Skip to content

Commit

Permalink
Implement custom glass panes
Browse files Browse the repository at this point in the history
  • Loading branch information
IcarussOne committed Mar 22, 2024
1 parent c9985e2 commit ffaf2bb
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/main/java/drzhark/mocreatures/block/MoCBlockGlass.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
import java.util.Random;

public class MoCBlockGlass extends BlockBreakable {
private final boolean isTranslucent;

public MoCBlockGlass() {
public MoCBlockGlass(boolean isTranslucent) {
super(Material.GLASS, false);
this.setSoundType(SoundType.GLASS);
this.setHarvestLevel("pickaxe", 0);
this.isTranslucent = isTranslucent;
}

@Override
Expand All @@ -29,7 +31,7 @@ public int quantityDropped(Random random) {
@Override
@SideOnly(Side.CLIENT)
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.TRANSLUCENT;
return this.isTranslucent ? BlockRenderLayer.TRANSLUCENT : BlockRenderLayer.CUTOUT_MIPPED;
}

@Override
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/drzhark/mocreatures/block/MoCBlockPane.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package drzhark.mocreatures.block;

import java.util.Random;

import net.minecraft.block.BlockPane;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.BlockRenderLayer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class MoCBlockPane extends BlockPane {
private final boolean canDrop;
private final boolean isTranslucent;

public MoCBlockPane(Material material, SoundType soundType, boolean canDrop, boolean isTranslucent) {
super(material, canDrop);
this.setSoundType(soundType);
this.setHarvestLevel("pickaxe", 0);
this.canDrop = canDrop;
this.isTranslucent = isTranslucent;
}

@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
return !this.canDrop ? Items.AIR : super.getItemDropped(state, rand, fortune);
}

@Override
@SideOnly(Side.CLIENT)
public BlockRenderLayer getRenderLayer() {
return this.isTranslucent ? BlockRenderLayer.TRANSLUCENT : BlockRenderLayer.CUTOUT_MIPPED;
}
}
7 changes: 6 additions & 1 deletion src/main/java/drzhark/mocreatures/init/MoCBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import drzhark.mocreatures.block.MoCBlockSapling.EnumWoodType;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.StateMap;
import net.minecraft.item.Item;
Expand Down Expand Up @@ -67,6 +69,8 @@ public class MoCBlocks {
public static Block firestone;
@GameRegistry.ObjectHolder("gleaming_glass")
public static Block gleamingGlass;
@GameRegistry.ObjectHolder("gleaming_glass_pane")
public static Block gleamingGlassPane;
@GameRegistry.ObjectHolder("mossy_cobbled_wyvstone")
public static Block mossyCobbledWyvstone;
@GameRegistry.ObjectHolder("mossy_cobbled_wyvstone_stairs")
Expand Down Expand Up @@ -164,7 +168,8 @@ public static void registerBlocks(RegistryEvent.Register<Block> event) {
setup(new MoCBlockRock(MapColor.STONE), "mossy_cobbled_deep_wyvstone").setHardness(3.5F).setResistance(10.0F),
setup(new MoCBlockStairs(new MoCBlockRock(MapColor.STONE).getDefaultState(), false), "mossy_cobbled_deep_wyvstone_stairs").setHardness(3.5F).setResistance(10.0F),
setup(new MoCBlockWall(new MoCBlockRock(MapColor.STONE), false), "mossy_cobbled_deep_wyvstone_wall").setHardness(3.5F).setResistance(10.0F),
setup(new MoCBlockGlass(), "gleaming_glass").setHardness(0.4F),
setup(new MoCBlockGlass(true), "gleaming_glass").setHardness(0.4F),
setup(new MoCBlockPane(Material.GLASS, SoundType.GLASS, false, true), "gleaming_glass_pane").setHardness(0.4F),
setup(new MoCBlockSand(MapColor.CLAY), "silver_sand").setHardness(0.6F),
setup(new MoCBlockRock(MapColor.CLAY), "silver_sandstone").setHardness(1.2F),
setup(new MoCBlockStairs(new MoCBlockRock(MapColor.CLAY).getDefaultState(), false), "silver_sandstone_stairs").setHardness(1.2F),
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/drzhark/mocreatures/init/MoCRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,28 @@ public static void registerRecipes(final RegistryEvent.Register<IRecipe> event)
OreDictionary.registerOre("cobblestone", new ItemStack(MoCBlocks.cobbledDeepWyvstone));
OreDictionary.registerOre("cobblestone", new ItemStack(MoCBlocks.cobbledWyvstone));
OreDictionary.registerOre("dirt", new ItemStack(MoCBlocks.wyvdirt));
OreDictionary.registerOre("doorWood", new ItemStack(MoCBlocks.wyvwoodDoor));
OreDictionary.registerOre("fenceWood", new ItemStack(MoCBlocks.wyvwoodFence));
OreDictionary.registerOre("fenceGateWood", new ItemStack(MoCBlocks.wyvwoodFenceGate));
OreDictionary.registerOre("grass", new ItemStack(MoCBlocks.wyvgrass));
OreDictionary.registerOre("logWood", new ItemStack(MoCBlocks.wyvwoodLog));
OreDictionary.registerOre("oreDiamond", new ItemStack(MoCBlocks.wyvernDiamondOre));
OreDictionary.registerOre("oreEmerald", new ItemStack(MoCBlocks.wyvernEmeraldOre));
OreDictionary.registerOre("oreGold", new ItemStack(MoCBlocks.wyvernGoldOre));
OreDictionary.registerOre("oreIron", new ItemStack(MoCBlocks.wyvernIronOre));
OreDictionary.registerOre("oreLapis", new ItemStack(MoCBlocks.wyvernLapisOre));
OreDictionary.registerOre("paneGlass", new ItemStack(MoCBlocks.gleamingGlassPane));
OreDictionary.registerOre("paneGlassColorless", new ItemStack(MoCBlocks.gleamingGlassPane));
OreDictionary.registerOre("plankWood", new ItemStack(MoCBlocks.wyvwoodPlanks));
OreDictionary.registerOre("sand", new ItemStack(MoCBlocks.silverSand));
OreDictionary.registerOre("sandstone", new ItemStack(MoCBlocks.carvedSilverSandstone));
OreDictionary.registerOre("sandstone", new ItemStack(MoCBlocks.silverSandstone));
OreDictionary.registerOre("sandstone", new ItemStack(MoCBlocks.smoothSilverSandstone));
//OreDictionary.registerOre("slabWood", new ItemStack(MoCBlocks.wyvwoodPlanks));
OreDictionary.registerOre("stairWood", new ItemStack(MoCBlocks.wyvwoodPlanksStairs));
OreDictionary.registerOre("stone", new ItemStack(MoCBlocks.deepWyvstone));
OreDictionary.registerOre("stone", new ItemStack(MoCBlocks.wyvstone));
OreDictionary.registerOre("trapdoorWood", new ItemStack(MoCBlocks.wyvwoodTrapdoor));
OreDictionary.registerOre("treeLeaves", new ItemStack(MoCBlocks.wyvwoodLeaves));
OreDictionary.registerOre("treeSapling", new ItemStack(MoCBlocks.wyvwoodSapling));

Expand All @@ -117,6 +125,9 @@ public static void registerRecipes(final RegistryEvent.Register<IRecipe> event)
OreDictionary.registerOre("chitinScorpion", MoCItems.chitinNether);
OreDictionary.registerOre("chitinScorpion", MoCItems.chitinUndead);
OreDictionary.registerOre("egg", new ItemStack(MoCItems.mocegg, 1, OreDictionary.WILDCARD_VALUE));
OreDictionary.registerOre("hide", MoCItems.animalHide);
OreDictionary.registerOre("hide", MoCItems.hideCroc);
OreDictionary.registerOre("hideSmall", Items.RABBIT_HIDE);
OreDictionary.registerOre("ingotSilver", MoCItems.ancientSilverIngot);
OreDictionary.registerOre("nuggetSilver", MoCItems.ancientSilverNugget);
OreDictionary.registerOre("record", MoCItems.recordshuffle);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"forge_marker": 1,
"defaults": {
"model": "pane_post",
"textures": {
"edge": "mocreatures:blocks/glass_gleaming_top",
"pane": "mocreatures:blocks/glass_gleaming",
"layer0": "mocreatures:blocks/glass_gleaming"
}
},
"variants": {
"inventory": [
{
"transform": "forge:default-item",
"model": "builtin/generated",
"textures": {
"layer0": "mocreatures:blocks/glass_gleaming"
}
}
],
"normal": [
{
"transform": "forge:default-item",
"model": "builtin/generated",
"textures": {
"layer0": "mocreatures:blocks/glass_gleaming"
}
}
],
"north": {
"true": {
"submodel": {
"nside": {
"model": "pane_side"
}
}
},
"false": {
"submodel": {
"nside": {
"model": "pane_noside"
}
}
}
},
"south": {
"true": {
"submodel": {
"sside": {
"model": "pane_side_alt"
}
}
},
"false": {
"submodel": {
"sside": {
"model": "pane_noside_alt",
"y": 90
}
}
}
},
"west": {
"true": {
"submodel": {
"wside": {
"model": "pane_side_alt",
"y": 90
}
}
},
"false": {
"submodel": {
"wside": {
"model": "pane_noside",
"y": 270
}
}
}
},
"east": {
"true": {
"submodel": {
"eside": {
"model": "pane_side",
"y": 90
}
}
},
"false": {
"submodel": {
"eside": {
"model": "pane_noside_alt"
}
}
}
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/mocreatures/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ tile.mocreatures.deep_wyvstone_stairs.name=Deep Wyvstone Stairs [NYI]
tile.mocreatures.deep_wyvstone_wall.name=Deep Wyvstone Wall [NYI]
tile.mocreatures.firestone.name=Firestone [NYI]
tile.mocreatures.gleaming_glass.name=Gleaming Glass
tile.mocreatures.gleaming_glass_pane.name=Gleaming Glass Pane
tile.mocreatures.mossy_cobbled_wyvstone.name=Mossy Cobbled Wyvstone
tile.mocreatures.mossy_cobbled_wyvstone_stairs.name=Mossy Cobbled Wyvstone Stairs
tile.mocreatures.mossy_cobbled_wyvstone_wall.name=Mossy Cobbled Wyvstone Wall
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"type": "forge:ore_shaped",
"pattern": [
"XXX",
"XXX"
],
"key": {
"X": {
"item": "mocreatures:gleaming_glass"
}
},
"result": {
"item": "mocreatures:gleaming_glass_pane",
"count": 16
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ffaf2bb

Please sign in to comment.