Add rubber wood and stripped rubber wood (#2086). Thanks to haykam821

* Make rubber wood block names consistent with vanilla
* Add rubber wood
* Add stripped rubber wood
* Add block and item tags for rubber logs
* Allow crafting all types of rubber logs into rubber planks
* Allow extracting rubber from rubber wood and stripped rubber wood
This commit is contained in:
haykam821 2020-04-17 07:28:59 -04:00 committed by GitHub
parent 7b672244c3
commit 99a2a28d91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 191 additions and 45 deletions

View file

@ -26,15 +26,25 @@ package techreborn;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ComposterBlock;
import net.minecraft.block.PillarBlock;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.AxeItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import net.minecraft.util.math.BlockPos;
import reborncore.common.blockentity.RedstoneConfiguration;
import reborncore.common.config.Configuration;
import reborncore.common.recipes.RecipeCrafter;
@ -104,6 +114,44 @@ public class TechReborn implements ModInitializer {
RedstoneConfiguration.fluidStack = DynamicCellItem.getCellWithFluid(Fluids.LAVA);
RedstoneConfiguration.powerStack = new ItemStack(TRContent.RED_CELL_BATTERY);
UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> {
ItemStack stack = player.getStackInHand(hand);
if (stack.getItem() instanceof AxeItem) {
BlockPos pos = hitResult.getBlockPos();
BlockState hitState = world.getBlockState(pos);
Block hitBlock = hitState.getBlock();
Block strippedBlock = null;
if (hitBlock == TRContent.RUBBER_LOG) {
strippedBlock = TRContent.RUBBER_LOG_STRIPPED;
} else if (hitBlock == TRContent.RUBBER_WOOD) {
strippedBlock = TRContent.STRIPPED_RUBBER_WOOD;
}
if (strippedBlock != null) {
// Play stripping sound
world.playSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F);
if (world.isClient) {
return ActionResult.SUCCESS;
}
world.setBlockState(pos, strippedBlock.getDefaultState().with(PillarBlock.AXIS, hitState.get(PillarBlock.AXIS)), 11);
// Damage axe
if (player instanceof LivingEntity) {
LivingEntity playerEntity = (LivingEntity) player;
stack.damage(1, playerEntity, playerx -> {
playerx.sendToolBreakStatus(hand);
});
}
return ActionResult.SUCCESS;
}
}
return ActionResult.PASS;
});
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.put(TRContent.RUBBER_SAPLING.asItem(), 0.3F);
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.put(TRContent.RUBBER_LEAVES.asItem(), 0.3F);
ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE.put(TRContent.Parts.PLANTBALL.asItem(), 1F);

View file

