Skip to content

Commit

Permalink
Blastproof glass (recipes not done yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lykrast committed Sep 7, 2024
1 parent dd50960 commit 5dd8a53
Show file tree
Hide file tree
Showing 129 changed files with 787 additions and 47 deletions.
43 changes: 36 additions & 7 deletions src/main/java/lykrast/glassential/Glassential.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,43 @@ public static void makeCreativeTab(RegisterEvent event) {
});
}

private static final String GHOSTLY = "tooltip.glassential.ghostly", LIGHT = "tooltip.glassential.light", OBSIDIAN = "tooltip.glassential.obsidian";

static {
makeBlock("glass_redstone", () -> new RedstoneGlassBlock(glassProp()));
makeBlock("glass_ghostly", () -> new TooltipGlassBlock(ghostProp(), "tooltip.glassential.ghostly"));
makeBlock("glass_ghostly", () -> new TooltipGlassBlock(ghostProp(), GHOSTLY));
makeBlock("glass_ethereal", () -> new EtherealGlassBlock(ghostProp(), false));
makeBlock("glass_ethereal_reverse", () -> new EtherealGlassBlock(ghostProp(), true));
makeBlock("glass_dark_ghostly", () -> new DarkGlassBlock(ghostProp(), "tooltip.glassential.ghostly"));
makeBlock("glass_dark_ghostly", () -> new DarkGlassBlock(ghostProp(), GHOSTLY));
makeBlock("glass_dark_ethereal", () -> new DarkEtherealGlassBlock(ghostProp(), false));
makeBlock("glass_dark_ethereal_reverse", () -> new DarkEtherealGlassBlock(ghostProp(), true));
makeBlock("glass_light", () -> new TooltipGlassBlock(glassProp().lightLevel((b) -> 15), "tooltip.glassential.light"));
makeBlock("glass_light_ghostly", () -> new TooltipGlassBlock(ghostProp().lightLevel((b) -> 15), "tooltip.glassential.ghostly", "tooltip.glassential.light"));
makeBlock("glass_light_ethereal", () -> new EtherealGlassBlock(ghostProp().lightLevel((b) -> 15), false, "tooltip.glassential.light"));
makeBlock("glass_light_ethereal_reverse", () -> new EtherealGlassBlock(ghostProp().lightLevel((b) -> 15), true, "tooltip.glassential.light"));
makeBlock("glass_light", () -> new TooltipGlassBlock(glassProp().lightLevel((b) -> 15), LIGHT));
makeBlock("glass_light_ghostly", () -> new TooltipGlassBlock(ghostProp().lightLevel((b) -> 15), GHOSTLY, LIGHT));
makeBlock("glass_light_ethereal", () -> new EtherealGlassBlock(ghostProp().lightLevel((b) -> 15), false, LIGHT));
makeBlock("glass_light_ethereal_reverse", () -> new EtherealGlassBlock(ghostProp().lightLevel((b) -> 15), true, LIGHT));
makeBlock("glass_magma", () -> new MagmaGlassBlock(glassProp().lightLevel((b) -> 3)));
makeBlock("glass_magma_ghostly", () -> new MagmaGlassBlock(ghostProp().lightLevel((b) -> 3), "tooltip.glassential.ghostly"));
makeBlock("glass_magma_ghostly", () -> new MagmaGlassBlock(ghostProp().lightLevel((b) -> 3), GHOSTLY));
makeBlock("glass_magma_ethereal", () -> new MagmaEtherealGlassBlock(ghostProp().lightLevel((b) -> 3), false));
makeBlock("glass_magma_ethereal_reverse", () -> new MagmaEtherealGlassBlock(ghostProp().lightLevel((b) -> 3), true));

makeBlock("glass_obsidian", () -> new TooltipGlassBlock(obsidian(), OBSIDIAN));
makeBlock("glass_obsidian_redstone", () -> new RedstoneGlassBlock(obsidian(), OBSIDIAN));
makeBlock("glass_obsidian_ghostly", () -> new TooltipGlassBlock(ghostbsidian(), GHOSTLY));
makeBlock("glass_obsidian_ethereal", () -> new EtherealGlassBlock(ghostbsidian(), false, OBSIDIAN));
makeBlock("glass_obsidian_ethereal_reverse", () -> new EtherealGlassBlock(ghostbsidian(), true, OBSIDIAN));
makeBlock("glass_obsidian_dark", () -> new DarkGlassBlock(obsidian(), null, OBSIDIAN));
makeBlock("glass_obsidian_dark_ghostly", () -> new DarkGlassBlock(ghostbsidian(), GHOSTLY, OBSIDIAN));
makeBlock("glass_obsidian_dark_ethereal", () -> new DarkEtherealGlassBlock(ghostbsidian(), false, OBSIDIAN));
makeBlock("glass_obsidian_dark_ethereal_reverse", () -> new DarkEtherealGlassBlock(ghostbsidian(), true, OBSIDIAN));
makeBlock("glass_obsidian_light", () -> new TooltipGlassBlock(obsidian().lightLevel((b) -> 15), LIGHT, OBSIDIAN));
makeBlock("glass_obsidian_light_ghostly", () -> new TooltipGlassBlock(ghostbsidian().lightLevel((b) -> 15), GHOSTLY, LIGHT, OBSIDIAN));
makeBlock("glass_obsidian_light_ethereal", () -> new EtherealGlassBlock(ghostbsidian().lightLevel((b) -> 15), false, LIGHT, OBSIDIAN));
makeBlock("glass_obsidian_light_ethereal_reverse", () -> new EtherealGlassBlock(ghostbsidian().lightLevel((b) -> 15), true, LIGHT, OBSIDIAN));
//it's a lil bit of a mess how I ordered the tooltips, hence the extra null
makeBlock("glass_obsidian_magma", () -> new MagmaGlassBlock(obsidian().lightLevel((b) -> 3), null, OBSIDIAN));
makeBlock("glass_obsidian_magma_ghostly", () -> new MagmaGlassBlock(ghostbsidian().lightLevel((b) -> 3), GHOSTLY, OBSIDIAN));
makeBlock("glass_obsidian_magma_ethereal", () -> new MagmaEtherealGlassBlock(ghostbsidian().lightLevel((b) -> 3), false, OBSIDIAN));
makeBlock("glass_obsidian_magma_ethereal_reverse", () -> new MagmaEtherealGlassBlock(ghostbsidian().lightLevel((b) -> 3), true, OBSIDIAN));
}

