Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rubber Planks and generic plank block #105

Merged
merged 3 commits into from
Aug 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/gregtech/common/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import gregtech.common.blocks.*;
import gregtech.common.blocks.wood.BlockGregLeaves;
import gregtech.common.blocks.wood.BlockGregLog;
import gregtech.common.blocks.wood.BlockGregPlank;
import gregtech.common.blocks.wood.BlockGregSapling;
import gregtech.common.items.MetaItems;
import gregtech.common.pipelike.cable.BlockCable;
Expand Down Expand Up @@ -97,6 +98,7 @@ public static void registerBlocks(RegistryEvent.Register<Block> event) {
registry.register(LOG);
registry.register(LEAVES);
registry.register(SAPLING);
registry.register(PLANKS);
registry.register(SURFACE_ROCK);

COMPRESSED.values().stream().distinct().forEach(registry::register);
Expand Down Expand Up @@ -145,6 +147,7 @@ public static void registerItems(RegistryEvent.Register<Item> event) {
registry.register(createMultiTexItemBlock(LOG, state -> state.getValue(BlockGregLog.VARIANT).getName()));
registry.register(createMultiTexItemBlock(LEAVES, state -> state.getValue(BlockGregLeaves.VARIANT).getName()));
registry.register(createMultiTexItemBlock(SAPLING, state -> state.getValue(BlockGregSapling.VARIANT).getName()));
registry.register(createMultiTexItemBlock(PLANKS, state -> state.getValue(BlockGregPlank.VARIANT).getName()));

COMPRESSED.values()
.stream().distinct()
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/gregtech/common/blocks/MetaBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import gregtech.common.blocks.surfacerock.TileEntitySurfaceRock;
import gregtech.common.blocks.wood.BlockGregLeaves;
import gregtech.common.blocks.wood.BlockGregLog;
import gregtech.common.blocks.wood.BlockGregPlank;
import gregtech.common.blocks.wood.BlockGregSapling;
import gregtech.common.pipelike.cable.BlockCable;
import gregtech.common.pipelike.cable.Insulation;
Expand Down Expand Up @@ -106,6 +107,7 @@ private MetaBlocks() {
public static BlockGregLog LOG;
public static BlockGregLeaves LEAVES;
public static BlockGregSapling SAPLING;
public static BlockGregPlank PLANKS;

public static BlockSurfaceRock SURFACE_ROCK;

Expand Down Expand Up @@ -178,6 +180,8 @@ public static void init() {
LEAVES.setRegistryName("leaves");
SAPLING = new BlockGregSapling();
SAPLING.setRegistryName("sapling");
PLANKS = new BlockGregPlank();
PLANKS.setRegistryName("plank");

SURFACE_ROCK = new BlockSurfaceRock();
SURFACE_ROCK.setRegistryName("surface_rock_new");
Expand Down Expand Up @@ -227,6 +231,7 @@ public static void init() {
//could possibly override block methods, but since these props don't depend on state why not just use nice and simple vanilla method
Blocks.FIRE.setFireInfo(LOG, 5, 5);
Blocks.FIRE.setFireInfo(LEAVES, 30, 60);
Blocks.FIRE.setFireInfo(PLANKS, 5, 20);
}

/**
Expand Down Expand Up @@ -336,6 +341,7 @@ public static void registerItemModels() {
registerItemModelWithOverride(LOG, ImmutableMap.of(BlockGregLog.LOG_AXIS, EnumAxis.Y));
registerItemModel(LEAVES);
registerItemModel(SAPLING);
registerItemModel(PLANKS);

COMPRESSED.values().stream().distinct().forEach(MetaBlocks::registerItemModel);
FRAMES.values().forEach(MetaBlocks::registerItemModelWithFilteredProperties);
Expand Down Expand Up @@ -466,6 +472,7 @@ public static void registerOreDict() {
OreDictUnifier.registerOre(new ItemStack(LOG, 1, GTValues.W), OrePrefix.log, Materials.Wood);
OreDictUnifier.registerOre(new ItemStack(LEAVES, 1, GTValues.W), "treeLeaves");
OreDictUnifier.registerOre(new ItemStack(SAPLING, 1, GTValues.W), "treeSapling");
OreDictUnifier.registerOre(new ItemStack(PLANKS, 1, GTValues.W), OrePrefix.plank, Materials.Wood);
GameRegistry.addSmelting(LOG, new ItemStack(Items.COAL, 1, 1), 0.15F);

for (Entry<Material, BlockCompressed> entry : COMPRESSED.entrySet()) {
Expand Down
89 changes: 89 additions & 0 deletions src/main/java/gregtech/common/blocks/wood/BlockGregPlank.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package gregtech.common.blocks.wood;

import gregtech.api.GregTechAPI;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;

import javax.annotation.Nonnull;

public class BlockGregPlank extends Block {

public static final PropertyEnum<PlankVariant> VARIANT = PropertyEnum.create("variant", PlankVariant.class);

public BlockGregPlank() {
super(Material.WOOD);
this.setDefaultState(this.blockState.getBaseState()
.withProperty(VARIANT, PlankVariant.RUBBER_PLANK));
setTranslationKey("gt.plank");
this.setCreativeTab(GregTechAPI.TAB_GREGTECH);
}

@Override
public void getSubBlocks(@Nonnull CreativeTabs itemIn, @Nonnull NonNullList<ItemStack> items) {
for(PlankVariant plankVariant : PlankVariant.values()) {
items.add(getItem(plankVariant));
}
}

@Nonnull
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, VARIANT);
}

@Nonnull
@Override
@SuppressWarnings("deprecation")
public IBlockState getStateFromMeta(int meta) {
return getDefaultState().withProperty(VARIANT, PlankVariant.values()[meta]);
}

@Override
public int getMetaFromState(IBlockState state) {
return state.getValue(VARIANT).ordinal();
}

@Nonnull
@Override
public ItemStack getPickBlock(IBlockState state, @Nonnull RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EntityPlayer player) {
return new ItemStack(Item.getItemFromBlock(this), 1,
state.getValue(VARIANT).ordinal());
}

public ItemStack getItem(PlankVariant variant) {
return new ItemStack(this, 1, variant.ordinal());
}

public ItemStack getItem(PlankVariant variant, int amount) {
return new ItemStack(this, amount, variant.ordinal());
}

public enum PlankVariant implements IStringSerializable {

RUBBER_PLANK("rubber_plank");

private final String name;

PlankVariant(String name) {
this.name = name;
}

@Nonnull
@Override
public String getName() {
return name;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
import gregtech.common.blocks.BlockTransparentCasing;
import gregtech.common.blocks.MetaBlocks;
import gregtech.common.blocks.wood.BlockGregLog.LogVariant;
import gregtech.common.blocks.wood.BlockGregPlank;
import gregtech.common.crafting.FacadeRecipe;
import gregtech.common.items.MetaItems;
import gregtech.loaders.oreprocessing.ToolRecipeHandler;
import net.minecraft.block.BlockPlanks.EnumType;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
Expand Down Expand Up @@ -93,7 +92,7 @@ private static void loadCraftingRecipes() {
MetaItems.CAPACITOR.getStackForm());
}

ModHandler.addShapelessRecipe("rubber_wood_planks", new ItemStack(Blocks.PLANKS, 4, EnumType.JUNGLE.getMetadata()), new ItemStack(MetaBlocks.LOG, 1, LogVariant.RUBBER_WOOD.ordinal()));
ModHandler.addShapelessRecipe("rubber_wood_planks", new ItemStack(MetaBlocks.PLANKS, 4, BlockGregPlank.PlankVariant.RUBBER_PLANK.ordinal()), new ItemStack(MetaBlocks.LOG, 1, LogVariant.RUBBER_WOOD.ordinal()));

ModHandler.addShapedRecipe("paper_ring", OreDictUnifier.get(OrePrefix.ring, Materials.Paper), "k", "X", 'X', new UnificationEntry(OrePrefix.plate, Materials.Paper));
ModHandler.addShapedRecipe("rubber_ring", OreDictUnifier.get(OrePrefix.ring, Materials.Rubber), "k", "X", 'X', new UnificationEntry(OrePrefix.plate, Materials.Rubber));
Expand Down
18 changes: 18 additions & 0 deletions src/main/resources/assets/gregtech/blockstates/plank.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"forge_marker": 1,
"defaults": {
"model": "minecraft:cube_all",
"textures": {
"all": "gregtech:blocks/rendering_error"
}
},
"variants": {
"variant": {
"rubber_plank": {
"textures": {
"all": "gregtech:blocks/wood/rubber/planks_rubber"
}
}
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/gregtech/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,7 @@ tile.gt.reinforced_stone.name=Reinforced Stone
tile.gt.log.rubber_wood.name=Rubber Wood
tile.gt.leaves.rubber_wood.name=Rubber Tree Leaves
tile.gt.sapling.rubber_wood.name=Rubber Tree Sapling
tile.gt.plank.rubber_plank.name=Rubber Wood Planks

tile.surface_rock.name=Surface Rock

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.