@ -131,19 +131,6 @@ public class BlockRubberLog extends LogBlock {
return ActionResult.PASS;
}
if (stack.getItem() instanceof AxeItem) {
worldIn.playSound(playerIn, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F);
if (worldIn.isClient) {
return ActionResult.SUCCESS;
}
worldIn.setBlockState(pos, TRContent.RUBBER_LOG_STRIPPED.getDefaultState().with(PillarBlock.AXIS, state.get(PillarBlock.AXIS)), 11);
if (playerIn instanceof LivingEntity) {
LivingEntity playerEntity = (LivingEntity) playerIn;
stack.damage(1, playerEntity, player -> { player.sendToolBreakStatus(hand); });
}
return ActionResult.SUCCESS;
}
if ((Energy.valid(stack) && Energy.of(stack).getEnergy() > 20 && stack.getItem() instanceof ElectricTreetapItem) || stack.getItem() instanceof TreeTapItem) {
if (state.get(HAS_SAP) && state.get(SAP_SIDE) == hitResult.getSide()) {
worldIn.setBlockState(pos, state.with(HAS_SAP, false).with(SAP_SIDE, Direction.fromHorizontal(0)));

View file

@ -87,6 +87,8 @@ public class ModRegistry {
RebornRegistry.registerBlock(TRContent.RUBBER_LEAVES = InitUtils.setup(new BlockRubberLeaves(), "rubber_leaves"), itemGroup);
RebornRegistry.registerBlock(TRContent.RUBBER_LOG = InitUtils.setup(new BlockRubberLog(), "rubber_log"), itemGroup);
RebornRegistry.registerBlock(TRContent.RUBBER_LOG_STRIPPED = InitUtils.setup(new LogBlock(MaterialColor.SPRUCE, InitUtils.setupRubberBlockSettings(2.0F, 15.0F)), "rubber_log_stripped"), itemGroup);
RebornRegistry.registerBlock(TRContent.RUBBER_WOOD = InitUtils.setup(new LogBlock(MaterialColor.SPRUCE, InitUtils.setupRubberBlockSettings(2.0F, 15.0F)), "rubber_wood"), itemGroup);
RebornRegistry.registerBlock(TRContent.STRIPPED_RUBBER_WOOD = InitUtils.setup(new LogBlock(MaterialColor.SPRUCE, InitUtils.setupRubberBlockSettings(2.0F, 15.0F)), "stripped_rubber_wood"), itemGroup);
RebornRegistry.registerBlock(TRContent.RUBBER_PLANKS = InitUtils.setup(new BlockRubberPlank(), "rubber_planks"), itemGroup);
RebornRegistry.registerBlock(TRContent.RUBBER_SAPLING = InitUtils.setup(new BlockRubberSapling(), "rubber_sapling"), itemGroup);
RebornRegistry.registerBlock(TRContent.RUBBER_PLANK_SLAB = InitUtils.setup(new SlabBlock(InitUtils.setupRubberBlockSettings(2.0F, 15.0F)), "rubber_plank_slab"), itemGroup);

View file

@ -142,6 +142,8 @@ public class TRContent {
public static Block RUBBER_PRESSURE_PLATE;
public static Block RUBBER_DOOR;
public static Block RUBBER_LOG_STRIPPED;
public static Block RUBBER_WOOD;
public static Block STRIPPED_RUBBER_WOOD;
// Armor
public static Item CLOAKING_DEVICE;

View file

@ -0,0 +1,7 @@
{
"variants": {
"axis=y": { "model": "techreborn:block/rubber/rubber_wood" },
"axis=z": { "model": "techreborn:block/rubber/rubber_wood", "x": 90 },
"axis=x": { "model": "techreborn:block/rubber/rubber_wood", "x": 90, "y": 90 }
}
}

View file

@ -0,0 +1,7 @@
{
"variants": {
"axis=y": { "model": "techreborn:block/rubber/stripped_rubber_wood" },
"axis=z": { "model": "techreborn:block/rubber/stripped_rubber_wood", "x": 90 },
"axis=x": { "model": "techreborn:block/rubber/stripped_rubber_wood", "x": 90, "y": 90 }
}
}

View file

@ -99,19 +99,21 @@
"block.techreborn.greenhouse_controller": "Greenhouse controller",
"_comment1": "Blocks",
"block.techreborn.rubber_log": "Rubber Wood",
"block.techreborn.rubber_log_stripped": "Stripped Rubber Wood",
"block.techreborn.rubber_planks": "Rubber Wood Planks",
"block.techreborn.rubber_plank_slab": "Rubber Wood Plank Slab",
"block.techreborn.rubber_plank_stair": "Rubber Wood Plank Stairs",
"block.techreborn.rubber_leaves": "Rubber Wood Leaves",
"block.techreborn.rubber_sapling": "Rubber Wood Sapling",
"block.techreborn.rubber_fence": "Rubber Wood Fence",
"block.techreborn.rubber_fence_gate": "Rubber Wood Fence Gate",
"block.techreborn.rubber_trapdoor": "Rubber Wood Trapdoor",
"block.techreborn.rubber_button": "Rubber Wood Button",
"block.techreborn.rubber_pressure_plate": "Rubber Wood Pressure Plate",
"block.techreborn.rubber_door": "Rubber Wood Door",
"block.techreborn.rubber_log": "Rubber Log",
"block.techreborn.rubber_log_stripped": "Stripped Rubber Log",
"block.techreborn.rubber_wood": "Rubber Wood",
"block.techreborn.stripped_rubber_wood": "Stripped Rubber Wood",
"block.techreborn.rubber_planks": "Rubber Planks",
"block.techreborn.rubber_plank_slab": "Rubber Slab",
"block.techreborn.rubber_plank_stair": "Rubber Stairs",
"block.techreborn.rubber_leaves": "Rubber Leaves",
"block.techreborn.rubber_sapling": "Rubber Sapling",
"block.techreborn.rubber_fence": "Rubber Fence",
"block.techreborn.rubber_fence_gate": "Rubber Fence Gate",
"block.techreborn.rubber_trapdoor": "Rubber Trapdoor",
"block.techreborn.rubber_button": "Rubber Button",
"block.techreborn.rubber_pressure_plate": "Rubber Pressure Plate",
"block.techreborn.rubber_door": "Rubber Door",
"block.techreborn.refined_iron_fence": "Iron Fence",
"block.techreborn.reinforced_glass": "Reinforced Glass",

View file

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/cube_column",
"textures": {
"end": "techreborn:block/rubber_log_side",
"side": "techreborn:block/rubber_log_side"
}
}

View file

@ -0,0 +1,7 @@
{
"parent": "minecraft:block/cube_column",
"textures": {
"end": "techreborn:block/stripped_rubber_log_side",
"side": "techreborn:block/stripped_rubber_log_side"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "techreborn:block/rubber/rubber_wood"
}

View file

@ -0,0 +1,3 @@
{
"parent": "techreborn:block/rubber/stripped_rubber_wood"
}

View file

@ -1,6 +1,6 @@
{
"replace": false,
"values": [
"techreborn:rubber_log"
"#techreborn:rubber_logs"
]
}

View file

@ -1,6 +1,6 @@
{
"replace": false,
"values": [
"techreborn:rubber_log"
"#techreborn:rubber_logs"
]
}

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "techreborn:rubber_wood"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "techreborn:stripped_rubber_wood"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -3,7 +3,7 @@
"group": "planks",
"ingredients": [
{
"item": "techreborn:rubber_log"
"tag": "techreborn:rubber_logs"
}
],
"result": {

View file

@ -0,0 +1,16 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"##",
"##"
],
"key": {
"#": {
"item": "techreborn:rubber_log"
}
},
"result": {
"item": "techreborn:rubber_wood",
"count": 3
}
}

View file

@ -0,0 +1,16 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"##",
"##"
],
"key": {
"#": {
"item": "techreborn:rubber_log_stripped"
}
},
"result": {
"item": "techreborn:stripped_rubber_wood",
"count": 3
}
}

View file

@ -4,7 +4,7 @@
"time": 300,
"ingredients": [
{
"item": "techreborn:rubber_log"
"tag": "techreborn:rubber_logs"
}
],
"results": [

View file

@ -1,15 +0,0 @@
{
"type": "techreborn:extractor",
"power": 10,
"time": 300,
"ingredients": [
{
"item": "techreborn:rubber_log_stripped"
}
],
"results": [
{
"item": "techreborn:rubber"
}
]
}

View file

@ -0,0 +1,8 @@
{
"values": [
"techreborn:rubber_log",
"techreborn:rubber_log_stripped",
"techreborn:rubber_wood",
"techreborn:stripped_rubber_wood"
]
}

View file

@ -0,0 +1,8 @@
{
"values": [
"techreborn:rubber_log",
"techreborn:rubber_log_stripped",
"techreborn:rubber_wood",
"techreborn:stripped_rubber_wood"
]
}