Stripped version of Rubber Log.

This commit is contained in:
drcrazy 2019-10-08 13:03:01 +03:00
parent e72edd5eec
commit 264224a6f9
9 changed files with 54 additions and 18 deletions

View file

@ -26,11 +26,14 @@ package techreborn.blocks.misc;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.*;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.AxeItem;
import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateFactory;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
@ -110,24 +113,37 @@ public class BlockRubberLog extends LogBlock {
}
@Override
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn,
Hand hand, BlockHitResult hitResult) {
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
super.activate(state, worldIn, pos, playerIn, hand, hitResult);
ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND);
if (stack.isEmpty()) {
return false;
}
if (stack.getItem() instanceof AxeItem) {
worldIn.playSound(playerIn, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F);
if (worldIn.isClient) {
return true;
}
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 true;
}
if ((Energy.valid(stack) && Energy.of(stack).getEnergy() > 20) || stack.getItem() instanceof ItemTreeTap) {
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)));
worldIn.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.SAP_EXTRACT, SoundCategory.BLOCKS,
0.6F, 1F);
if (!worldIn.isClient) {
worldIn.playSound(playerIn, pos, ModSounds.SAP_EXTRACT, SoundCategory.BLOCKS, 0.6F, 1F);
if (worldIn.isClient) {
return true;
}
if (Energy.valid(stack)) {
Energy.of(stack).use(20);
} else {
playerIn.getStackInHand(Hand.MAIN_HAND).damage(1, playerIn, playerEntity -> {});
stack.damage(1, playerIn, player -> { player.sendToolBreakStatus(hand); });
}
if (!playerIn.inventory.insertStack(TRContent.Parts.SAP.getStack())) {
WorldUtils.dropItem(TRContent.Parts.SAP.getStack(), worldIn, pos.offset(hitResult.getSide()));
@ -135,7 +151,7 @@ public class BlockRubberLog extends LogBlock {
if (playerIn instanceof ServerPlayerEntity) {
TRRecipeHandler.unlockTRRecipes((ServerPlayerEntity) playerIn);
}
}
return true;
}
}

View file

@ -26,6 +26,8 @@ package techreborn.events;
import net.minecraft.block.FenceBlock;
import net.minecraft.block.FenceGateBlock;
import net.minecraft.block.LogBlock;
import net.minecraft.block.MaterialColor;
import net.minecraft.block.SlabBlock;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.Item;
@ -111,6 +113,7 @@ public class ModRegistry {
RebornRegistry.registerBlock(TRContent.REINFORCED_GLASS = InitUtils.setup(new BlockReinforcedGlass(), "reinforced_glass"), itemGroup);
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_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

@ -93,6 +93,7 @@ public class TRContent {
public static Block RUBBER_BUTTON;
public static Block RUBBER_PRESSURE_PLATE;
public static Block RUBBER_DOOR;
public static Block RUBBER_LOG_STRIPPED;
// Armor
public static Item CLOAKING_DEVICE;

View file

@ -79,9 +79,8 @@ public class ItemChainsaw extends AxeItem implements EnergyHolder, ItemDurabilit
if (Energy.of(stack).getEnergy() >= cost
&& (state.getMaterial() == Material.WOOD)) {
return this.poweredSpeed;
} else {
return super.getMiningSpeed(stack, state);
}
return super.getMiningSpeed(stack, state);
}
// ItemTool

View file

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

View file

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

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 435 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B