From 9910d0590de7f7ea9928b4f0569d9dc00a548c18 Mon Sep 17 00:00:00 2001 From: Reisse Date: Fri, 21 Dec 2018 21:26:13 +0300 Subject: [PATCH 1/9] Update build.gradle to 1.13.2 --- build.gradle | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index e447942..d92de14 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,13 @@ buildscript { - repositories { - jcenter() + repositories { + mavenCentral() + maven { url 'https://www.jitpack.io' } + maven { url 'https://files.minecraftforge.net/maven' } maven { url 'https://www.dimdev.org/maven/' } - } - dependencies { - classpath 'org.dimdev:ForgeGradle:2.3-SNAPSHOT' - } + } + dependencies { + classpath 'com.github.Chocohead:ForgeGradle:moderniser-SNAPSHOT' + } } apply plugin: 'net.minecraftforge.gradle.tweaker-client' @@ -20,16 +22,18 @@ targetCompatibility = 1.8 repositories { mavenCentral() + maven { url 'https://www.jitpack.io' } + maven { url 'http://repo.strezz.org/artifactory/list/Strezz-Central' } maven { url 'https://www.dimdev.org/maven/' } } dependencies { - implementation 'org.dimdev:rift:1.0.4-65:dev' + implementation 'com.github.Chocohead:Rift:jitpack-SNAPSHOT:dev' } minecraft { - version = '1.13' - mappings = 'snapshot_20180826' - runDir = 'run' - tweakClass = 'org.dimdev.riftloader.launch.RiftLoaderClientTweaker' + version = '1.13.2' + mappings = 'snapshot_20181130' + runDir = 'run' + tweakClass = 'org.dimdev.riftloader.launch.RiftLoaderClientTweaker' } From 06bbfd7668e7c7beacf8b6e27e82ec6670c4eed9 Mon Sep 17 00:00:00 2001 From: Reisse Date: Fri, 21 Dec 2018 21:27:29 +0300 Subject: [PATCH 2/9] Update code to 1.13.2 --- .../java/org/dimdev/halflogs/HalfLogs.java | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/dimdev/halflogs/HalfLogs.java b/src/main/java/org/dimdev/halflogs/HalfLogs.java index 0108abc..3ad7aaf 100644 --- a/src/main/java/org/dimdev/halflogs/HalfLogs.java +++ b/src/main/java/org/dimdev/halflogs/HalfLogs.java @@ -1,16 +1,25 @@ package org.dimdev.halflogs; +import java.util.function.Supplier; + +import org.dimdev.rift.listener.BlockAdder; +import org.dimdev.rift.listener.ItemAdder; + import net.minecraft.block.Block; import net.minecraft.block.BlockSlab; import net.minecraft.block.BlockStairs; import net.minecraft.block.SoundType; -import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; +import net.minecraft.block.material.MaterialColor; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.SoundEvents; -import net.minecraft.item.*; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.item.Item; +import net.minecraft.item.ItemAxe; +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemStack; import net.minecraft.state.EnumProperty; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.SlabType; @@ -20,10 +29,6 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import org.dimdev.rift.listener.BlockAdder; -import org.dimdev.rift.listener.ItemAdder; - -import java.util.function.Supplier; public class HalfLogs implements BlockAdder, ItemAdder { public static final EnumProperty AXIS = EnumProperty.create("axis", EnumFacing.Axis.class); @@ -31,7 +36,7 @@ public class HalfLogs implements BlockAdder, ItemAdder { private static Supplier LOG_STAIRS = () -> { Block block = Blocks.OAK_LOG; - return new BlockStairs(block.getDefaultState(), Block.Builder.create(Material.WOOD, MapColor.WOOD).hardnessAndResistance(2.0F, 3.0F).sound(SoundType.WOOD)) { + return new BlockStairs(block.getDefaultState(), Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2.0F, 3.0F).sound(SoundType.WOOD)) { @Override protected void fillStateContainer(StateContainer.Builder p_Builder) { super.fillStateContainer(p_Builder); @@ -42,7 +47,7 @@ protected void fillStateContainer(StateContainer.Builder p_Bu public IBlockState getStateForPlacement(BlockItemUseContext p_getBlockToPlaceOnUse_1_) { IBlockState iblockstate = super.getStateForPlacement(p_getBlockToPlaceOnUse_1_); - iblockstate = iblockstate.withProperty(AXIS, p_getBlockToPlaceOnUse_1_.getFace().getAxis()); + iblockstate = iblockstate.with(AXIS, p_getBlockToPlaceOnUse_1_.getFace().getAxis()); return iblockstate; } @@ -69,10 +74,10 @@ public boolean onBlockActivated(IBlockState p_blockState, World p_world, BlockPo } p_world.setBlockState(p_blockPos, strippedBlock.getDefaultState() - .withProperty(AXIS, p_blockState.getValue(AXIS)) - .withProperty(BlockStairs.FACING, p_blockState.getValue(BlockStairs.FACING)) - .withProperty(BlockStairs.HALF, p_blockState.getValue(BlockStairs.HALF)) - .withProperty(BlockStairs.SHAPE, p_blockState.getValue(BlockStairs.SHAPE))); + .with(AXIS, p_blockState.get(AXIS)) + .with(BlockStairs.FACING, p_blockState.get(BlockStairs.FACING)) + .with(BlockStairs.HALF, p_blockState.get(BlockStairs.HALF)) + .with(BlockStairs.SHAPE, p_blockState.get(BlockStairs.SHAPE))); p_world.playSound(p_player, p_blockPos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F); stack.damageItem(1, p_player); return true; @@ -84,7 +89,7 @@ public boolean onBlockActivated(IBlockState p_blockState, World p_world, BlockPo private static Supplier LOG_SLABS = () -> { - return new BlockSlab(Block.Builder.create(Material.WOOD, MapColor.WOOD).hardnessAndResistance(2.0F, 3.0F).sound(SoundType.WOOD)) { + return new BlockSlab(Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2.0F, 3.0F).sound(SoundType.WOOD)) { @Override protected void fillStateContainer(StateContainer.Builder p_Builder) { super.fillStateContainer(p_Builder); @@ -95,7 +100,7 @@ protected void fillStateContainer(StateContainer.Builder p_Bu public IBlockState getStateForPlacement(BlockItemUseContext p_getBlockToPlaceOnUse_1_) { IBlockState iblockstate = super.getStateForPlacement(p_getBlockToPlaceOnUse_1_); - iblockstate = iblockstate.withProperty(AXIS, p_getBlockToPlaceOnUse_1_.getFace().getAxis()); + iblockstate = iblockstate.with(AXIS, p_getBlockToPlaceOnUse_1_.getFace().getAxis()); return iblockstate; } @@ -121,10 +126,10 @@ public boolean onBlockActivated(IBlockState p_blockState, World p_world, BlockPo return false; } - SlabType slabType = p_blockState.getValue(BlockSlab.TYPE); + SlabType slabType = p_blockState.get(BlockSlab.TYPE); p_world.setBlockState(p_blockPos, strippedBlock.getDefaultState() - .withProperty(AXIS, p_blockState.getValue(AXIS)) - .withProperty(BlockSlab.TYPE, slabType)); + .with(AXIS, p_blockState.get(AXIS)) + .with(BlockSlab.TYPE, slabType)); p_world.playSound(p_player, p_blockPos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F); stack.damageItem(slabType == SlabType.DOUBLE ? (p_world.rand.nextBoolean() ? 2 : 1) : 1, p_player); //just because return true; From 6fe1d1d964e1d4fbdd1a0b1e9ac5761aa15ece7a Mon Sep 17 00:00:00 2001 From: Reisse Date: Fri, 21 Dec 2018 21:30:17 +0300 Subject: [PATCH 3/9] Turn Suppliers into static methods --- .../java/org/dimdev/halflogs/HalfLogs.java | 413 +++++++++--------- 1 file changed, 208 insertions(+), 205 deletions(-) diff --git a/src/main/java/org/dimdev/halflogs/HalfLogs.java b/src/main/java/org/dimdev/halflogs/HalfLogs.java index 3ad7aaf..34a3c7d 100644 --- a/src/main/java/org/dimdev/halflogs/HalfLogs.java +++ b/src/main/java/org/dimdev/halflogs/HalfLogs.java @@ -1,7 +1,5 @@ package org.dimdev.halflogs; -import java.util.function.Supplier; - import org.dimdev.rift.listener.BlockAdder; import org.dimdev.rift.listener.ItemAdder; @@ -31,207 +29,212 @@ import net.minecraft.world.World; public class HalfLogs implements BlockAdder, ItemAdder { - public static final EnumProperty AXIS = EnumProperty.create("axis", EnumFacing.Axis.class); - - private static Supplier LOG_STAIRS = () -> { - Block block = Blocks.OAK_LOG; - - return new BlockStairs(block.getDefaultState(), Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2.0F, 3.0F).sound(SoundType.WOOD)) { - @Override - protected void fillStateContainer(StateContainer.Builder p_Builder) { - super.fillStateContainer(p_Builder); - p_Builder.add(AXIS); - } - - @Override - public IBlockState getStateForPlacement(BlockItemUseContext p_getBlockToPlaceOnUse_1_) - { - IBlockState iblockstate = super.getStateForPlacement(p_getBlockToPlaceOnUse_1_); - iblockstate = iblockstate.with(AXIS, p_getBlockToPlaceOnUse_1_.getFace().getAxis()); - return iblockstate; - } - - @Override - public boolean onBlockActivated(IBlockState p_blockState, World p_world, BlockPos p_blockPos, EntityPlayer p_player, EnumHand p_hand, EnumFacing p_facing, float hitX, float hitY, float hitZ) { - ItemStack stack = p_hand == EnumHand.MAIN_HAND ? p_player.getHeldItemMainhand() : p_player.getHeldItemOffhand(); - Item item = stack.getItem(); - if (item instanceof ItemAxe) { - Block strippedBlock; - if (this == OAK_LOG_STAIRS) { - strippedBlock = STRIPPED_OAK_LOG_STAIRS; - } else if (this == SPRUCE_LOG_STAIRS) { - strippedBlock = STRIPPED_SPRUCE_LOG_STAIRS; - } else if (this == BIRCH_LOG_STAIRS) { - strippedBlock = STRIPPED_BIRCH_LOG_STAIRS; - } else if (this == JUNGLE_LOG_STAIRS) { - strippedBlock = STRIPPED_JUNGLE_LOG_STAIRS; - } else if (this == ACACIA_LOG_STAIRS) { - strippedBlock = STRIPPED_ACACIA_LOG_STAIRS; - } else if (this == DARK_OAK_LOG_STAIRS) { - strippedBlock = STRIPPED_DARK_OAK_LOG_STAIRS; - } else { - return false; - } - - p_world.setBlockState(p_blockPos, strippedBlock.getDefaultState() - .with(AXIS, p_blockState.get(AXIS)) - .with(BlockStairs.FACING, p_blockState.get(BlockStairs.FACING)) - .with(BlockStairs.HALF, p_blockState.get(BlockStairs.HALF)) - .with(BlockStairs.SHAPE, p_blockState.get(BlockStairs.SHAPE))); - p_world.playSound(p_player, p_blockPos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F); - stack.damageItem(1, p_player); - return true; - } - return false; - } - }; - }; - - private static Supplier LOG_SLABS = () -> { - - return new BlockSlab(Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2.0F, 3.0F).sound(SoundType.WOOD)) { - @Override - protected void fillStateContainer(StateContainer.Builder p_Builder) { - super.fillStateContainer(p_Builder); - p_Builder.add(AXIS); - } - - @Override - public IBlockState getStateForPlacement(BlockItemUseContext p_getBlockToPlaceOnUse_1_) - { - IBlockState iblockstate = super.getStateForPlacement(p_getBlockToPlaceOnUse_1_); - iblockstate = iblockstate.with(AXIS, p_getBlockToPlaceOnUse_1_.getFace().getAxis()); - return iblockstate; - } - - @Override - public boolean onBlockActivated(IBlockState p_blockState, World p_world, BlockPos p_blockPos, EntityPlayer p_player, EnumHand p_hand, EnumFacing p_facing, float hitX, float hitY, float hitZ) { - ItemStack stack = p_hand == EnumHand.MAIN_HAND ? p_player.getHeldItemMainhand() : p_player.getHeldItemOffhand(); - Item item = stack.getItem(); - if (item instanceof ItemAxe) { - Block strippedBlock; - if (this == OAK_LOG_SLAB) { - strippedBlock = STRIPPED_OAK_LOG_SLAB; - } else if (this == SPRUCE_LOG_SLAB) { - strippedBlock = STRIPPED_SPRUCE_LOG_SLAB; - } else if (this == BIRCH_LOG_SLAB) { - strippedBlock = STRIPPED_BIRCH_LOG_SLAB; - } else if (this == JUNGLE_LOG_SLAB) { - strippedBlock = STRIPPED_JUNGLE_LOG_SLAB; - } else if (this == ACACIA_LOG_SLAB) { - strippedBlock = STRIPPED_ACACIA_LOG_SLAB; - } else if (this == DARK_OAK_LOG_SLAB) { - strippedBlock = STRIPPED_DARK_OAK_LOG_SLAB; - } else { - return false; - } - - SlabType slabType = p_blockState.get(BlockSlab.TYPE); - p_world.setBlockState(p_blockPos, strippedBlock.getDefaultState() - .with(AXIS, p_blockState.get(AXIS)) - .with(BlockSlab.TYPE, slabType)); - p_world.playSound(p_player, p_blockPos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F); - stack.damageItem(slabType == SlabType.DOUBLE ? (p_world.rand.nextBoolean() ? 2 : 1) : 1, p_player); //just because - return true; - } - return false; - } - }; - }; - - //Slabs - public final static Block OAK_LOG_SLAB = LOG_SLABS.get(); - public final static Block SPRUCE_LOG_SLAB = LOG_SLABS.get(); - public final static Block BIRCH_LOG_SLAB = LOG_SLABS.get(); - public final static Block JUNGLE_LOG_SLAB = LOG_SLABS.get(); - public final static Block ACACIA_LOG_SLAB = LOG_SLABS.get(); - public final static Block DARK_OAK_LOG_SLAB = LOG_SLABS.get(); - //Stripped - public final static Block STRIPPED_OAK_LOG_SLAB = LOG_SLABS.get(); - public final static Block STRIPPED_SPRUCE_LOG_SLAB = LOG_SLABS.get(); - public final static Block STRIPPED_BIRCH_LOG_SLAB = LOG_SLABS.get(); - public final static Block STRIPPED_JUNGLE_LOG_SLAB = LOG_SLABS.get(); - public final static Block STRIPPED_ACACIA_LOG_SLAB = LOG_SLABS.get(); - public final static Block STRIPPED_DARK_OAK_LOG_SLAB = LOG_SLABS.get(); - - //Stairs - public final static Block OAK_LOG_STAIRS = LOG_STAIRS.get(); - public final static Block SPRUCE_LOG_STAIRS = LOG_STAIRS.get(); - public final static Block BIRCH_LOG_STAIRS = LOG_STAIRS.get(); - public final static Block JUNGLE_LOG_STAIRS = LOG_STAIRS.get(); - public final static Block ACACIA_LOG_STAIRS = LOG_STAIRS.get(); - public final static Block DARK_OAK_LOG_STAIRS = LOG_STAIRS.get(); - //Stripped - public final static Block STRIPPED_OAK_LOG_STAIRS = LOG_STAIRS.get(); - public final static Block STRIPPED_SPRUCE_LOG_STAIRS = LOG_STAIRS.get(); - public final static Block STRIPPED_BIRCH_LOG_STAIRS = LOG_STAIRS.get(); - public final static Block STRIPPED_JUNGLE_LOG_STAIRS = LOG_STAIRS.get(); - public final static Block STRIPPED_ACACIA_LOG_STAIRS = LOG_STAIRS.get(); - public final static Block STRIPPED_DARK_OAK_LOG_STAIRS = LOG_STAIRS.get(); - - @Override - public void registerBlocks() { - //Slabs - Block.register(new ResourceLocation("halflogs:oak_log_slab"), OAK_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:spruce_log_slab"), SPRUCE_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:birch_log_slab"), BIRCH_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:jungle_log_slab"), JUNGLE_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:acacia_log_slab"), ACACIA_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:dark_oak_log_slab"), DARK_OAK_LOG_SLAB); - //Stripped - Block.register(new ResourceLocation("halflogs:stripped_oak_log_slab"), STRIPPED_OAK_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:stripped_spruce_log_slab"), STRIPPED_SPRUCE_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:stripped_birch_log_slab"), STRIPPED_BIRCH_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:stripped_jungle_log_slab"), STRIPPED_JUNGLE_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:stripped_acacia_log_slab"), STRIPPED_ACACIA_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:stripped_dark_oak_log_slab"), STRIPPED_DARK_OAK_LOG_SLAB); - - //Stairs - Block.register(new ResourceLocation("halflogs:oak_log_stairs"), OAK_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:spruce_log_stairs"), SPRUCE_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:birch_log_stairs"), BIRCH_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:jungle_log_stairs"), JUNGLE_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:acacia_log_stairs"), ACACIA_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:dark_oak_log_stairs"), DARK_OAK_LOG_STAIRS); - //Stripped - Block.register(new ResourceLocation("halflogs:stripped_oak_log_stairs"), STRIPPED_OAK_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:stripped_spruce_log_stairs"), STRIPPED_SPRUCE_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:stripped_birch_log_stairs"), STRIPPED_BIRCH_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:stripped_jungle_log_stairs"), STRIPPED_JUNGLE_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:stripped_acacia_log_stairs"), STRIPPED_ACACIA_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:stripped_dark_oak_log_stairs"), STRIPPED_DARK_OAK_LOG_STAIRS); - } - - @Override - public void registerItems() { - //Slabs - Item.register(OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(SPRUCE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(BIRCH_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(JUNGLE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(ACACIA_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(DARK_OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - //Stripped - Item.register(STRIPPED_OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_SPRUCE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_BIRCH_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_JUNGLE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_ACACIA_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_DARK_OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - - //Stairs - Item.register(OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(SPRUCE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(BIRCH_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(JUNGLE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(ACACIA_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(DARK_OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - //Stripped - Item.register(STRIPPED_OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_SPRUCE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_BIRCH_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_JUNGLE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_ACACIA_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_DARK_OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - } + public static final EnumProperty AXIS = EnumProperty.create("axis", EnumFacing.Axis.class); + + private static BlockStairs createLogStairs() { + Block block = Blocks.OAK_LOG; + + return new BlockStairs(block.getDefaultState(), Block.Properties.create(Material.WOOD, MaterialColor.WOOD) + .hardnessAndResistance(2.0F, 3.0F).sound(SoundType.WOOD)) { + @Override + protected void fillStateContainer(StateContainer.Builder p_Builder) { + super.fillStateContainer(p_Builder); + p_Builder.add(AXIS); + } + + @Override + public IBlockState getStateForPlacement(BlockItemUseContext p_getBlockToPlaceOnUse_1_) { + IBlockState iblockstate = super.getStateForPlacement(p_getBlockToPlaceOnUse_1_); + iblockstate = iblockstate.with(AXIS, p_getBlockToPlaceOnUse_1_.getFace().getAxis()); + return iblockstate; + } + + @Override + public boolean onBlockActivated(IBlockState p_blockState, World p_world, BlockPos p_blockPos, + EntityPlayer p_player, EnumHand p_hand, EnumFacing p_facing, float hitX, float hitY, float hitZ) { + ItemStack stack = p_hand == EnumHand.MAIN_HAND ? p_player.getHeldItemMainhand() + : p_player.getHeldItemOffhand(); + Item item = stack.getItem(); + if (item instanceof ItemAxe) { + Block strippedBlock; + if (this == OAK_LOG_STAIRS) { + strippedBlock = STRIPPED_OAK_LOG_STAIRS; + } else if (this == SPRUCE_LOG_STAIRS) { + strippedBlock = STRIPPED_SPRUCE_LOG_STAIRS; + } else if (this == BIRCH_LOG_STAIRS) { + strippedBlock = STRIPPED_BIRCH_LOG_STAIRS; + } else if (this == JUNGLE_LOG_STAIRS) { + strippedBlock = STRIPPED_JUNGLE_LOG_STAIRS; + } else if (this == ACACIA_LOG_STAIRS) { + strippedBlock = STRIPPED_ACACIA_LOG_STAIRS; + } else if (this == DARK_OAK_LOG_STAIRS) { + strippedBlock = STRIPPED_DARK_OAK_LOG_STAIRS; + } else { + return false; + } + + p_world.setBlockState(p_blockPos, + strippedBlock.getDefaultState().with(AXIS, p_blockState.get(AXIS)) + .with(BlockStairs.FACING, p_blockState.get(BlockStairs.FACING)) + .with(BlockStairs.HALF, p_blockState.get(BlockStairs.HALF)) + .with(BlockStairs.SHAPE, p_blockState.get(BlockStairs.SHAPE))); + p_world.playSound(p_player, p_blockPos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, + 1.0F); + stack.damageItem(1, p_player); + return true; + } + return false; + } + }; + } + + private static BlockSlab createLogSlab() { + return new BlockSlab(Block.Properties.create(Material.WOOD, MaterialColor.WOOD) + .hardnessAndResistance(2.0F, 3.0F).sound(SoundType.WOOD)) { + @Override + protected void fillStateContainer(StateContainer.Builder p_Builder) { + super.fillStateContainer(p_Builder); + p_Builder.add(AXIS); + } + + @Override + public IBlockState getStateForPlacement(BlockItemUseContext p_getBlockToPlaceOnUse_1_) { + IBlockState iblockstate = super.getStateForPlacement(p_getBlockToPlaceOnUse_1_); + iblockstate = iblockstate.with(AXIS, p_getBlockToPlaceOnUse_1_.getFace().getAxis()); + return iblockstate; + } + + @Override + public boolean onBlockActivated(IBlockState p_blockState, World p_world, BlockPos p_blockPos, + EntityPlayer p_player, EnumHand p_hand, EnumFacing p_facing, float hitX, float hitY, float hitZ) { + ItemStack stack = p_hand == EnumHand.MAIN_HAND ? p_player.getHeldItemMainhand() + : p_player.getHeldItemOffhand(); + Item item = stack.getItem(); + if (item instanceof ItemAxe) { + Block strippedBlock; + if (this == OAK_LOG_SLAB) { + strippedBlock = STRIPPED_OAK_LOG_SLAB; + } else if (this == SPRUCE_LOG_SLAB) { + strippedBlock = STRIPPED_SPRUCE_LOG_SLAB; + } else if (this == BIRCH_LOG_SLAB) { + strippedBlock = STRIPPED_BIRCH_LOG_SLAB; + } else if (this == JUNGLE_LOG_SLAB) { + strippedBlock = STRIPPED_JUNGLE_LOG_SLAB; + } else if (this == ACACIA_LOG_SLAB) { + strippedBlock = STRIPPED_ACACIA_LOG_SLAB; + } else if (this == DARK_OAK_LOG_SLAB) { + strippedBlock = STRIPPED_DARK_OAK_LOG_SLAB; + } else { + return false; + } + + SlabType slabType = p_blockState.get(BlockSlab.TYPE); + p_world.setBlockState(p_blockPos, strippedBlock.getDefaultState().with(AXIS, p_blockState.get(AXIS)) + .with(BlockSlab.TYPE, slabType)); + p_world.playSound(p_player, p_blockPos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, + 1.0F); + stack.damageItem(slabType == SlabType.DOUBLE ? (p_world.rand.nextBoolean() ? 2 : 1) : 1, p_player); // just + // because + return true; + } + return false; + } + }; + } + + // Slabs + public final static Block OAK_LOG_SLAB = createLogSlab(); + public final static Block SPRUCE_LOG_SLAB = createLogSlab(); + public final static Block BIRCH_LOG_SLAB = createLogSlab(); + public final static Block JUNGLE_LOG_SLAB = createLogSlab(); + public final static Block ACACIA_LOG_SLAB = createLogSlab(); + public final static Block DARK_OAK_LOG_SLAB = createLogSlab(); + // Stripped + public final static Block STRIPPED_OAK_LOG_SLAB = createLogSlab(); + public final static Block STRIPPED_SPRUCE_LOG_SLAB = createLogSlab(); + public final static Block STRIPPED_BIRCH_LOG_SLAB = createLogSlab(); + public final static Block STRIPPED_JUNGLE_LOG_SLAB = createLogSlab(); + public final static Block STRIPPED_ACACIA_LOG_SLAB = createLogSlab(); + public final static Block STRIPPED_DARK_OAK_LOG_SLAB = createLogSlab(); + + // Stairs + public final static Block OAK_LOG_STAIRS = createLogStairs(); + public final static Block SPRUCE_LOG_STAIRS = createLogStairs(); + public final static Block BIRCH_LOG_STAIRS = createLogStairs(); + public final static Block JUNGLE_LOG_STAIRS = createLogStairs(); + public final static Block ACACIA_LOG_STAIRS = createLogStairs(); + public final static Block DARK_OAK_LOG_STAIRS = createLogStairs(); + // Stripped + public final static Block STRIPPED_OAK_LOG_STAIRS = createLogStairs(); + public final static Block STRIPPED_SPRUCE_LOG_STAIRS = createLogStairs(); + public final static Block STRIPPED_BIRCH_LOG_STAIRS = createLogStairs(); + public final static Block STRIPPED_JUNGLE_LOG_STAIRS = createLogStairs(); + public final static Block STRIPPED_ACACIA_LOG_STAIRS = createLogStairs(); + public final static Block STRIPPED_DARK_OAK_LOG_STAIRS = createLogStairs(); + + @Override + public void registerBlocks() { + // Slabs + Block.register(new ResourceLocation("halflogs:oak_log_slab"), OAK_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:spruce_log_slab"), SPRUCE_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:birch_log_slab"), BIRCH_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:jungle_log_slab"), JUNGLE_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:acacia_log_slab"), ACACIA_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:dark_oak_log_slab"), DARK_OAK_LOG_SLAB); + // Stripped + Block.register(new ResourceLocation("halflogs:stripped_oak_log_slab"), STRIPPED_OAK_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:stripped_spruce_log_slab"), STRIPPED_SPRUCE_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:stripped_birch_log_slab"), STRIPPED_BIRCH_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:stripped_jungle_log_slab"), STRIPPED_JUNGLE_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:stripped_acacia_log_slab"), STRIPPED_ACACIA_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:stripped_dark_oak_log_slab"), STRIPPED_DARK_OAK_LOG_SLAB); + + // Stairs + Block.register(new ResourceLocation("halflogs:oak_log_stairs"), OAK_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:spruce_log_stairs"), SPRUCE_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:birch_log_stairs"), BIRCH_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:jungle_log_stairs"), JUNGLE_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:acacia_log_stairs"), ACACIA_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:dark_oak_log_stairs"), DARK_OAK_LOG_STAIRS); + // Stripped + Block.register(new ResourceLocation("halflogs:stripped_oak_log_stairs"), STRIPPED_OAK_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:stripped_spruce_log_stairs"), STRIPPED_SPRUCE_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:stripped_birch_log_stairs"), STRIPPED_BIRCH_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:stripped_jungle_log_stairs"), STRIPPED_JUNGLE_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:stripped_acacia_log_stairs"), STRIPPED_ACACIA_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:stripped_dark_oak_log_stairs"), STRIPPED_DARK_OAK_LOG_STAIRS); + } + + @Override + public void registerItems() { + // Slabs + Item.register(OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(SPRUCE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(BIRCH_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(JUNGLE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(ACACIA_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(DARK_OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + // Stripped + Item.register(STRIPPED_OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_SPRUCE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_BIRCH_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_JUNGLE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_ACACIA_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_DARK_OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + + // Stairs + Item.register(OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(SPRUCE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(BIRCH_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(JUNGLE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(ACACIA_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(DARK_OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + // Stripped + Item.register(STRIPPED_OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_SPRUCE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_BIRCH_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_JUNGLE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_ACACIA_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_DARK_OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + } } From 742f5b9d0da3acba138dda24965c74d2bfd69b06 Mon Sep 17 00:00:00 2001 From: Reisse Date: Fri, 21 Dec 2018 21:40:47 +0300 Subject: [PATCH 4/9] Deobfuscate parameter and refactor --- .../java/org/dimdev/halflogs/HalfLogs.java | 125 +++++++++--------- 1 file changed, 59 insertions(+), 66 deletions(-) diff --git a/src/main/java/org/dimdev/halflogs/HalfLogs.java b/src/main/java/org/dimdev/halflogs/HalfLogs.java index 34a3c7d..2094ae1 100644 --- a/src/main/java/org/dimdev/halflogs/HalfLogs.java +++ b/src/main/java/org/dimdev/halflogs/HalfLogs.java @@ -31,29 +31,25 @@ public class HalfLogs implements BlockAdder, ItemAdder { public static final EnumProperty AXIS = EnumProperty.create("axis", EnumFacing.Axis.class); - private static BlockStairs createLogStairs() { - Block block = Blocks.OAK_LOG; - - return new BlockStairs(block.getDefaultState(), Block.Properties.create(Material.WOOD, MaterialColor.WOOD) - .hardnessAndResistance(2.0F, 3.0F).sound(SoundType.WOOD)) { + private static BlockStairs createLogStairs(Block log) { + return new BlockStairs(log.getDefaultState(), Block.Properties.from(log)) { @Override - protected void fillStateContainer(StateContainer.Builder p_Builder) { - super.fillStateContainer(p_Builder); - p_Builder.add(AXIS); + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(AXIS); } @Override - public IBlockState getStateForPlacement(BlockItemUseContext p_getBlockToPlaceOnUse_1_) { - IBlockState iblockstate = super.getStateForPlacement(p_getBlockToPlaceOnUse_1_); - iblockstate = iblockstate.with(AXIS, p_getBlockToPlaceOnUse_1_.getFace().getAxis()); - return iblockstate; + public IBlockState getStateForPlacement(BlockItemUseContext context) { + IBlockState state = super.getStateForPlacement(context); + state = state.with(AXIS, context.getFace().getAxis()); + return state; } @Override - public boolean onBlockActivated(IBlockState p_blockState, World p_world, BlockPos p_blockPos, - EntityPlayer p_player, EnumHand p_hand, EnumFacing p_facing, float hitX, float hitY, float hitZ) { - ItemStack stack = p_hand == EnumHand.MAIN_HAND ? p_player.getHeldItemMainhand() - : p_player.getHeldItemOffhand(); + public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, EntityPlayer player, + EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + ItemStack stack = player.getHeldItem(hand); Item item = stack.getItem(); if (item instanceof ItemAxe) { Block strippedBlock; @@ -73,14 +69,13 @@ public boolean onBlockActivated(IBlockState p_blockState, World p_world, BlockPo return false; } - p_world.setBlockState(p_blockPos, - strippedBlock.getDefaultState().with(AXIS, p_blockState.get(AXIS)) - .with(BlockStairs.FACING, p_blockState.get(BlockStairs.FACING)) - .with(BlockStairs.HALF, p_blockState.get(BlockStairs.HALF)) - .with(BlockStairs.SHAPE, p_blockState.get(BlockStairs.SHAPE))); - p_world.playSound(p_player, p_blockPos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, - 1.0F); - stack.damageItem(1, p_player); + world.setBlockState(pos, + strippedBlock.getDefaultState().with(AXIS, state.get(AXIS)) + .with(BlockStairs.FACING, state.get(BlockStairs.FACING)) + .with(BlockStairs.HALF, state.get(BlockStairs.HALF)) + .with(BlockStairs.SHAPE, state.get(BlockStairs.SHAPE))); + world.playSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F); + stack.damageItem(1, player); return true; } return false; @@ -88,27 +83,25 @@ public boolean onBlockActivated(IBlockState p_blockState, World p_world, BlockPo }; } - private static BlockSlab createLogSlab() { - return new BlockSlab(Block.Properties.create(Material.WOOD, MaterialColor.WOOD) - .hardnessAndResistance(2.0F, 3.0F).sound(SoundType.WOOD)) { + private static BlockSlab createLogSlab(Block block) { + return new BlockSlab(Block.Properties.from(block)) { @Override - protected void fillStateContainer(StateContainer.Builder p_Builder) { - super.fillStateContainer(p_Builder); - p_Builder.add(AXIS); + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(AXIS); } @Override - public IBlockState getStateForPlacement(BlockItemUseContext p_getBlockToPlaceOnUse_1_) { - IBlockState iblockstate = super.getStateForPlacement(p_getBlockToPlaceOnUse_1_); - iblockstate = iblockstate.with(AXIS, p_getBlockToPlaceOnUse_1_.getFace().getAxis()); - return iblockstate; + public IBlockState getStateForPlacement(BlockItemUseContext context) { + IBlockState state = super.getStateForPlacement(context); + state = state.with(AXIS, context.getFace().getAxis()); + return state; } @Override - public boolean onBlockActivated(IBlockState p_blockState, World p_world, BlockPos p_blockPos, - EntityPlayer p_player, EnumHand p_hand, EnumFacing p_facing, float hitX, float hitY, float hitZ) { - ItemStack stack = p_hand == EnumHand.MAIN_HAND ? p_player.getHeldItemMainhand() - : p_player.getHeldItemOffhand(); + public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, + EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + ItemStack stack = player.getHeldItem(hand); Item item = stack.getItem(); if (item instanceof ItemAxe) { Block strippedBlock; @@ -128,12 +121,12 @@ public boolean onBlockActivated(IBlockState p_blockState, World p_world, BlockPo return false; } - SlabType slabType = p_blockState.get(BlockSlab.TYPE); - p_world.setBlockState(p_blockPos, strippedBlock.getDefaultState().with(AXIS, p_blockState.get(AXIS)) + SlabType slabType = state.get(BlockSlab.TYPE); + world.setBlockState(pos, strippedBlock.getDefaultState().with(AXIS, state.get(AXIS)) .with(BlockSlab.TYPE, slabType)); - p_world.playSound(p_player, p_blockPos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, + world.playSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F); - stack.damageItem(slabType == SlabType.DOUBLE ? (p_world.rand.nextBoolean() ? 2 : 1) : 1, p_player); // just + stack.damageItem(slabType == SlabType.DOUBLE ? (world.rand.nextBoolean() ? 2 : 1) : 1, player); // just // because return true; } @@ -143,34 +136,34 @@ public boolean onBlockActivated(IBlockState p_blockState, World p_world, BlockPo } // Slabs - public final static Block OAK_LOG_SLAB = createLogSlab(); - public final static Block SPRUCE_LOG_SLAB = createLogSlab(); - public final static Block BIRCH_LOG_SLAB = createLogSlab(); - public final static Block JUNGLE_LOG_SLAB = createLogSlab(); - public final static Block ACACIA_LOG_SLAB = createLogSlab(); - public final static Block DARK_OAK_LOG_SLAB = createLogSlab(); + public final static Block OAK_LOG_SLAB = createLogSlab(Blocks.OAK_LOG); + public final static Block SPRUCE_LOG_SLAB = createLogSlab(Blocks.SPRUCE_LOG); + public final static Block BIRCH_LOG_SLAB = createLogSlab(Blocks.BIRCH_LOG); + public final static Block JUNGLE_LOG_SLAB = createLogSlab(Blocks.JUNGLE_LOG); + public final static Block ACACIA_LOG_SLAB = createLogSlab(Blocks.ACACIA_LOG); + public final static Block DARK_OAK_LOG_SLAB = createLogSlab(Blocks.DARK_OAK_LOG); // Stripped - public final static Block STRIPPED_OAK_LOG_SLAB = createLogSlab(); - public final static Block STRIPPED_SPRUCE_LOG_SLAB = createLogSlab(); - public final static Block STRIPPED_BIRCH_LOG_SLAB = createLogSlab(); - public final static Block STRIPPED_JUNGLE_LOG_SLAB = createLogSlab(); - public final static Block STRIPPED_ACACIA_LOG_SLAB = createLogSlab(); - public final static Block STRIPPED_DARK_OAK_LOG_SLAB = createLogSlab(); + public final static Block STRIPPED_OAK_LOG_SLAB = createLogSlab(Blocks.STRIPPED_OAK_LOG); + public final static Block STRIPPED_SPRUCE_LOG_SLAB = createLogSlab(Blocks.STRIPPED_SPRUCE_LOG); + public final static Block STRIPPED_BIRCH_LOG_SLAB = createLogSlab(Blocks.STRIPPED_BIRCH_LOG); + public final static Block STRIPPED_JUNGLE_LOG_SLAB = createLogSlab(Blocks.STRIPPED_JUNGLE_LOG); + public final static Block STRIPPED_ACACIA_LOG_SLAB = createLogSlab(Blocks.STRIPPED_ACACIA_LOG); + public final static Block STRIPPED_DARK_OAK_LOG_SLAB = createLogSlab(Blocks.STRIPPED_DARK_OAK_LOG); // Stairs - public final static Block OAK_LOG_STAIRS = createLogStairs(); - public final static Block SPRUCE_LOG_STAIRS = createLogStairs(); - public final static Block BIRCH_LOG_STAIRS = createLogStairs(); - public final static Block JUNGLE_LOG_STAIRS = createLogStairs(); - public final static Block ACACIA_LOG_STAIRS = createLogStairs(); - public final static Block DARK_OAK_LOG_STAIRS = createLogStairs(); + public final static Block OAK_LOG_STAIRS = createLogStairs(Blocks.OAK_LOG); + public final static Block SPRUCE_LOG_STAIRS = createLogStairs(Blocks.SPRUCE_LOG); + public final static Block BIRCH_LOG_STAIRS = createLogStairs(Blocks.BIRCH_LOG); + public final static Block JUNGLE_LOG_STAIRS = createLogStairs(Blocks.JUNGLE_LOG); + public final static Block ACACIA_LOG_STAIRS = createLogStairs(Blocks.ACACIA_LOG); + public final static Block DARK_OAK_LOG_STAIRS = createLogStairs(Blocks.DARK_OAK_LOG); // Stripped - public final static Block STRIPPED_OAK_LOG_STAIRS = createLogStairs(); - public final static Block STRIPPED_SPRUCE_LOG_STAIRS = createLogStairs(); - public final static Block STRIPPED_BIRCH_LOG_STAIRS = createLogStairs(); - public final static Block STRIPPED_JUNGLE_LOG_STAIRS = createLogStairs(); - public final static Block STRIPPED_ACACIA_LOG_STAIRS = createLogStairs(); - public final static Block STRIPPED_DARK_OAK_LOG_STAIRS = createLogStairs(); + public final static Block STRIPPED_OAK_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_OAK_LOG); + public final static Block STRIPPED_SPRUCE_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_SPRUCE_LOG); + public final static Block STRIPPED_BIRCH_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_BIRCH_LOG); + public final static Block STRIPPED_JUNGLE_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_JUNGLE_LOG); + public final static Block STRIPPED_ACACIA_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_ACACIA_LOG); + public final static Block STRIPPED_DARK_OAK_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_DARK_OAK_LOG); @Override public void registerBlocks() { From 18c5c0d34d1ff90548f3a6a457c9fd66f5e3800d Mon Sep 17 00:00:00 2001 From: Reisse Date: Fri, 21 Dec 2018 21:43:00 +0300 Subject: [PATCH 5/9] Remove comments and unused imports --- .../java/org/dimdev/halflogs/HalfLogs.java | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/dimdev/halflogs/HalfLogs.java b/src/main/java/org/dimdev/halflogs/HalfLogs.java index 2094ae1..1287b0e 100644 --- a/src/main/java/org/dimdev/halflogs/HalfLogs.java +++ b/src/main/java/org/dimdev/halflogs/HalfLogs.java @@ -6,9 +6,6 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockSlab; import net.minecraft.block.BlockStairs; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.material.MaterialColor; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -135,14 +132,14 @@ public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, }; } - // Slabs + public final static Block OAK_LOG_SLAB = createLogSlab(Blocks.OAK_LOG); public final static Block SPRUCE_LOG_SLAB = createLogSlab(Blocks.SPRUCE_LOG); public final static Block BIRCH_LOG_SLAB = createLogSlab(Blocks.BIRCH_LOG); public final static Block JUNGLE_LOG_SLAB = createLogSlab(Blocks.JUNGLE_LOG); public final static Block ACACIA_LOG_SLAB = createLogSlab(Blocks.ACACIA_LOG); public final static Block DARK_OAK_LOG_SLAB = createLogSlab(Blocks.DARK_OAK_LOG); - // Stripped + public final static Block STRIPPED_OAK_LOG_SLAB = createLogSlab(Blocks.STRIPPED_OAK_LOG); public final static Block STRIPPED_SPRUCE_LOG_SLAB = createLogSlab(Blocks.STRIPPED_SPRUCE_LOG); public final static Block STRIPPED_BIRCH_LOG_SLAB = createLogSlab(Blocks.STRIPPED_BIRCH_LOG); @@ -150,14 +147,13 @@ public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, public final static Block STRIPPED_ACACIA_LOG_SLAB = createLogSlab(Blocks.STRIPPED_ACACIA_LOG); public final static Block STRIPPED_DARK_OAK_LOG_SLAB = createLogSlab(Blocks.STRIPPED_DARK_OAK_LOG); - // Stairs public final static Block OAK_LOG_STAIRS = createLogStairs(Blocks.OAK_LOG); public final static Block SPRUCE_LOG_STAIRS = createLogStairs(Blocks.SPRUCE_LOG); public final static Block BIRCH_LOG_STAIRS = createLogStairs(Blocks.BIRCH_LOG); public final static Block JUNGLE_LOG_STAIRS = createLogStairs(Blocks.JUNGLE_LOG); public final static Block ACACIA_LOG_STAIRS = createLogStairs(Blocks.ACACIA_LOG); public final static Block DARK_OAK_LOG_STAIRS = createLogStairs(Blocks.DARK_OAK_LOG); - // Stripped + public final static Block STRIPPED_OAK_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_OAK_LOG); public final static Block STRIPPED_SPRUCE_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_SPRUCE_LOG); public final static Block STRIPPED_BIRCH_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_BIRCH_LOG); @@ -167,14 +163,13 @@ public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, @Override public void registerBlocks() { - // Slabs Block.register(new ResourceLocation("halflogs:oak_log_slab"), OAK_LOG_SLAB); Block.register(new ResourceLocation("halflogs:spruce_log_slab"), SPRUCE_LOG_SLAB); Block.register(new ResourceLocation("halflogs:birch_log_slab"), BIRCH_LOG_SLAB); Block.register(new ResourceLocation("halflogs:jungle_log_slab"), JUNGLE_LOG_SLAB); Block.register(new ResourceLocation("halflogs:acacia_log_slab"), ACACIA_LOG_SLAB); Block.register(new ResourceLocation("halflogs:dark_oak_log_slab"), DARK_OAK_LOG_SLAB); - // Stripped + Block.register(new ResourceLocation("halflogs:stripped_oak_log_slab"), STRIPPED_OAK_LOG_SLAB); Block.register(new ResourceLocation("halflogs:stripped_spruce_log_slab"), STRIPPED_SPRUCE_LOG_SLAB); Block.register(new ResourceLocation("halflogs:stripped_birch_log_slab"), STRIPPED_BIRCH_LOG_SLAB); @@ -182,14 +177,13 @@ public void registerBlocks() { Block.register(new ResourceLocation("halflogs:stripped_acacia_log_slab"), STRIPPED_ACACIA_LOG_SLAB); Block.register(new ResourceLocation("halflogs:stripped_dark_oak_log_slab"), STRIPPED_DARK_OAK_LOG_SLAB); - // Stairs Block.register(new ResourceLocation("halflogs:oak_log_stairs"), OAK_LOG_STAIRS); Block.register(new ResourceLocation("halflogs:spruce_log_stairs"), SPRUCE_LOG_STAIRS); Block.register(new ResourceLocation("halflogs:birch_log_stairs"), BIRCH_LOG_STAIRS); Block.register(new ResourceLocation("halflogs:jungle_log_stairs"), JUNGLE_LOG_STAIRS); Block.register(new ResourceLocation("halflogs:acacia_log_stairs"), ACACIA_LOG_STAIRS); Block.register(new ResourceLocation("halflogs:dark_oak_log_stairs"), DARK_OAK_LOG_STAIRS); - // Stripped + Block.register(new ResourceLocation("halflogs:stripped_oak_log_stairs"), STRIPPED_OAK_LOG_STAIRS); Block.register(new ResourceLocation("halflogs:stripped_spruce_log_stairs"), STRIPPED_SPRUCE_LOG_STAIRS); Block.register(new ResourceLocation("halflogs:stripped_birch_log_stairs"), STRIPPED_BIRCH_LOG_STAIRS); @@ -200,14 +194,13 @@ public void registerBlocks() { @Override public void registerItems() { - // Slabs Item.register(OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); Item.register(SPRUCE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); Item.register(BIRCH_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); Item.register(JUNGLE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); Item.register(ACACIA_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); Item.register(DARK_OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - // Stripped + Item.register(STRIPPED_OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); Item.register(STRIPPED_SPRUCE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); Item.register(STRIPPED_BIRCH_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); @@ -215,14 +208,13 @@ public void registerItems() { Item.register(STRIPPED_ACACIA_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); Item.register(STRIPPED_DARK_OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - // Stairs Item.register(OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); Item.register(SPRUCE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); Item.register(BIRCH_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); Item.register(JUNGLE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); Item.register(ACACIA_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); Item.register(DARK_OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - // Stripped + Item.register(STRIPPED_OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); Item.register(STRIPPED_SPRUCE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); Item.register(STRIPPED_BIRCH_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); From 68bd02596ede4b3628d67dff92f38b1f3706e374 Mon Sep 17 00:00:00 2001 From: Reisse Date: Fri, 21 Dec 2018 21:50:04 +0300 Subject: [PATCH 6/9] Add russian localization --- .../resources/assets/halflogs/lang/ru_ru.json | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/resources/assets/halflogs/lang/ru_ru.json diff --git a/src/main/resources/assets/halflogs/lang/ru_ru.json b/src/main/resources/assets/halflogs/lang/ru_ru.json new file mode 100644 index 0000000..7aa19c7 --- /dev/null +++ b/src/main/resources/assets/halflogs/lang/ru_ru.json @@ -0,0 +1,29 @@ +{ + "block.halflogs.oak_log_slab": "Цельная дубовая плита", + "block.halflogs.spruce_log_slab": "Цельная еловая плита", + "block.halflogs.birch_log_slab": "Цельная берёзовая плита", + "block.halflogs.jungle_log_slab": "Цельная джунглевая плита", + "block.halflogs.acacia_log_slab": "Цельная акациевая плита", + "block.halflogs.dark_oak_log_slab": "Цельная плита из тёмного дуба", + + "block.halflogs.stripped_oak_log_slab": "Обтёсанная дубовая плита", + "block.halflogs.stripped_spruce_log_slab": "Обтёсанная еловая плита", + "block.halflogs.stripped_birch_log_slab": "Обтёсанная берёзовая плита", + "block.halflogs.stripped_jungle_log_slab": "Обтёсанная джунглевая плита", + "block.halflogs.stripped_acacia_log_slab": "Обтёсанная акациевая плита", + "block.halflogs.stripped_dark_oak_log_slab": "Обтёсанная плита из тёмного дуба", + + "block.halflogs.oak_log_stairs": "Цельные дубовые ступеньки", + "block.halflogs.spruce_log_stairs": "Цельные еловые ступеньки", + "block.halflogs.birch_log_stairs": "Цельные берёзовые ступеньки", + "block.halflogs.jungle_log_stairs": "Цельные джунглевые ступеньки", + "block.halflogs.acacia_log_stairs": "Цельные акациевые ступеньки", + "block.halflogs.dark_oak_log_stairs": "Цельные ступеньки из тёмного дуба", + + "block.halflogs.stripped_oak_log_stairs": "Обтёсанные дубовые ступеньки", + "block.halflogs.stripped_spruce_log_stairs": "Обтёсанные еловые ступеньки", + "block.halflogs.stripped_birch_log_stairs": "Обтёсанные берёзовые ступеньки", + "block.halflogs.stripped_jungle_log_stairs": "Обтёсанные джунглевые ступеньки", + "block.halflogs.stripped_acacia_log_stairs": "Обтёсанные акациевые ступеньки", + "block.halflogs.stripped_dark_oak_log_stairs": "Обтёсанные ступеньки ступеньки" +} \ No newline at end of file From 8e3cfc3450eae05dc11871d4fc2cb3790ce7e879 Mon Sep 17 00:00:00 2001 From: Reisse Date: Fri, 21 Dec 2018 21:54:04 +0300 Subject: [PATCH 7/9] Revert tabs to spaces 3; --- build.gradle | 28 +- .../java/org/dimdev/halflogs/HalfLogs.java | 391 +++++++++--------- 2 files changed, 209 insertions(+), 210 deletions(-) diff --git a/build.gradle b/build.gradle index d92de14..a732373 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,13 @@ buildscript { - repositories { + repositories { mavenCentral() - maven { url 'https://www.jitpack.io' } - maven { url 'https://files.minecraftforge.net/maven' } + maven { url 'https://www.jitpack.io' } + maven { url 'https://files.minecraftforge.net/maven' } maven { url 'https://www.dimdev.org/maven/' } - } - dependencies { - classpath 'com.github.Chocohead:ForgeGradle:moderniser-SNAPSHOT' - } + } + dependencies { + classpath 'com.github.Chocohead:ForgeGradle:moderniser-SNAPSHOT' + } } apply plugin: 'net.minecraftforge.gradle.tweaker-client' @@ -22,18 +22,18 @@ targetCompatibility = 1.8 repositories { mavenCentral() - maven { url 'https://www.jitpack.io' } - maven { url 'http://repo.strezz.org/artifactory/list/Strezz-Central' } + maven { url 'https://www.jitpack.io' } + maven { url 'http://repo.strezz.org/artifactory/list/Strezz-Central' } maven { url 'https://www.dimdev.org/maven/' } } dependencies { - implementation 'com.github.Chocohead:Rift:jitpack-SNAPSHOT:dev' + implementation 'com.github.Chocohead:Rift:jitpack-SNAPSHOT:dev' } minecraft { - version = '1.13.2' - mappings = 'snapshot_20181130' - runDir = 'run' - tweakClass = 'org.dimdev.riftloader.launch.RiftLoaderClientTweaker' + version = '1.13.2' + mappings = 'snapshot_20181130' + runDir = 'run' + tweakClass = 'org.dimdev.riftloader.launch.RiftLoaderClientTweaker' } diff --git a/src/main/java/org/dimdev/halflogs/HalfLogs.java b/src/main/java/org/dimdev/halflogs/HalfLogs.java index 1287b0e..e599e59 100644 --- a/src/main/java/org/dimdev/halflogs/HalfLogs.java +++ b/src/main/java/org/dimdev/halflogs/HalfLogs.java @@ -26,200 +26,199 @@ import net.minecraft.world.World; public class HalfLogs implements BlockAdder, ItemAdder { - public static final EnumProperty AXIS = EnumProperty.create("axis", EnumFacing.Axis.class); - - private static BlockStairs createLogStairs(Block log) { - return new BlockStairs(log.getDefaultState(), Block.Properties.from(log)) { - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); - builder.add(AXIS); - } - - @Override - public IBlockState getStateForPlacement(BlockItemUseContext context) { - IBlockState state = super.getStateForPlacement(context); - state = state.with(AXIS, context.getFace().getAxis()); - return state; - } - - @Override - public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, EntityPlayer player, - EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - ItemStack stack = player.getHeldItem(hand); - Item item = stack.getItem(); - if (item instanceof ItemAxe) { - Block strippedBlock; - if (this == OAK_LOG_STAIRS) { - strippedBlock = STRIPPED_OAK_LOG_STAIRS; - } else if (this == SPRUCE_LOG_STAIRS) { - strippedBlock = STRIPPED_SPRUCE_LOG_STAIRS; - } else if (this == BIRCH_LOG_STAIRS) { - strippedBlock = STRIPPED_BIRCH_LOG_STAIRS; - } else if (this == JUNGLE_LOG_STAIRS) { - strippedBlock = STRIPPED_JUNGLE_LOG_STAIRS; - } else if (this == ACACIA_LOG_STAIRS) { - strippedBlock = STRIPPED_ACACIA_LOG_STAIRS; - } else if (this == DARK_OAK_LOG_STAIRS) { - strippedBlock = STRIPPED_DARK_OAK_LOG_STAIRS; - } else { - return false; - } - - world.setBlockState(pos, - strippedBlock.getDefaultState().with(AXIS, state.get(AXIS)) - .with(BlockStairs.FACING, state.get(BlockStairs.FACING)) - .with(BlockStairs.HALF, state.get(BlockStairs.HALF)) - .with(BlockStairs.SHAPE, state.get(BlockStairs.SHAPE))); - world.playSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F); - stack.damageItem(1, player); - return true; - } - return false; - } - }; - } - - private static BlockSlab createLogSlab(Block block) { - return new BlockSlab(Block.Properties.from(block)) { - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - super.fillStateContainer(builder); - builder.add(AXIS); - } - - @Override - public IBlockState getStateForPlacement(BlockItemUseContext context) { - IBlockState state = super.getStateForPlacement(context); - state = state.with(AXIS, context.getFace().getAxis()); - return state; - } - - @Override - public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, - EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - ItemStack stack = player.getHeldItem(hand); - Item item = stack.getItem(); - if (item instanceof ItemAxe) { - Block strippedBlock; - if (this == OAK_LOG_SLAB) { - strippedBlock = STRIPPED_OAK_LOG_SLAB; - } else if (this == SPRUCE_LOG_SLAB) { - strippedBlock = STRIPPED_SPRUCE_LOG_SLAB; - } else if (this == BIRCH_LOG_SLAB) { - strippedBlock = STRIPPED_BIRCH_LOG_SLAB; - } else if (this == JUNGLE_LOG_SLAB) { - strippedBlock = STRIPPED_JUNGLE_LOG_SLAB; - } else if (this == ACACIA_LOG_SLAB) { - strippedBlock = STRIPPED_ACACIA_LOG_SLAB; - } else if (this == DARK_OAK_LOG_SLAB) { - strippedBlock = STRIPPED_DARK_OAK_LOG_SLAB; - } else { - return false; - } - - SlabType slabType = state.get(BlockSlab.TYPE); - world.setBlockState(pos, strippedBlock.getDefaultState().with(AXIS, state.get(AXIS)) - .with(BlockSlab.TYPE, slabType)); - world.playSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, - 1.0F); - stack.damageItem(slabType == SlabType.DOUBLE ? (world.rand.nextBoolean() ? 2 : 1) : 1, player); // just - // because - return true; - } - return false; - } - }; - } - - - public final static Block OAK_LOG_SLAB = createLogSlab(Blocks.OAK_LOG); - public final static Block SPRUCE_LOG_SLAB = createLogSlab(Blocks.SPRUCE_LOG); - public final static Block BIRCH_LOG_SLAB = createLogSlab(Blocks.BIRCH_LOG); - public final static Block JUNGLE_LOG_SLAB = createLogSlab(Blocks.JUNGLE_LOG); - public final static Block ACACIA_LOG_SLAB = createLogSlab(Blocks.ACACIA_LOG); - public final static Block DARK_OAK_LOG_SLAB = createLogSlab(Blocks.DARK_OAK_LOG); - - public final static Block STRIPPED_OAK_LOG_SLAB = createLogSlab(Blocks.STRIPPED_OAK_LOG); - public final static Block STRIPPED_SPRUCE_LOG_SLAB = createLogSlab(Blocks.STRIPPED_SPRUCE_LOG); - public final static Block STRIPPED_BIRCH_LOG_SLAB = createLogSlab(Blocks.STRIPPED_BIRCH_LOG); - public final static Block STRIPPED_JUNGLE_LOG_SLAB = createLogSlab(Blocks.STRIPPED_JUNGLE_LOG); - public final static Block STRIPPED_ACACIA_LOG_SLAB = createLogSlab(Blocks.STRIPPED_ACACIA_LOG); - public final static Block STRIPPED_DARK_OAK_LOG_SLAB = createLogSlab(Blocks.STRIPPED_DARK_OAK_LOG); - - public final static Block OAK_LOG_STAIRS = createLogStairs(Blocks.OAK_LOG); - public final static Block SPRUCE_LOG_STAIRS = createLogStairs(Blocks.SPRUCE_LOG); - public final static Block BIRCH_LOG_STAIRS = createLogStairs(Blocks.BIRCH_LOG); - public final static Block JUNGLE_LOG_STAIRS = createLogStairs(Blocks.JUNGLE_LOG); - public final static Block ACACIA_LOG_STAIRS = createLogStairs(Blocks.ACACIA_LOG); - public final static Block DARK_OAK_LOG_STAIRS = createLogStairs(Blocks.DARK_OAK_LOG); - - public final static Block STRIPPED_OAK_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_OAK_LOG); - public final static Block STRIPPED_SPRUCE_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_SPRUCE_LOG); - public final static Block STRIPPED_BIRCH_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_BIRCH_LOG); - public final static Block STRIPPED_JUNGLE_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_JUNGLE_LOG); - public final static Block STRIPPED_ACACIA_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_ACACIA_LOG); - public final static Block STRIPPED_DARK_OAK_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_DARK_OAK_LOG); - - @Override - public void registerBlocks() { - Block.register(new ResourceLocation("halflogs:oak_log_slab"), OAK_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:spruce_log_slab"), SPRUCE_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:birch_log_slab"), BIRCH_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:jungle_log_slab"), JUNGLE_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:acacia_log_slab"), ACACIA_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:dark_oak_log_slab"), DARK_OAK_LOG_SLAB); - - Block.register(new ResourceLocation("halflogs:stripped_oak_log_slab"), STRIPPED_OAK_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:stripped_spruce_log_slab"), STRIPPED_SPRUCE_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:stripped_birch_log_slab"), STRIPPED_BIRCH_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:stripped_jungle_log_slab"), STRIPPED_JUNGLE_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:stripped_acacia_log_slab"), STRIPPED_ACACIA_LOG_SLAB); - Block.register(new ResourceLocation("halflogs:stripped_dark_oak_log_slab"), STRIPPED_DARK_OAK_LOG_SLAB); - - Block.register(new ResourceLocation("halflogs:oak_log_stairs"), OAK_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:spruce_log_stairs"), SPRUCE_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:birch_log_stairs"), BIRCH_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:jungle_log_stairs"), JUNGLE_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:acacia_log_stairs"), ACACIA_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:dark_oak_log_stairs"), DARK_OAK_LOG_STAIRS); - - Block.register(new ResourceLocation("halflogs:stripped_oak_log_stairs"), STRIPPED_OAK_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:stripped_spruce_log_stairs"), STRIPPED_SPRUCE_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:stripped_birch_log_stairs"), STRIPPED_BIRCH_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:stripped_jungle_log_stairs"), STRIPPED_JUNGLE_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:stripped_acacia_log_stairs"), STRIPPED_ACACIA_LOG_STAIRS); - Block.register(new ResourceLocation("halflogs:stripped_dark_oak_log_stairs"), STRIPPED_DARK_OAK_LOG_STAIRS); - } - - @Override - public void registerItems() { - Item.register(OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(SPRUCE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(BIRCH_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(JUNGLE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(ACACIA_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(DARK_OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - - Item.register(STRIPPED_OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_SPRUCE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_BIRCH_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_JUNGLE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_ACACIA_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_DARK_OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); - - Item.register(OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(SPRUCE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(BIRCH_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(JUNGLE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(ACACIA_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(DARK_OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - - Item.register(STRIPPED_OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_SPRUCE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_BIRCH_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_JUNGLE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_ACACIA_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - Item.register(STRIPPED_DARK_OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); - } + public static final EnumProperty AXIS = EnumProperty.create("axis", EnumFacing.Axis.class); + + private static BlockStairs createLogStairs(Block log) { + return new BlockStairs(log.getDefaultState(), Block.Properties.from(log)) { + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(AXIS); + } + + @Override + public IBlockState getStateForPlacement(BlockItemUseContext context) { + IBlockState state = super.getStateForPlacement(context); + state = state.with(AXIS, context.getFace().getAxis()); + return state; + } + + @Override + public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, EntityPlayer player, + EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + ItemStack stack = player.getHeldItem(hand); + Item item = stack.getItem(); + if (item instanceof ItemAxe) { + Block strippedBlock; + if (this == OAK_LOG_STAIRS) { + strippedBlock = STRIPPED_OAK_LOG_STAIRS; + } else if (this == SPRUCE_LOG_STAIRS) { + strippedBlock = STRIPPED_SPRUCE_LOG_STAIRS; + } else if (this == BIRCH_LOG_STAIRS) { + strippedBlock = STRIPPED_BIRCH_LOG_STAIRS; + } else if (this == JUNGLE_LOG_STAIRS) { + strippedBlock = STRIPPED_JUNGLE_LOG_STAIRS; + } else if (this == ACACIA_LOG_STAIRS) { + strippedBlock = STRIPPED_ACACIA_LOG_STAIRS; + } else if (this == DARK_OAK_LOG_STAIRS) { + strippedBlock = STRIPPED_DARK_OAK_LOG_STAIRS; + } else { + return false; + } + + world.setBlockState(pos, + strippedBlock.getDefaultState().with(AXIS, state.get(AXIS)) + .with(BlockStairs.FACING, state.get(BlockStairs.FACING)) + .with(BlockStairs.HALF, state.get(BlockStairs.HALF)) + .with(BlockStairs.SHAPE, state.get(BlockStairs.SHAPE))); + world.playSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F); + stack.damageItem(1, player); + return true; + } + return false; + } + }; + } + + private static BlockSlab createLogSlab(Block block) { + return new BlockSlab(Block.Properties.from(block)) { + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(AXIS); + } + + @Override + public IBlockState getStateForPlacement(BlockItemUseContext context) { + IBlockState state = super.getStateForPlacement(context); + state = state.with(AXIS, context.getFace().getAxis()); + return state; + } + + @Override + public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, + EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + ItemStack stack = player.getHeldItem(hand); + Item item = stack.getItem(); + if (item instanceof ItemAxe) { + Block strippedBlock; + if (this == OAK_LOG_SLAB) { + strippedBlock = STRIPPED_OAK_LOG_SLAB; + } else if (this == SPRUCE_LOG_SLAB) { + strippedBlock = STRIPPED_SPRUCE_LOG_SLAB; + } else if (this == BIRCH_LOG_SLAB) { + strippedBlock = STRIPPED_BIRCH_LOG_SLAB; + } else if (this == JUNGLE_LOG_SLAB) { + strippedBlock = STRIPPED_JUNGLE_LOG_SLAB; + } else if (this == ACACIA_LOG_SLAB) { + strippedBlock = STRIPPED_ACACIA_LOG_SLAB; + } else if (this == DARK_OAK_LOG_SLAB) { + strippedBlock = STRIPPED_DARK_OAK_LOG_SLAB; + } else { + return false; + } + + SlabType slabType = state.get(BlockSlab.TYPE); + world.setBlockState(pos, strippedBlock.getDefaultState().with(AXIS, state.get(AXIS)) + .with(BlockSlab.TYPE, slabType)); + world.playSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, + 1.0F); + stack.damageItem(slabType == SlabType.DOUBLE ? (world.rand.nextBoolean() ? 2 : 1) : 1, player); // just + // because + return true; + } + return false; + } + }; + } + + public final static Block OAK_LOG_SLAB = createLogSlab(Blocks.OAK_LOG); + public final static Block SPRUCE_LOG_SLAB = createLogSlab(Blocks.SPRUCE_LOG); + public final static Block BIRCH_LOG_SLAB = createLogSlab(Blocks.BIRCH_LOG); + public final static Block JUNGLE_LOG_SLAB = createLogSlab(Blocks.JUNGLE_LOG); + public final static Block ACACIA_LOG_SLAB = createLogSlab(Blocks.ACACIA_LOG); + public final static Block DARK_OAK_LOG_SLAB = createLogSlab(Blocks.DARK_OAK_LOG); + + public final static Block STRIPPED_OAK_LOG_SLAB = createLogSlab(Blocks.STRIPPED_OAK_LOG); + public final static Block STRIPPED_SPRUCE_LOG_SLAB = createLogSlab(Blocks.STRIPPED_SPRUCE_LOG); + public final static Block STRIPPED_BIRCH_LOG_SLAB = createLogSlab(Blocks.STRIPPED_BIRCH_LOG); + public final static Block STRIPPED_JUNGLE_LOG_SLAB = createLogSlab(Blocks.STRIPPED_JUNGLE_LOG); + public final static Block STRIPPED_ACACIA_LOG_SLAB = createLogSlab(Blocks.STRIPPED_ACACIA_LOG); + public final static Block STRIPPED_DARK_OAK_LOG_SLAB = createLogSlab(Blocks.STRIPPED_DARK_OAK_LOG); + + public final static Block OAK_LOG_STAIRS = createLogStairs(Blocks.OAK_LOG); + public final static Block SPRUCE_LOG_STAIRS = createLogStairs(Blocks.SPRUCE_LOG); + public final static Block BIRCH_LOG_STAIRS = createLogStairs(Blocks.BIRCH_LOG); + public final static Block JUNGLE_LOG_STAIRS = createLogStairs(Blocks.JUNGLE_LOG); + public final static Block ACACIA_LOG_STAIRS = createLogStairs(Blocks.ACACIA_LOG); + public final static Block DARK_OAK_LOG_STAIRS = createLogStairs(Blocks.DARK_OAK_LOG); + + public final static Block STRIPPED_OAK_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_OAK_LOG); + public final static Block STRIPPED_SPRUCE_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_SPRUCE_LOG); + public final static Block STRIPPED_BIRCH_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_BIRCH_LOG); + public final static Block STRIPPED_JUNGLE_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_JUNGLE_LOG); + public final static Block STRIPPED_ACACIA_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_ACACIA_LOG); + public final static Block STRIPPED_DARK_OAK_LOG_STAIRS = createLogStairs(Blocks.STRIPPED_DARK_OAK_LOG); + + @Override + public void registerBlocks() { + Block.register(new ResourceLocation("halflogs:oak_log_slab"), OAK_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:spruce_log_slab"), SPRUCE_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:birch_log_slab"), BIRCH_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:jungle_log_slab"), JUNGLE_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:acacia_log_slab"), ACACIA_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:dark_oak_log_slab"), DARK_OAK_LOG_SLAB); + + Block.register(new ResourceLocation("halflogs:stripped_oak_log_slab"), STRIPPED_OAK_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:stripped_spruce_log_slab"), STRIPPED_SPRUCE_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:stripped_birch_log_slab"), STRIPPED_BIRCH_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:stripped_jungle_log_slab"), STRIPPED_JUNGLE_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:stripped_acacia_log_slab"), STRIPPED_ACACIA_LOG_SLAB); + Block.register(new ResourceLocation("halflogs:stripped_dark_oak_log_slab"), STRIPPED_DARK_OAK_LOG_SLAB); + + Block.register(new ResourceLocation("halflogs:oak_log_stairs"), OAK_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:spruce_log_stairs"), SPRUCE_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:birch_log_stairs"), BIRCH_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:jungle_log_stairs"), JUNGLE_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:acacia_log_stairs"), ACACIA_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:dark_oak_log_stairs"), DARK_OAK_LOG_STAIRS); + + Block.register(new ResourceLocation("halflogs:stripped_oak_log_stairs"), STRIPPED_OAK_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:stripped_spruce_log_stairs"), STRIPPED_SPRUCE_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:stripped_birch_log_stairs"), STRIPPED_BIRCH_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:stripped_jungle_log_stairs"), STRIPPED_JUNGLE_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:stripped_acacia_log_stairs"), STRIPPED_ACACIA_LOG_STAIRS); + Block.register(new ResourceLocation("halflogs:stripped_dark_oak_log_stairs"), STRIPPED_DARK_OAK_LOG_STAIRS); + } + + @Override + public void registerItems() { + Item.register(OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(SPRUCE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(BIRCH_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(JUNGLE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(ACACIA_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(DARK_OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + + Item.register(STRIPPED_OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_SPRUCE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_BIRCH_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_JUNGLE_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_ACACIA_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_DARK_OAK_LOG_SLAB, ItemGroup.BUILDING_BLOCKS); + + Item.register(OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(SPRUCE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(BIRCH_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(JUNGLE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(ACACIA_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(DARK_OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + + Item.register(STRIPPED_OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_SPRUCE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_BIRCH_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_JUNGLE_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_ACACIA_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + Item.register(STRIPPED_DARK_OAK_LOG_STAIRS, ItemGroup.BUILDING_BLOCKS); + } } From fd77355bc0874ee751b76e8b8644d6113ab1bfe5 Mon Sep 17 00:00:00 2001 From: Reisse Date: Fri, 21 Dec 2018 22:09:14 +0300 Subject: [PATCH 8/9] Use BlockStateProperties.AXIS insetad of creating a new instance --- src/main/java/org/dimdev/halflogs/HalfLogs.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/dimdev/halflogs/HalfLogs.java b/src/main/java/org/dimdev/halflogs/HalfLogs.java index e599e59..0d4d420 100644 --- a/src/main/java/org/dimdev/halflogs/HalfLogs.java +++ b/src/main/java/org/dimdev/halflogs/HalfLogs.java @@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.state.EnumProperty; import net.minecraft.state.StateContainer; +import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.SlabType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; @@ -26,7 +27,7 @@ import net.minecraft.world.World; public class HalfLogs implements BlockAdder, ItemAdder { - public static final EnumProperty AXIS = EnumProperty.create("axis", EnumFacing.Axis.class); + public static final EnumProperty AXIS = BlockStateProperties.AXIS; private static BlockStairs createLogStairs(Block log) { return new BlockStairs(log.getDefaultState(), Block.Properties.from(log)) { From fce37a455e0b753b721e91145e6466f7417a3528 Mon Sep 17 00:00:00 2001 From: Reisse Date: Fri, 21 Dec 2018 22:10:12 +0300 Subject: [PATCH 9/9] Fix typo in russian localization --- src/main/resources/assets/halflogs/lang/ru_ru.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/assets/halflogs/lang/ru_ru.json b/src/main/resources/assets/halflogs/lang/ru_ru.json index 7aa19c7..6189091 100644 --- a/src/main/resources/assets/halflogs/lang/ru_ru.json +++ b/src/main/resources/assets/halflogs/lang/ru_ru.json @@ -25,5 +25,5 @@ "block.halflogs.stripped_birch_log_stairs": "Обтёсанные берёзовые ступеньки", "block.halflogs.stripped_jungle_log_stairs": "Обтёсанные джунглевые ступеньки", "block.halflogs.stripped_acacia_log_stairs": "Обтёсанные акациевые ступеньки", - "block.halflogs.stripped_dark_oak_log_stairs": "Обтёсанные ступеньки ступеньки" + "block.halflogs.stripped_dark_oak_log_stairs": "Обтёсанные ступеньки из тёмного дуба" } \ No newline at end of file