private static RegistryObject<Block> makeBlock(String name, Supplier<Block> block) {
Expand All @@ -105,6 +126,14 @@ private static Block.Properties ghostProp() {
return glassProp().forceSolidOn().noCollission();
}

private static Block.Properties obsidian() {
return glassProp().strength(0.5f, 1200);
}

private static Block.Properties ghostbsidian() {
return ghostProp().strength(0.5f, 1200);
}

//Private predicates from Blocks, no need to AT something like that
private static Boolean neverAllowSpawn(BlockState state, BlockGetter reader, BlockPos pos, EntityType<?> entity) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
public class DarkEtherealGlassBlock extends EtherealGlassBlock {

public DarkEtherealGlassBlock(Block.Properties properties, boolean collidePlayers) {
super(properties, collidePlayers, "tooltip.glassential.dark");
this(properties, collidePlayers, null);
}

public DarkEtherealGlassBlock(Block.Properties properties, boolean collidePlayers, String third) {
super(properties, collidePlayers, "tooltip.glassential.dark", third);
}

@Override
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/lykrast/glassential/blocks/DarkGlassBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
import net.minecraftforge.api.distmarker.OnlyIn;

public class DarkGlassBlock extends GlassBlock {
private String extraTooltip;
private String extraTooltip, second;

public DarkGlassBlock(Block.Properties properties, String extraTooltip) {
this(properties, extraTooltip, null);
}

public DarkGlassBlock(Block.Properties properties, String extraTooltip, String second) {
super(properties);
this.extraTooltip = extraTooltip;
this.second = second;
}

@Override
Expand All @@ -40,5 +45,6 @@ public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List
super.appendHoverText(stack, worldIn, tooltip, flagIn);
if (extraTooltip != null) tooltip.add(Component.translatable(extraTooltip).withStyle(ChatFormatting.GRAY));
tooltip.add(Component.translatable("tooltip.glassential.dark").withStyle(ChatFormatting.GRAY));
if (second != null) tooltip.add(Component.translatable(second).withStyle(ChatFormatting.GRAY));
}
}
10 changes: 7 additions & 3 deletions src/main/java/lykrast/glassential/blocks/EtherealGlassBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ public class EtherealGlassBlock extends TooltipGlassBlock {
private final boolean collidePlayers;

public EtherealGlassBlock(Block.Properties properties, boolean collidePlayers) {
this(properties, collidePlayers, null);
this(properties, collidePlayers, null, null);
}

public EtherealGlassBlock(Block.Properties properties, boolean collidePlayers, String second) {
super(properties, collidePlayers ? "tooltip.glassential.ethereal_reverse" : "tooltip.glassential.ethereal", second);
this(properties, collidePlayers, second, null);
}

public EtherealGlassBlock(Block.Properties properties, boolean collidePlayers, String second, String third) {
super(properties, collidePlayers ? "tooltip.glassential.ethereal_reverse" : "tooltip.glassential.ethereal", second, third);
this.collidePlayers = collidePlayers;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
public class MagmaEtherealGlassBlock extends EtherealGlassBlock {

public MagmaEtherealGlassBlock(Block.Properties properties, boolean collidePlayers) {
super(properties, collidePlayers, "tooltip.glassential.magma");
this(properties, collidePlayers, null);
}

public MagmaEtherealGlassBlock(Block.Properties properties, boolean collidePlayers, String third) {
super(properties, collidePlayers, "tooltip.glassential.magma", third);
}

@Override
Expand Down
34 changes: 7 additions & 27 deletions src/main/java/lykrast/glassential/blocks/MagmaGlassBlock.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,23 @@
package lykrast.glassential.blocks;

import java.util.List;

import javax.annotation.Nullable;

import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.GlassBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

public class MagmaGlassBlock extends GlassBlock {
private String extraTooltip;

public class MagmaGlassBlock extends TooltipGlassBlock {
public MagmaGlassBlock(Block.Properties properties) {
this(properties, null);
super(properties, "tooltip.glassential.magma");
}

public MagmaGlassBlock(Block.Properties properties, String extraTooltip) {
super(properties);
this.extraTooltip = extraTooltip;
this(properties, extraTooltip, null);
}

public MagmaGlassBlock(Block.Properties properties, String extraTooltip, String third) {
super(properties, extraTooltip, "tooltip.glassential.magma", third);
}

@Override
Expand All @@ -47,12 +35,4 @@ public void entityInside(BlockState state, Level level, BlockPos pos, Entity ent
//that makes it different from cactus but eeeh we'll see
if (entity instanceof LivingEntity) entity.hurt(level.damageSources().hotFloor(), 1);
}

@Override
@OnlyIn(Dist.CLIENT)
public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) {
super.appendHoverText(stack, worldIn, tooltip, flagIn);
if (extraTooltip != null) tooltip.add(Component.translatable(extraTooltip).withStyle(ChatFormatting.GRAY));
tooltip.add(Component.translatable("tooltip.glassential.magma").withStyle(ChatFormatting.GRAY));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@
import net.minecraftforge.api.distmarker.OnlyIn;

public class RedstoneGlassBlock extends GlassBlock {
private String extraTooltip;

public RedstoneGlassBlock(Block.Properties settings) {
this(settings, null);
}

public RedstoneGlassBlock(Block.Properties settings, String extraTooltip) {
super(settings);
this.extraTooltip = extraTooltip;
}

@Override
Expand All @@ -38,5 +44,6 @@ public int getSignal(BlockState state, BlockGetter world, BlockPos pos, Directio
public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) {
super.appendHoverText(stack, worldIn, tooltip, flagIn);
tooltip.add(Component.translatable("tooltip.glassential.redstone").withStyle(ChatFormatting.GRAY));
if (extraTooltip != null) tooltip.add(Component.translatable(extraTooltip).withStyle(ChatFormatting.GRAY));
}
}
15 changes: 10 additions & 5 deletions src/main/java/lykrast/glassential/blocks/TooltipGlassBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,30 @@

public class TooltipGlassBlock extends GlassBlock {
//Used for Light and Ghostly glass that don't need their own classes for their properties
private String tooltip;
private String second;
private String tooltip, second, third;

public TooltipGlassBlock(Properties properties, String tooltip) {
this(properties, tooltip, null);
this(properties, tooltip, null, null);
}

public TooltipGlassBlock(Properties properties, String tooltip, String second) {
this(properties, tooltip, second, null);
}

public TooltipGlassBlock(Properties properties, String tooltip, String second, String third) {
super(properties);
this.tooltip = tooltip;
this.second = second;
this.third = third;
}

@Override
@OnlyIn(Dist.CLIENT)
public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) {
super.appendHoverText(stack, worldIn, tooltip, flagIn);
tooltip.add(Component.translatable(this.tooltip).withStyle(ChatFormatting.GRAY));
if (this.tooltip != null) tooltip.add(Component.translatable(this.tooltip).withStyle(ChatFormatting.GRAY));
if (second != null) tooltip.add(Component.translatable(second).withStyle(ChatFormatting.GRAY));
if (third != null) tooltip.add(Component.translatable(third).withStyle(ChatFormatting.GRAY));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian_dark" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian_dark_ethereal" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian_dark_ethereal_reverse" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian_dark_ghostly" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian_ethereal" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian_ethereal_reverse" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian_ghostly" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian_light" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian_light_ethereal" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian_light_ethereal_reverse" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian_light_ghostly" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian_magma" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian_magma_ethereal" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian_magma_ethereal_reverse" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian_magma_ghostly" }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "glassential:block/glass_obsidian_redstone" }
}
}
Loading

0 comments on commit 5dd8a53

Please sign in to comment.