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:
parent
7b672244c3
commit
99a2a28d91
22 changed files with 191 additions and 45 deletions
|
@ -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);
|
||||
|
|
|
@ -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)));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue