mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
chore: so much block porting
This commit is contained in:
parent
97bc966606
commit
6f34f82f4e
43 changed files with 638 additions and 1056 deletions
|
@ -15,6 +15,8 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraftforge.common.ToolType;
|
||||||
import net.minecraftforge.fml.RegistryObject;
|
import net.minecraftforge.fml.RegistryObject;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
@ -48,8 +50,6 @@ public final class ActuallyBlocks {
|
||||||
public static final RegistryObject<Block> blockFireworkBox = BLOCKS.register("block_firework_box", BlockFireworkBox::new);
|
public static final RegistryObject<Block> blockFireworkBox = BLOCKS.register("block_firework_box", BlockFireworkBox::new);
|
||||||
public static final RegistryObject<Block> blockMiner = BLOCKS.register("block_miner", BlockMiner::new);
|
public static final RegistryObject<Block> blockMiner = BLOCKS.register("block_miner", BlockMiner::new);
|
||||||
public static final RegistryObject<Block> blockAtomicReconstructor = BLOCKS.register("block_atomic_reconstructor", BlockAtomicReconstructor::new);
|
public static final RegistryObject<Block> blockAtomicReconstructor = BLOCKS.register("block_atomic_reconstructor", BlockAtomicReconstructor::new);
|
||||||
public static final RegistryObject<Block> blockCrystal = BLOCKS.register("block_crystal", () -> new BlockCrystal(false));
|
|
||||||
public static final RegistryObject<Block> blockCrystalEmpowered = BLOCKS.register("block_crystal_empowered", () -> new BlockCrystal(true));
|
|
||||||
public static final RegistryObject<Block> blockLaserRelay = BLOCKS.register("block_laser_relay", () -> new BlockLaserRelay(BlockLaserRelay.Type.ENERGY_BASIC));
|
public static final RegistryObject<Block> blockLaserRelay = BLOCKS.register("block_laser_relay", () -> new BlockLaserRelay(BlockLaserRelay.Type.ENERGY_BASIC));
|
||||||
public static final RegistryObject<Block> blockLaserRelayAdvanced = BLOCKS.register("block_laser_relay_advanced", () -> new BlockLaserRelay(BlockLaserRelay.Type.ENERGY_ADVANCED));
|
public static final RegistryObject<Block> blockLaserRelayAdvanced = BLOCKS.register("block_laser_relay_advanced", () -> new BlockLaserRelay(BlockLaserRelay.Type.ENERGY_ADVANCED));
|
||||||
public static final RegistryObject<Block> blockLaserRelayExtreme = BLOCKS.register("block_laser_relay_extreme", () -> new BlockLaserRelay(BlockLaserRelay.Type.ENERGY_EXTREME));
|
public static final RegistryObject<Block> blockLaserRelayExtreme = BLOCKS.register("block_laser_relay_extreme", () -> new BlockLaserRelay(BlockLaserRelay.Type.ENERGY_EXTREME));
|
||||||
|
@ -59,7 +59,6 @@ public final class ActuallyBlocks {
|
||||||
public static final RegistryObject<Block> blockRangedCollector = BLOCKS.register("block_ranged_collector", BlockRangedCollector::new);
|
public static final RegistryObject<Block> blockRangedCollector = BLOCKS.register("block_ranged_collector", BlockRangedCollector::new);
|
||||||
public static final RegistryObject<Block> blockDirectionalBreaker = BLOCKS.register("block_directional_breaker", BlockDirectionalBreaker::new);
|
public static final RegistryObject<Block> blockDirectionalBreaker = BLOCKS.register("block_directional_breaker", BlockDirectionalBreaker::new);
|
||||||
public static final RegistryObject<Block> blockLeafGenerator = BLOCKS.register("block_leaf_generator", BlockLeafGenerator::new);
|
public static final RegistryObject<Block> blockLeafGenerator = BLOCKS.register("block_leaf_generator", BlockLeafGenerator::new);
|
||||||
public static final RegistryObject<Block> blockSmileyCloud = BLOCKS.register("block_smiley_cloud", BlockSmileyCloud::new);
|
|
||||||
public static final RegistryObject<Block> blockXPSolidifier = BLOCKS.register("block_xp_solidifier", BlockXPSolidifier::new);
|
public static final RegistryObject<Block> blockXPSolidifier = BLOCKS.register("block_xp_solidifier", BlockXPSolidifier::new);
|
||||||
public static final RegistryObject<Block> blockTestifiBucksGreenWall = BLOCKS.register("block_testifi_bucks_green_wall", BlockGeneric::new);
|
public static final RegistryObject<Block> blockTestifiBucksGreenWall = BLOCKS.register("block_testifi_bucks_green_wall", BlockGeneric::new);
|
||||||
public static final RegistryObject<Block> blockTestifiBucksWhiteWall = BLOCKS.register("block_testifi_bucks_white_wall", BlockGeneric::new);
|
public static final RegistryObject<Block> blockTestifiBucksWhiteWall = BLOCKS.register("block_testifi_bucks_white_wall", BlockGeneric::new);
|
||||||
|
@ -69,8 +68,40 @@ public final class ActuallyBlocks {
|
||||||
public static final RegistryObject<Block> blockTestifiBucksWhiteSlab = BLOCKS.register("block_testifi_bucks_white_slab", () -> new SlabBlock(AbstractBlock.Properties.from(blockTestifiBucksWhiteWall.get())));
|
public static final RegistryObject<Block> blockTestifiBucksWhiteSlab = BLOCKS.register("block_testifi_bucks_white_slab", () -> new SlabBlock(AbstractBlock.Properties.from(blockTestifiBucksWhiteWall.get())));
|
||||||
public static final RegistryObject<Block> blockTestifiBucksGreenFence = BLOCKS.register("block_testifi_bucks_green_fence", () -> new WallBlock(AbstractBlock.Properties.from(blockTestifiBucksGreenWall.get())));
|
public static final RegistryObject<Block> blockTestifiBucksGreenFence = BLOCKS.register("block_testifi_bucks_green_fence", () -> new WallBlock(AbstractBlock.Properties.from(blockTestifiBucksGreenWall.get())));
|
||||||
public static final RegistryObject<Block> blockTestifiBucksWhiteFence = BLOCKS.register("block_testifi_bucks_white_fence", () -> new WallBlock(AbstractBlock.Properties.from(blockTestifiBucksWhiteWall.get())));
|
public static final RegistryObject<Block> blockTestifiBucksWhiteFence = BLOCKS.register("block_testifi_bucks_white_fence", () -> new WallBlock(AbstractBlock.Properties.from(blockTestifiBucksWhiteWall.get())));
|
||||||
public static final RegistryObject<Block> blockColoredLamp = BLOCKS.register("block_colored_lamp", () -> new BlockColoredLamp(false));
|
|
||||||
public static final RegistryObject<Block> blockColoredLampOn = BLOCKS.register("block_colored_lamp_on", () -> new BlockColoredLamp(true));
|
public static final RegistryObject<Block> CRYSTAL_ENORI = BLOCKS.register("crystal_enori_block", () -> new BlockCrystal(false));
|
||||||
|
public static final RegistryObject<Block> CRYSTAL_RESTONIA = BLOCKS.register("crystal_restonia_block", () -> new BlockCrystal(false));
|
||||||
|
public static final RegistryObject<Block> CRYSTAL_PALIS = BLOCKS.register("crystal_palis_block", () -> new BlockCrystal(false));
|
||||||
|
public static final RegistryObject<Block> CRYSTAL_DIAMATINE = BLOCKS.register("crystal_diamatine_block", () -> new BlockCrystal(false));
|
||||||
|
public static final RegistryObject<Block> CRYSTAL_VOID = BLOCKS.register("crystal_void_block", () -> new BlockCrystal(false));
|
||||||
|
public static final RegistryObject<Block> CRYSTAL_EMERADIC = BLOCKS.register("crystal_emeradic_block", () -> new BlockCrystal(false));
|
||||||
|
|
||||||
|
public static final RegistryObject<Block> CRYSTAL_EMPOWERED_ENORI = BLOCKS.register("crystal_enori_empowered_block", () -> new BlockCrystal(true));
|
||||||
|
public static final RegistryObject<Block> CRYSTAL_EMPOWERED_RESTONIA = BLOCKS.register("crystal_restonia_empowered_block", () -> new BlockCrystal(true));
|
||||||
|
public static final RegistryObject<Block> CRYSTAL_EMPOWERED_PALIS = BLOCKS.register("crystal_palis_empowered_block", () -> new BlockCrystal(true));
|
||||||
|
public static final RegistryObject<Block> CRYSTAL_EMPOWERED_DIAMATINE = BLOCKS.register("crystal_diamatine_empowered_block", () -> new BlockCrystal(true));
|
||||||
|
public static final RegistryObject<Block> CRYSTAL_EMPOWERED_VOID = BLOCKS.register("crystal_void_empowered_block", () -> new BlockCrystal(true));
|
||||||
|
public static final RegistryObject<Block> CRYSTAL_EMPOWERED_EMERADIC = BLOCKS.register("crystal_emeradic_empowered_block", () -> new BlockCrystal(true));
|
||||||
|
|
||||||
|
public static final RegistryObject<Block> LAMP_WHITE = BLOCKS.register("lamp_white_block", BlockColoredLamp::new);
|
||||||
|
public static final RegistryObject<Block> LAMP_ORANGE = BLOCKS.register("lamp_orange_block", BlockColoredLamp::new);
|
||||||
|
public static final RegistryObject<Block> LAMP_MAGENTA = BLOCKS.register("lamp_magenta_block", BlockColoredLamp::new);
|
||||||
|
public static final RegistryObject<Block> LAMP_LIGHT_BLUE = BLOCKS.register("lamp_light_blue_block", BlockColoredLamp::new);
|
||||||
|
public static final RegistryObject<Block> LAMP_YELLOW = BLOCKS.register("lamp_yellow_block", BlockColoredLamp::new);
|
||||||
|
public static final RegistryObject<Block> LAMP_LIME = BLOCKS.register("lamp_lime_block", BlockColoredLamp::new);
|
||||||
|
public static final RegistryObject<Block> LAMP_PINK = BLOCKS.register("lamp_pink_block", BlockColoredLamp::new);
|
||||||
|
public static final RegistryObject<Block> LAMP_GRAY = BLOCKS.register("lamp_gray_block", BlockColoredLamp::new);
|
||||||
|
public static final RegistryObject<Block> LAMP_LIGHT_GRAY = BLOCKS.register("lamp_light_gray_block", BlockColoredLamp::new);
|
||||||
|
public static final RegistryObject<Block> LAMP_CYAN = BLOCKS.register("lamp_cyan_block", BlockColoredLamp::new);
|
||||||
|
public static final RegistryObject<Block> LAMP_PURPLE = BLOCKS.register("lamp_purple_block", BlockColoredLamp::new);
|
||||||
|
public static final RegistryObject<Block> LAMP_BLUE = BLOCKS.register("lamp_blue_block", BlockColoredLamp::new);
|
||||||
|
public static final RegistryObject<Block> LAMP_BROWN = BLOCKS.register("lamp_brown_block", BlockColoredLamp::new);
|
||||||
|
public static final RegistryObject<Block> LAMP_GREEN = BLOCKS.register("lamp_green_block", BlockColoredLamp::new);
|
||||||
|
public static final RegistryObject<Block> LAMP_RED = BLOCKS.register("lamp_red_block", BlockColoredLamp::new);
|
||||||
|
public static final RegistryObject<Block> LAMP_BLACK = BLOCKS.register("lamp_black_block", BlockColoredLamp::new);
|
||||||
|
|
||||||
|
// public static final RegistryObject<Block> blockColoredLamp = BLOCKS.register("block_colored_lamp", () -> new BlockColoredLamp());
|
||||||
|
// public static final RegistryObject<Block> blockColoredLampOn = BLOCKS.register("block_colored_lamp_on", () -> new BlockColoredLamp());
|
||||||
public static final RegistryObject<Block> blockLampPowerer = BLOCKS.register("block_lamp_powerer", BlockLampPowerer::new);
|
public static final RegistryObject<Block> blockLampPowerer = BLOCKS.register("block_lamp_powerer", BlockLampPowerer::new);
|
||||||
// public static final RegistryObject<Block> blockTreasureChest = BLOCKS.register("block_treasure_chest", BlockTreasureChest::new);
|
// public static final RegistryObject<Block> blockTreasureChest = BLOCKS.register("block_treasure_chest", BlockTreasureChest::new);
|
||||||
public static final RegistryObject<Block> blockEnergizer = BLOCKS.register("block_energizer", () -> new BlockEnergizer(true));
|
public static final RegistryObject<Block> blockEnergizer = BLOCKS.register("block_energizer", () -> new BlockEnergizer(true));
|
||||||
|
@ -112,4 +143,12 @@ public final class ActuallyBlocks {
|
||||||
public static final RegistryObject<Block> blockQuartzSlab = BLOCKS.register("block_quartz_slab", () -> new SlabBlock(AbstractBlock.Properties.from(blockMisc.get())));
|
public static final RegistryObject<Block> blockQuartzSlab = BLOCKS.register("block_quartz_slab", () -> new SlabBlock(AbstractBlock.Properties.from(blockMisc.get())));
|
||||||
public static final RegistryObject<Block> blockChiseledQuartzSlab = BLOCKS.register("block_chiseled_quartz_slab", () -> new SlabBlock(AbstractBlock.Properties.from(blockMisc.get())));
|
public static final RegistryObject<Block> blockChiseledQuartzSlab = BLOCKS.register("block_chiseled_quartz_slab", () -> new SlabBlock(AbstractBlock.Properties.from(blockMisc.get())));
|
||||||
public static final RegistryObject<Block> blockPillarQuartzSlab = BLOCKS.register("block_pillar_quartz_slab", () -> new SlabBlock(AbstractBlock.Properties.from(blockMisc.get())));
|
public static final RegistryObject<Block> blockPillarQuartzSlab = BLOCKS.register("block_pillar_quartz_slab", () -> new SlabBlock(AbstractBlock.Properties.from(blockMisc.get())));
|
||||||
|
|
||||||
|
public static AbstractBlock.Properties defaultPickProps(int harvestLevel, float hardness, float resistance) {
|
||||||
|
return AbstractBlock.Properties.create(Material.ROCK).harvestLevel(harvestLevel).harvestTool(ToolType.PICKAXE).hardnessAndResistance(hardness, resistance).sound(SoundType.STONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AbstractBlock.Properties defaultPickProps(int harvestLevel) {
|
||||||
|
return AbstractBlock.Properties.create(Material.ROCK).harvestLevel(harvestLevel).harvestTool(ToolType.PICKAXE).hardnessAndResistance(1.5F, 10.0F).sound(SoundType.STONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,6 @@ import de.ellpeck.actuallyadditions.mod.util.Lang;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.SoundType;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.client.MainWindow;
|
import net.minecraft.client.MainWindow;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
@ -43,7 +41,6 @@ import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.common.ToolType;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -54,7 +51,7 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im
|
||||||
public static final int NAME_FLAVOR_AMOUNTS_2 = 14;
|
public static final int NAME_FLAVOR_AMOUNTS_2 = 14;
|
||||||
|
|
||||||
public BlockAtomicReconstructor() {
|
public BlockAtomicReconstructor() {
|
||||||
super(Properties.create(Material.ROCK).harvestTool(ToolType.PICKAXE).hardnessAndResistance(10F, 80F).sound(SoundType.STONE));
|
super(ActuallyBlocks.defaultPickProps(0, 10.0F, 80F));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,8 +15,6 @@ import de.ellpeck.actuallyadditions.mod.items.ItemBattery;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBatteryBox;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBatteryBox;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.SoundType;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -26,14 +24,13 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ToolType;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class BlockBatteryBox extends BlockContainerBase {
|
public class BlockBatteryBox extends BlockContainerBase {
|
||||||
|
|
||||||
public BlockBatteryBox() {
|
public BlockBatteryBox() {
|
||||||
super(Properties.create(Material.ROCK).harvestTool(ToolType.PICKAXE).hardnessAndResistance(1.5f, 10.0f).sound(SoundType.STONE));
|
super(ActuallyBlocks.defaultPickProps(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
|
|
|
@ -13,10 +13,7 @@ package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBioReactor;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBioReactor;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.SoundType;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
|
@ -24,13 +21,11 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ToolType;
|
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
|
||||||
|
|
||||||
public class BlockBioReactor extends BlockContainerBase {
|
public class BlockBioReactor extends BlockContainerBase {
|
||||||
|
|
||||||
public BlockBioReactor() {
|
public BlockBioReactor() {
|
||||||
super(Properties.create(Material.ROCK).harvestTool(ToolType.PICKAXE).hardnessAndResistance(2.0F, 10.0F).sound(SoundType.STONE));
|
super(ActuallyBlocks.defaultPickProps(0, 2.0F, 10.0F));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,12 +35,6 @@ public class BlockBioReactor extends BlockContainerBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||||
if (!world.isRemote) {
|
return this.openGui(world, player, pos, TileEntityBioReactor.class);
|
||||||
TileEntity tileEntity = world.getTileEntity(pos);
|
|
||||||
if (tileEntity instanceof TileEntityBioReactor) {
|
|
||||||
NetworkHooks.openGui((ServerPlayerEntity) player, (TileEntityBioReactor) tileEntity, pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ActionResultType.PASS;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlacer;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlacer;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.SoundType;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
|
@ -25,8 +22,6 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ToolType;
|
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -35,7 +30,7 @@ public class BlockBreaker extends FullyDirectionalBlock.Container {
|
||||||
private final boolean isPlacer;
|
private final boolean isPlacer;
|
||||||
|
|
||||||
public BlockBreaker(boolean isPlacer) {
|
public BlockBreaker(boolean isPlacer) {
|
||||||
super(Properties.create(Material.ROCK).hardnessAndResistance(1.5F, 10.0F).harvestTool(ToolType.PICKAXE).harvestLevel(0).sound(SoundType.STONE));
|
super(ActuallyBlocks.defaultPickProps(0));
|
||||||
this.isPlacer = isPlacer;
|
this.isPlacer = isPlacer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,13 +47,7 @@ public class BlockBreaker extends FullyDirectionalBlock.Container {
|
||||||
if (this.tryToggleRedstone(world, pos, player)) {
|
if (this.tryToggleRedstone(world, pos, player)) {
|
||||||
return ActionResultType.PASS;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
if (!world.isRemote) {
|
|
||||||
TileEntityBreaker tile = (TileEntityBreaker) world.getTileEntity(pos);
|
return this.openGui(world, player, pos, TileEntityBreaker.class);
|
||||||
if (tile != null) {
|
|
||||||
NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
|
|
||||||
}
|
|
||||||
return ActionResultType.PASS;
|
|
||||||
}
|
|
||||||
return super.onBlockActivated(state, world, pos, player, handIn, hit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,6 @@ package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.SoundType;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -26,7 +24,6 @@ import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ToolType;
|
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -34,7 +31,7 @@ import javax.annotation.Nullable;
|
||||||
public class BlockCanolaPress extends BlockContainerBase {
|
public class BlockCanolaPress extends BlockContainerBase {
|
||||||
|
|
||||||
public BlockCanolaPress() {
|
public BlockCanolaPress() {
|
||||||
super(Properties.create(Material.ROCK).harvestTool(ToolType.PICKAXE).harvestLevel(0).hardnessAndResistance(1.5F, 10.0F).sound(SoundType.STONE));
|
super(ActuallyBlocks.defaultPickProps(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
|
|
|
@ -13,10 +13,7 @@ package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.SoundType;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
|
||||||
import net.minecraft.particles.ParticleTypes;
|
import net.minecraft.particles.ParticleTypes;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
|
@ -28,14 +25,12 @@ import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraftforge.common.ToolType;
|
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class BlockCoalGenerator extends DirectionalBlock.Container {
|
public class BlockCoalGenerator extends DirectionalBlock.Container {
|
||||||
public BlockCoalGenerator() {
|
public BlockCoalGenerator() {
|
||||||
super(Properties.create(Material.ROCK).harvestTool(ToolType.PICKAXE).harvestLevel(0).hardnessAndResistance(1.5F, 10.0F).sound(SoundType.STONE).tickRandomly());
|
super(ActuallyBlocks.defaultPickProps(0).tickRandomly());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,15 +52,7 @@ public class BlockCoalGenerator extends DirectionalBlock.Container {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||||
if (!world.isRemote) {
|
return this.openGui(world, player, pos, TileEntityCoalGenerator.class);
|
||||||
TileEntityCoalGenerator tile = (TileEntityCoalGenerator) world.getTileEntity(pos);
|
|
||||||
if (tile != null) {
|
|
||||||
NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
|
|
||||||
}
|
|
||||||
return ActionResultType.PASS;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onBlockActivated(state, world, pos, player, hand, hit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -13,8 +13,6 @@ package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.SoundType;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -26,14 +24,13 @@ import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ToolType;
|
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class BlockCoffeeMachine extends DirectionalBlock.Container {
|
public class BlockCoffeeMachine extends DirectionalBlock.Container {
|
||||||
public BlockCoffeeMachine() {
|
public BlockCoffeeMachine() {
|
||||||
super(Properties.create(Material.ROCK).harvestTool(ToolType.PICKAXE).harvestLevel(0).hardnessAndResistance(1.5F, 10.0F).sound(SoundType.STONE));
|
super(ActuallyBlocks.defaultPickProps(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,166 +10,122 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.properties.PropertyEnum;
|
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.DyeColor;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.DyeItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.state.BooleanProperty;
|
||||||
|
import net.minecraft.state.StateContainer;
|
||||||
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.NonNullList;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.common.ToolType;
|
||||||
import net.minecraftforge.fml.relauncher.OnlyIn;
|
import net.minecraftforge.common.util.Constants;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.HashMap;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class BlockColoredLamp extends BlockBase {
|
public class BlockColoredLamp extends BlockBase {
|
||||||
|
private static final HashMap<DyeColor, Supplier<Block>> COLOR_TO_LAMP = new HashMap<DyeColor, Supplier<Block>>() {{
|
||||||
|
this.put(DyeColor.WHITE, ActuallyBlocks.LAMP_WHITE);
|
||||||
|
this.put(DyeColor.ORANGE, ActuallyBlocks.LAMP_ORANGE);
|
||||||
|
this.put(DyeColor.MAGENTA, ActuallyBlocks.LAMP_MAGENTA);
|
||||||
|
this.put(DyeColor.LIGHT_BLUE, ActuallyBlocks.LAMP_LIGHT_BLUE);
|
||||||
|
this.put(DyeColor.YELLOW, ActuallyBlocks.LAMP_YELLOW);
|
||||||
|
this.put(DyeColor.LIME, ActuallyBlocks.LAMP_LIME);
|
||||||
|
this.put(DyeColor.PINK, ActuallyBlocks.LAMP_PINK);
|
||||||
|
this.put(DyeColor.GRAY, ActuallyBlocks.LAMP_GRAY);
|
||||||
|
this.put(DyeColor.LIGHT_GRAY, ActuallyBlocks.LAMP_LIGHT_GRAY);
|
||||||
|
this.put(DyeColor.CYAN, ActuallyBlocks.LAMP_CYAN);
|
||||||
|
this.put(DyeColor.PURPLE, ActuallyBlocks.LAMP_PURPLE);
|
||||||
|
this.put(DyeColor.BLUE, ActuallyBlocks.LAMP_BLUE);
|
||||||
|
this.put(DyeColor.BROWN, ActuallyBlocks.LAMP_BROWN);
|
||||||
|
this.put(DyeColor.GREEN, ActuallyBlocks.LAMP_GREEN);
|
||||||
|
this.put(DyeColor.RED, ActuallyBlocks.LAMP_RED);
|
||||||
|
this.put(DyeColor.BLACK, ActuallyBlocks.LAMP_BLACK);
|
||||||
|
}};
|
||||||
|
|
||||||
public static final TheColoredLampColors[] ALL_LAMP_TYPES = TheColoredLampColors.values();
|
private static final BooleanProperty LIT = BlockStateProperties.LIT;
|
||||||
public static final PropertyEnum<TheColoredLampColors> TYPE = PropertyEnum.create("type", TheColoredLampColors.class);
|
|
||||||
public final boolean isOn;
|
|
||||||
|
|
||||||
public BlockColoredLamp(boolean isOn) {
|
public BlockColoredLamp() {
|
||||||
super(Material.REDSTONE_LIGHT, name);
|
super(Properties.create(Material.REDSTONE_LIGHT).hardnessAndResistance(0.5F, 3.0F).harvestTool(ToolType.PICKAXE).harvestLevel(0));
|
||||||
this.setHarvestLevel("pickaxe", 0);
|
this.setDefaultState(this.stateContainer.getBaseState().with(LIT, false));
|
||||||
this.setHardness(0.5F);
|
|
||||||
this.setResistance(3.0F);
|
|
||||||
this.isOn = isOn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item getItemDropped(BlockState state, Random rand, int par3) {
|
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||||
return Item.getItemFromBlock(ActuallyBlocks.blockColoredLamp);
|
builder.add(LIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: [port][test] validate this rework works
|
||||||
@Override
|
@Override
|
||||||
public int damageDropped(BlockState state) {
|
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||||
return this.getMetaFromState(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
|
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
//Turning On
|
//Turning On
|
||||||
if (hand == Hand.MAIN_HAND && stack.isEmpty()) {
|
if (hand == Hand.MAIN_HAND && stack.isEmpty()) {
|
||||||
world.setBlockState(pos, (this.isOn
|
world.setBlockState(pos, this.getDefaultState().with(LIT, !state.get(LIT)), Constants.BlockFlags.NO_RERENDER);
|
||||||
? ActuallyBlocks.blockColoredLamp
|
return ActionResultType.PASS;
|
||||||
: ActuallyBlocks.blockColoredLampOn).getDefaultState().withProperty(TYPE, state.getValue(TYPE)), 2);
|
|
||||||
world.notifyLightSet(pos);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StackUtil.isValid(stack)) {
|
if (StackUtil.isValid(stack) && stack.getItem() instanceof DyeItem) {
|
||||||
//Changing Colors
|
DyeColor color = DyeColor.getColor(stack);
|
||||||
int[] oreIDs = OreDictionary.getOreIDs(stack);
|
if (color == null) {
|
||||||
if (oreIDs.length > 0) {
|
return ActionResultType.FAIL;
|
||||||
for (int oreID : oreIDs) {
|
}
|
||||||
String name = OreDictionary.getOreName(oreID);
|
|
||||||
TheColoredLampColors color = TheColoredLampColors.getColorFromDyeName(name);
|
Block newColor = COLOR_TO_LAMP.get(color).get();
|
||||||
if (color != null) {
|
|
||||||
if (this.getMetaFromState(state) != color.ordinal()) {
|
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
world.setBlockState(pos, this.getStateFromMeta(color.ordinal()), 2);
|
world.setBlockState(pos, newColor.getDefaultState().with(LIT, state.get(LIT)), 2);
|
||||||
if (!player.capabilities.isCreativeMode) {
|
if (!player.isCreative()) {
|
||||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
return super.onBlockActivated(state, world, pos, player, hand, hit);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
public int getLightValue(BlockState state, IBlockReader world, BlockPos pos) {
|
||||||
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
return state.get(LIT)
|
||||||
for (int j = 0; j < ALL_LAMP_TYPES.length; j++) {
|
|
||||||
list.add(new ItemStack(this, 1, j));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLightValue(BlockState state, IBlockAccess world, BlockPos pos) {
|
|
||||||
return this.isOn
|
|
||||||
? 15
|
? 15
|
||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// TODO: [port] Add this back correctly
|
||||||
protected ItemBlockBase getItemBlock() {
|
// public static class TheItemBlock extends ItemBlockBase {
|
||||||
return new TheItemBlock(this);
|
//
|
||||||
}
|
// public TheItemBlock(Block block) {
|
||||||
|
// super(block);
|
||||||
@Override
|
// this.setHasSubtypes(true);
|
||||||
public void registerRendering() {
|
// this.setMaxDamage(0);
|
||||||
for (int i = 0; i < ALL_LAMP_TYPES.length; i++) {
|
// }
|
||||||
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName() + "=" + ALL_LAMP_TYPES[i].regName);
|
//
|
||||||
}
|
// @Override
|
||||||
}
|
// public String getItemStackDisplayName(ItemStack stack) {
|
||||||
|
// if (stack.getItemDamage() >= ALL_LAMP_TYPES.length) {
|
||||||
@Override
|
// return StringUtil.BUGGED_ITEM_NAME;
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
// }
|
||||||
return EnumRarity.RARE;
|
// if (Util.isClient()) {
|
||||||
}
|
// return super.getItemStackDisplayName(stack) + (((BlockColoredLamp) this.block).isOn
|
||||||
|
// ? " (" + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".onSuffix.desc") + ")"
|
||||||
@Override
|
// : "");
|
||||||
public BlockState getStateFromMeta(int meta) {
|
// } else {
|
||||||
return this.getDefaultState().withProperty(TYPE, TheColoredLampColors.values()[meta]);
|
// return super.getItemStackDisplayName(stack);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public int getMetaFromState(BlockState state) {
|
// @Override
|
||||||
return state.getValue(TYPE).ordinal();
|
// public String getTranslationKey(ItemStack stack) {
|
||||||
}
|
// return ActuallyBlocks.blockColoredLamp.getTranslationKey() + "_" + ALL_LAMP_TYPES[stack.getItemDamage()].regName;
|
||||||
|
// }
|
||||||
@Override
|
// }
|
||||||
protected BlockStateContainer createBlockState() {
|
|
||||||
return new BlockStateContainer(this, TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TheItemBlock extends ItemBlockBase {
|
|
||||||
|
|
||||||
public TheItemBlock(Block block) {
|
|
||||||
super(block);
|
|
||||||
this.setHasSubtypes(true);
|
|
||||||
this.setMaxDamage(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getItemStackDisplayName(ItemStack stack) {
|
|
||||||
if (stack.getItemDamage() >= ALL_LAMP_TYPES.length) {
|
|
||||||
return StringUtil.BUGGED_ITEM_NAME;
|
|
||||||
}
|
|
||||||
if (Util.isClient()) {
|
|
||||||
return super.getItemStackDisplayName(stack) + (((BlockColoredLamp) this.block).isOn
|
|
||||||
? " (" + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".onSuffix.desc") + ")"
|
|
||||||
: "");
|
|
||||||
} else {
|
|
||||||
return super.getItemStackDisplayName(stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTranslationKey(ItemStack stack) {
|
|
||||||
return ActuallyBlocks.blockColoredLamp.getTranslationKey() + "_" + ALL_LAMP_TYPES[stack.getItemDamage()].regName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,103 +10,34 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.block.properties.PropertyEnum;
|
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.NonNullList;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.common.IRarity;
|
|
||||||
import net.minecraftforge.fml.relauncher.OnlyIn;
|
|
||||||
|
|
||||||
public class BlockCrystal extends BlockBase {
|
public class BlockCrystal extends BlockBase {
|
||||||
|
|
||||||
public static final TheCrystals[] ALL_CRYSTALS = TheCrystals.values();
|
|
||||||
private static final PropertyEnum<TheCrystals> TYPE = PropertyEnum.create("type", TheCrystals.class);
|
|
||||||
|
|
||||||
private final boolean isEmpowered;
|
private final boolean isEmpowered;
|
||||||
|
|
||||||
public BlockCrystal(boolean isEmpowered) {
|
public BlockCrystal(boolean isEmpowered) {
|
||||||
super(Material.ROCK, name);
|
super(ActuallyBlocks.defaultPickProps(1));
|
||||||
this.isEmpowered = isEmpowered;
|
this.isEmpowered = isEmpowered;
|
||||||
this.setHardness(1.5F);
|
|
||||||
this.setResistance(10.0F);
|
|
||||||
this.setHarvestLevel("pickaxe", 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// public static class TheItemBlock extends ItemBlockBase {
|
||||||
public int damageDropped(BlockState state) {
|
//
|
||||||
return this.getMetaFromState(state);
|
// public TheItemBlock(Block block) {
|
||||||
}
|
// super(block);
|
||||||
|
// this.setHasSubtypes(true);
|
||||||
@Override
|
// this.setMaxDamage(0);
|
||||||
@OnlyIn(Dist.CLIENT)
|
// }
|
||||||
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
|
//
|
||||||
for (int j = 0; j < ALL_CRYSTALS.length; j++) {
|
// @Override
|
||||||
list.add(new ItemStack(this, 1, j));
|
// public String getTranslationKey(ItemStack stack) {
|
||||||
}
|
// return stack.getItemDamage() >= ALL_CRYSTALS.length
|
||||||
}
|
// ? StringUtil.BUGGED_ITEM_NAME
|
||||||
|
// : this.getTranslationKey() + "_" + ALL_CRYSTALS[stack.getItemDamage()].name;
|
||||||
@Override
|
// }
|
||||||
protected ItemBlockBase getItemBlock() {
|
//
|
||||||
return new TheItemBlock(this);
|
// @Override
|
||||||
}
|
// public boolean hasEffect(ItemStack stack) {
|
||||||
|
// return this.block instanceof BlockCrystal && ((BlockCrystal) this.block).isEmpowered;
|
||||||
@Override
|
// }
|
||||||
public void registerRendering() {
|
// }
|
||||||
for (int i = 0; i < ALL_CRYSTALS.length; i++) {
|
|
||||||
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName() + "=" + ALL_CRYSTALS[i].name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getStateFromMeta(int meta) {
|
|
||||||
return this.getDefaultState().withProperty(TYPE, TheCrystals.values()[meta]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetaFromState(BlockState state) {
|
|
||||||
return state.getValue(TYPE).ordinal();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BlockStateContainer createBlockState() {
|
|
||||||
return new BlockStateContainer(this, TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IRarity getRarity(ItemStack stack) {
|
|
||||||
return stack.getItemDamage() >= ALL_CRYSTALS.length
|
|
||||||
? EnumRarity.COMMON
|
|
||||||
: ALL_CRYSTALS[stack.getItemDamage()].rarity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TheItemBlock extends ItemBlockBase {
|
|
||||||
|
|
||||||
public TheItemBlock(Block block) {
|
|
||||||
super(block);
|
|
||||||
this.setHasSubtypes(true);
|
|
||||||
this.setMaxDamage(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTranslationKey(ItemStack stack) {
|
|
||||||
return stack.getItemDamage() >= ALL_CRYSTALS.length
|
|
||||||
? StringUtil.BUGGED_ITEM_NAME
|
|
||||||
: this.getTranslationKey() + "_" + ALL_CRYSTALS[stack.getItemDamage()].name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasEffect(ItemStack stack) {
|
|
||||||
return this.block instanceof BlockCrystal && ((BlockCrystal) this.block).isEmpowered;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,135 +10,29 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
|
||||||
import de.ellpeck.actuallyadditions.mod.gen.WorldGenLushCaves;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.IColorProvidingBlock;
|
import net.minecraft.block.BlockState;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem;
|
|
||||||
import net.minecraft.block.BlockDirectional;
|
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
|
||||||
import net.minecraft.client.renderer.color.IBlockColor;
|
|
||||||
import net.minecraft.client.renderer.color.IItemColor;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.BlockRenderLayer;
|
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.Mirror;
|
|
||||||
import net.minecraft.util.Rotation;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraftforge.fml.relauncher.OnlyIn;
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
|
|
||||||
import java.util.Random;
|
public class BlockCrystalCluster extends FullyDirectionalBlock {
|
||||||
|
|
||||||
public class BlockCrystalCluster extends BlockBase implements IColorProvidingBlock, IColorProvidingItem {
|
|
||||||
|
|
||||||
private final TheCrystals crystal;
|
private final TheCrystals crystal;
|
||||||
|
|
||||||
public BlockCrystalCluster(TheCrystals crystal) {
|
public BlockCrystalCluster(TheCrystals crystal) {
|
||||||
super(Material.GLASS, name);
|
super(Properties.create(Material.GLASS).hardnessAndResistance(0.25F, 1.0F).sound(SoundType.GLASS).setLightLevel(state -> 7));
|
||||||
this.crystal = crystal;
|
this.crystal = crystal;
|
||||||
|
|
||||||
this.setHardness(0.25F);
|
// this.setLightOpacity(1);
|
||||||
this.setResistance(1.0F);
|
|
||||||
this.setSoundType(SoundType.GLASS);
|
|
||||||
this.setLightOpacity(1);
|
|
||||||
this.setLightLevel(0.7F);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFullCube(BlockState state) {
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
return false;
|
return Shapes.CRYSTAL_CLUSTER_SHAPE;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpaqueCube(BlockState state) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getStateForPlacement(World world, BlockPos pos, Direction side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase base) {
|
|
||||||
return this.getStateFromMeta(side.ordinal());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
|
||||||
return EnumRarity.EPIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getStateFromMeta(int meta) {
|
|
||||||
return this.getDefaultState().withProperty(BlockDirectional.FACING, Direction.byIndex(meta));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetaFromState(BlockState state) {
|
|
||||||
return state.getValue(BlockDirectional.FACING).getIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BlockStateContainer createBlockState() {
|
|
||||||
return new BlockStateContainer(this, BlockDirectional.FACING);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState withRotation(BlockState state, Rotation rot) {
|
|
||||||
return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState withMirror(BlockState state, Mirror mirror) {
|
|
||||||
return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public IBlockColor getBlockColor() {
|
|
||||||
return (state, world, pos, tintIndex) -> BlockCrystalCluster.this.crystal.clusterColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockRenderLayer getRenderLayer() {
|
|
||||||
return BlockRenderLayer.TRANSLUCENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public IItemColor getItemColor() {
|
|
||||||
return (stack, tintIndex) -> BlockCrystalCluster.this.crystal.clusterColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Item getItemDropped(BlockState state, Random rand, int fortune) {
|
|
||||||
return InitItems.itemCrystalShard;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int damageDropped(BlockState state) {
|
|
||||||
return ArrayUtils.indexOf(WorldGenLushCaves.CRYSTAL_CLUSTERS, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getPickBlock(BlockState state, RayTraceResult target, World world, BlockPos pos, PlayerEntity player) {
|
|
||||||
return new ItemStack(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int quantityDropped(Random random) {
|
|
||||||
return random.nextInt(5) + 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canSilkHarvest(World world, BlockPos pos, BlockState state, PlayerEntity player) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,34 +10,24 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDirectionalBreaker;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDirectionalBreaker;
|
||||||
import net.minecraft.block.BlockDirectional;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.SoundType;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Mirror;
|
|
||||||
import net.minecraft.util.Rotation;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class BlockDirectionalBreaker extends BlockContainerBase {
|
public class BlockDirectionalBreaker extends FullyDirectionalBlock.Container {
|
||||||
|
|
||||||
public BlockDirectionalBreaker() {
|
public BlockDirectionalBreaker() {
|
||||||
super(Material.ROCK, this.name);
|
super(ActuallyBlocks.defaultPickProps(0));
|
||||||
this.setHarvestLevel("pickaxe", 0);
|
|
||||||
this.setHardness(1.5F);
|
|
||||||
this.setResistance(10.0F);
|
|
||||||
this.setSoundType(SoundType.STONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -46,55 +36,29 @@ public class BlockDirectionalBreaker extends BlockContainerBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||||
if (this.tryToggleRedstone(world, pos, player)) {
|
if (this.tryToggleRedstone(world, pos, player)) {
|
||||||
return true;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
if (!world.isRemote) {
|
|
||||||
TileEntityDirectionalBreaker breaker = (TileEntityDirectionalBreaker) world.getTileEntity(pos);
|
return this.openGui(world, player, pos, TileEntityDirectionalBreaker.class);
|
||||||
if (breaker != null) {
|
|
||||||
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DIRECTIONAL_BREAKER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
return EnumRarity.EPIC;
|
switch (state.get(FACING)) {
|
||||||
}
|
case UP:
|
||||||
|
return Shapes.DirectionalBlockBreakerShapes.SHAPE_U;
|
||||||
@Override
|
case DOWN:
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, EntityLivingBase player, ItemStack stack) {
|
return Shapes.DirectionalBlockBreakerShapes.SHAPE_D;
|
||||||
int rotation = Direction.getDirectionFromEntityLiving(pos, player).ordinal();
|
case EAST:
|
||||||
world.setBlockState(pos, this.getStateFromMeta(rotation), 2);
|
return Shapes.DirectionalBlockBreakerShapes.SHAPE_E;
|
||||||
|
case SOUTH:
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
return Shapes.DirectionalBlockBreakerShapes.SHAPE_S;
|
||||||
}
|
case WEST:
|
||||||
|
return Shapes.DirectionalBlockBreakerShapes.SHAPE_W;
|
||||||
@Override
|
default:
|
||||||
public BlockState getStateFromMeta(int meta) {
|
return Shapes.DirectionalBlockBreakerShapes.SHAPE_N;
|
||||||
return this.getDefaultState().withProperty(BlockDirectional.FACING, Direction.byIndex(meta));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetaFromState(BlockState state) {
|
|
||||||
return state.getValue(BlockDirectional.FACING).getIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BlockStateContainer createBlockState() {
|
|
||||||
return new BlockStateContainer(this, BlockDirectional.FACING);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState withRotation(BlockState state, Rotation rot) {
|
|
||||||
return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState withMirror(BlockState state, Mirror mirror) {
|
|
||||||
return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,43 +14,35 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDisplayStand;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDisplayStand;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.block.state.BlockFaceShape;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class BlockDisplayStand extends BlockContainerBase {
|
public class BlockDisplayStand extends BlockContainerBase {
|
||||||
|
|
||||||
public BlockDisplayStand() {
|
public BlockDisplayStand() {
|
||||||
super(Material.ROCK, this.name);
|
super(ActuallyBlocks.defaultPickProps(0));
|
||||||
|
|
||||||
this.setHarvestLevel("pickaxe", 0);
|
|
||||||
this.setHardness(1.5F);
|
|
||||||
this.setResistance(10.0F);
|
|
||||||
this.setSoundType(SoundType.STONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
public TileEntity createNewTileEntity(IBlockReader worldIn) {
|
||||||
return new TileEntityDisplayStand();
|
return new TileEntityDisplayStand();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||||
return BlockSlabs.AABB_BOTTOM_HALF;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
|
||||||
ItemStack heldItem = player.getHeldItem(hand);
|
ItemStack heldItem = player.getHeldItem(hand);
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
TileEntityDisplayStand stand = (TileEntityDisplayStand) world.getTileEntity(pos);
|
TileEntityDisplayStand stand = (TileEntityDisplayStand) world.getTileEntity(pos);
|
||||||
|
@ -61,10 +53,10 @@ public class BlockDisplayStand extends BlockContainerBase {
|
||||||
ItemStack toPut = heldItem.copy();
|
ItemStack toPut = heldItem.copy();
|
||||||
toPut.setCount(1);
|
toPut.setCount(1);
|
||||||
stand.inv.setStackInSlot(0, toPut);
|
stand.inv.setStackInSlot(0, toPut);
|
||||||
if (!player.capabilities.isCreativeMode) {
|
if (!player.isCreative()) {
|
||||||
heldItem.shrink(1);
|
heldItem.shrink(1);
|
||||||
}
|
}
|
||||||
return true;
|
return ActionResultType.PASS;
|
||||||
} else if (ItemUtil.canBeStacked(heldItem, display)) {
|
} else if (ItemUtil.canBeStacked(heldItem, display)) {
|
||||||
int maxTransfer = Math.min(display.getCount(), heldItem.getMaxStackSize() - heldItem.getCount());
|
int maxTransfer = Math.min(display.getCount(), heldItem.getMaxStackSize() - heldItem.getCount());
|
||||||
if (maxTransfer > 0) {
|
if (maxTransfer > 0) {
|
||||||
|
@ -72,43 +64,25 @@ public class BlockDisplayStand extends BlockContainerBase {
|
||||||
ItemStack newDisplay = display.copy();
|
ItemStack newDisplay = display.copy();
|
||||||
newDisplay.shrink(maxTransfer);
|
newDisplay.shrink(maxTransfer);
|
||||||
stand.inv.setStackInSlot(0, newDisplay);
|
stand.inv.setStackInSlot(0, newDisplay);
|
||||||
return true;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (StackUtil.isValid(display)) {
|
if (StackUtil.isValid(display)) {
|
||||||
player.setHeldItem(hand, display.copy());
|
player.setHeldItem(hand, display.copy());
|
||||||
stand.inv.setStackInSlot(0, StackUtil.getEmpty());
|
stand.inv.setStackInSlot(0, StackUtil.getEmpty());
|
||||||
return true;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return ActionResultType.FAIL;
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOpaqueCube(BlockState state) {
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
return false;
|
return Shapes.DISPLAY_STAND_SHAPE;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isFullCube(BlockState state) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, BlockState state, BlockPos pos, Direction face) {
|
|
||||||
if (face == Direction.DOWN) {
|
|
||||||
return BlockFaceShape.SOLID;
|
|
||||||
}
|
|
||||||
return BlockFaceShape.UNDEFINED;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
|
||||||
return EnumRarity.RARE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,34 +10,22 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper;
|
||||||
import net.minecraft.block.BlockDirectional;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.SoundType;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Mirror;
|
|
||||||
import net.minecraft.util.Rotation;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class BlockDropper extends BlockContainerBase {
|
public class BlockDropper extends FullyDirectionalBlock.Container {
|
||||||
|
|
||||||
public BlockDropper() {
|
public BlockDropper() {
|
||||||
super(Material.ROCK, this.name);
|
super(ActuallyBlocks.defaultPickProps(0));
|
||||||
this.setHarvestLevel("pickaxe", 0);
|
|
||||||
this.setHardness(1.5F);
|
|
||||||
this.setResistance(10.0F);
|
|
||||||
this.setSoundType(SoundType.STONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -46,55 +34,11 @@ public class BlockDropper extends BlockContainerBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||||
if (this.tryToggleRedstone(world, pos, player)) {
|
if (this.tryToggleRedstone(world, pos, player)) {
|
||||||
return true;
|
return ActionResultType.PASS;
|
||||||
}
|
|
||||||
if (!world.isRemote) {
|
|
||||||
TileEntityDropper dropper = (TileEntityDropper) world.getTileEntity(pos);
|
|
||||||
if (dropper != null) {
|
|
||||||
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DROPPER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
return this.openGui(world, player, pos, TileEntityDropper.class);
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
|
||||||
return EnumRarity.RARE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, EntityLivingBase player, ItemStack stack) {
|
|
||||||
int rotation = Direction.getDirectionFromEntityLiving(pos, player).ordinal();
|
|
||||||
world.setBlockState(pos, this.getStateFromMeta(rotation), 2);
|
|
||||||
|
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getStateFromMeta(int meta) {
|
|
||||||
return this.getDefaultState().withProperty(BlockDirectional.FACING, Direction.byIndex(meta));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetaFromState(BlockState state) {
|
|
||||||
return state.getValue(BlockDirectional.FACING).getIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BlockStateContainer createBlockState() {
|
|
||||||
return new BlockStateContainer(this, BlockDirectional.FACING);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState withRotation(BlockState state, Rotation rot) {
|
|
||||||
return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState withMirror(BlockState state, Mirror mirror) {
|
|
||||||
return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,41 +14,34 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEmpowerer;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEmpowerer;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class BlockEmpowerer extends BlockContainerBase {
|
public class BlockEmpowerer extends BlockContainerBase {
|
||||||
|
|
||||||
public BlockEmpowerer() {
|
public BlockEmpowerer() {
|
||||||
super(Material.ROCK, this.name);
|
super(ActuallyBlocks.defaultPickProps(0));
|
||||||
|
|
||||||
this.setHarvestLevel("pickaxe", 0);
|
|
||||||
this.setHardness(1.5F);
|
|
||||||
this.setResistance(10.0F);
|
|
||||||
this.setSoundType(SoundType.STONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
public TileEntity createNewTileEntity(IBlockReader worldIn) {
|
||||||
return new TileEntityEmpowerer();
|
return new TileEntityEmpowerer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||||
return BlockSlabs.AABB_BOTTOM_HALF;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
|
||||||
ItemStack heldItem = player.getHeldItem(hand);
|
ItemStack heldItem = player.getHeldItem(hand);
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
TileEntityEmpowerer empowerer = (TileEntityEmpowerer) world.getTileEntity(pos);
|
TileEntityEmpowerer empowerer = (TileEntityEmpowerer) world.getTileEntity(pos);
|
||||||
|
@ -59,10 +52,10 @@ public class BlockEmpowerer extends BlockContainerBase {
|
||||||
ItemStack toPut = heldItem.copy();
|
ItemStack toPut = heldItem.copy();
|
||||||
toPut.setCount(1);
|
toPut.setCount(1);
|
||||||
empowerer.inv.setStackInSlot(0, toPut);
|
empowerer.inv.setStackInSlot(0, toPut);
|
||||||
if (!player.capabilities.isCreativeMode) {
|
if (!player.isCreative()) {
|
||||||
heldItem.shrink(1);
|
heldItem.shrink(1);
|
||||||
}
|
}
|
||||||
return true;
|
return ActionResultType.PASS;
|
||||||
} else if (ItemUtil.canBeStacked(heldItem, stackThere)) {
|
} else if (ItemUtil.canBeStacked(heldItem, stackThere)) {
|
||||||
int maxTransfer = Math.min(stackThere.getCount(), heldItem.getMaxStackSize() - heldItem.getCount());
|
int maxTransfer = Math.min(stackThere.getCount(), heldItem.getMaxStackSize() - heldItem.getCount());
|
||||||
if (maxTransfer > 0) {
|
if (maxTransfer > 0) {
|
||||||
|
@ -70,30 +63,25 @@ public class BlockEmpowerer extends BlockContainerBase {
|
||||||
ItemStack newStackThere = stackThere.copy();
|
ItemStack newStackThere = stackThere.copy();
|
||||||
newStackThere = StackUtil.shrink(newStackThere, maxTransfer);
|
newStackThere = StackUtil.shrink(newStackThere, maxTransfer);
|
||||||
empowerer.inv.setStackInSlot(0, newStackThere);
|
empowerer.inv.setStackInSlot(0, newStackThere);
|
||||||
return true;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (StackUtil.isValid(stackThere)) {
|
if (StackUtil.isValid(stackThere)) {
|
||||||
player.setHeldItem(hand, stackThere.copy());
|
player.setHeldItem(hand, stackThere.copy());
|
||||||
empowerer.inv.setStackInSlot(0, StackUtil.getEmpty());
|
empowerer.inv.setStackInSlot(0, StackUtil.getEmpty());
|
||||||
return true;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return ActionResultType.FAIL;
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOpaqueCube(BlockState state) {
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
return false;
|
return Shapes.EMPOWERER_SHAPE;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
|
||||||
return EnumRarity.RARE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,32 +10,27 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class BlockEnergizer extends BlockContainerBase {
|
public class BlockEnergizer extends BlockContainerBase {
|
||||||
|
|
||||||
private final boolean isEnergizer;
|
private final boolean isEnergizer;
|
||||||
|
|
||||||
public BlockEnergizer(boolean isEnergizer) {
|
public BlockEnergizer(boolean isEnergizer) {
|
||||||
super(Material.ROCK, this.name);
|
super(ActuallyBlocks.defaultPickProps(0, 2.0F, 10.0F));
|
||||||
this.isEnergizer = isEnergizer;
|
this.isEnergizer = isEnergizer;
|
||||||
this.setHarvestLevel("pickaxe", 0);
|
|
||||||
this.setHardness(2.0F);
|
|
||||||
this.setResistance(10.0F);
|
|
||||||
this.setSoundType(SoundType.STONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -46,26 +41,16 @@ public class BlockEnergizer extends BlockContainerBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||||
if (!world.isRemote) {
|
|
||||||
if (this.isEnergizer) {
|
if (this.isEnergizer) {
|
||||||
TileEntityEnergizer energizer = (TileEntityEnergizer) world.getTileEntity(pos);
|
return this.openGui(world, player, pos, TileEntityEnergizer.class);
|
||||||
if (energizer != null) {
|
|
||||||
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.ENERGIZER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
TileEntityEnervator energizer = (TileEntityEnervator) world.getTileEntity(pos);
|
return this.openGui(world, player, pos, TileEntityEnervator.class);
|
||||||
if (energizer != null) {
|
|
||||||
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.ENERVATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
return EnumRarity.EPIC;
|
return Shapes.ENERGIZER_SHAPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
/*
|
|
||||||
* This file ("BlockFishingNet.java") is part of the Actually Additions mod for Minecraft.
|
|
||||||
* It is created and owned by Ellpeck and distributed
|
|
||||||
* under the Actually Additions License to be found at
|
|
||||||
* http://ellpeck.de/actaddlicense
|
|
||||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
||||||
*
|
|
||||||
* © 2015-2017 Ellpeck
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
|
||||||
import net.minecraft.block.SoundType;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
|
|
||||||
public class BlockFishingNet extends BlockContainerBase {
|
|
||||||
|
|
||||||
private static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 1, 0.0625, 1);
|
|
||||||
|
|
||||||
public BlockFishingNet() {
|
|
||||||
super(Material.WOOD, this.name);
|
|
||||||
this.setHarvestLevel("axe", 0);
|
|
||||||
this.setHardness(0.5F);
|
|
||||||
this.setResistance(3.0F);
|
|
||||||
this.setSoundType(SoundType.WOOD);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
|
||||||
return AABB;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(IBlockReader worldIn) {
|
|
||||||
return new TileEntityFishingNet();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isFullCube(BlockState state) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpaqueCube(BlockState state) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
|
||||||
return EnumRarity.RARE;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,124 +0,0 @@
|
||||||
/*
|
|
||||||
* This file ("BlockSmileyCloud.java") is part of the Actually Additions mod for Minecraft.
|
|
||||||
* It is created and owned by Ellpeck and distributed
|
|
||||||
* under the Actually Additions License to be found at
|
|
||||||
* http://ellpeck.de/actaddlicense
|
|
||||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
||||||
*
|
|
||||||
* © 2015-2017 Ellpeck
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud;
|
|
||||||
import net.minecraft.block.BlockHorizontal;
|
|
||||||
import net.minecraft.block.SoundType;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.Hand;
|
|
||||||
import net.minecraft.util.Mirror;
|
|
||||||
import net.minecraft.util.Rotation;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.fml.relauncher.OnlyIn;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class BlockSmileyCloud extends BlockContainerBase {
|
|
||||||
|
|
||||||
public BlockSmileyCloud() {
|
|
||||||
super(Material.CLOTH, this.name);
|
|
||||||
this.setHardness(0.5F);
|
|
||||||
this.setResistance(5.0F);
|
|
||||||
this.setSoundType(SoundType.CLOTH);
|
|
||||||
this.setTickRandomly(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isFullCube(BlockState state) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpaqueCube(BlockState state) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random rand) {
|
|
||||||
if (world.rand.nextInt(30) == 0) {
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
double d = world.rand.nextGaussian() * 0.02D;
|
|
||||||
double d1 = world.rand.nextGaussian() * 0.02D;
|
|
||||||
double d2 = world.rand.nextGaussian() * 0.02D;
|
|
||||||
world.spawnParticle(EnumParticleTypes.HEART, pos.getX() + world.rand.nextFloat(), pos.getY() + 0.65 + world.rand.nextFloat(), pos.getZ() + world.rand.nextFloat(), d, d1, d2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction f6, float f7, float f8, float f9) {
|
|
||||||
if (!world.isRemote) {
|
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
|
||||||
if (tile instanceof TileEntitySmileyCloud) {
|
|
||||||
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.CLOUD.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
|
||||||
|
|
||||||
//TheAchievements.NAME_SMILEY_CLOUD.get(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World world, int meta) {
|
|
||||||
return new TileEntitySmileyCloud();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
|
||||||
return EnumRarity.RARE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, EntityLivingBase player, ItemStack stack) {
|
|
||||||
world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2);
|
|
||||||
|
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getStateFromMeta(int meta) {
|
|
||||||
return this.getDefaultState().withProperty(BlockHorizontal.FACING, Direction.byHorizontalIndex(meta));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetaFromState(BlockState state) {
|
|
||||||
return state.getValue(BlockHorizontal.FACING).getHorizontalIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BlockStateContainer createBlockState() {
|
|
||||||
return new BlockStateContainer(this, BlockHorizontal.FACING);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState withRotation(BlockState state, Rotation rot) {
|
|
||||||
return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState withMirror(BlockState state, Mirror mirror) {
|
|
||||||
return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING)));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,135 +0,0 @@
|
||||||
/*
|
|
||||||
* This file ("BlockTreasureChest.java") is part of the Actually Additions mod for Minecraft.
|
|
||||||
* It is created and owned by Ellpeck and distributed
|
|
||||||
* under the Actually Additions License to be found at
|
|
||||||
* http://ellpeck.de/actaddlicense
|
|
||||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
||||||
*
|
|
||||||
* © 2015-2017 Ellpeck
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
|
||||||
import net.minecraft.block.BlockHorizontal;
|
|
||||||
import net.minecraft.block.SoundType;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.init.Items;
|
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.*;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.fml.relauncher.OnlyIn;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class BlockTreasureChest extends BlockBase {
|
|
||||||
|
|
||||||
public BlockTreasureChest() {
|
|
||||||
super(Material.WOOD, name);
|
|
||||||
this.setHarvestLevel("axe", 0);
|
|
||||||
this.setHardness(300.0F);
|
|
||||||
this.setResistance(50.0F);
|
|
||||||
this.setSoundType(SoundType.WOOD);
|
|
||||||
this.setTickRandomly(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random rand) {
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
for (float f = 0; f <= 3; f += 0.5) {
|
|
||||||
float particleX = rand.nextFloat();
|
|
||||||
float particleZ = rand.nextFloat();
|
|
||||||
world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, (double) pos.getX() + particleX, (double) pos.getY() + f + 1, (double) pos.getZ() + particleZ, 0.0D, 0.2D, 0.0D);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Item getItemDropped(BlockState state, Random rand, int par3) {
|
|
||||||
return Items.AIR;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
|
||||||
if (!world.isRemote) {
|
|
||||||
world.playSound(null, pos, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.2F, world.rand.nextFloat() * 0.1F + 0.9F);
|
|
||||||
this.dropItems(world, pos);
|
|
||||||
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
|
||||||
|
|
||||||
//TheAchievements.OPEN_TREASURE_CHEST.get(player);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, EntityLivingBase player, ItemStack stack) {
|
|
||||||
world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2);
|
|
||||||
|
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canSilkHarvest(World world, BlockPos pos, BlockState state, PlayerEntity player) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void dropItems(World world, BlockPos pos) {
|
|
||||||
for (int i = 0; i < MathHelper.getInt(world.rand, 3, 6); i++) {
|
|
||||||
TreasureChestLoot theReturn = WeightedRandom.getRandomItem(world.rand, ActuallyAdditionsAPI.TREASURE_CHEST_LOOT);
|
|
||||||
ItemStack itemStack = theReturn.returnItem.copy();
|
|
||||||
itemStack.setCount(MathHelper.getInt(world.rand, theReturn.minAmount, theReturn.maxAmount));
|
|
||||||
|
|
||||||
float dX = world.rand.nextFloat() * 0.8F + 0.1F;
|
|
||||||
float dY = world.rand.nextFloat() * 0.8F + 0.1F;
|
|
||||||
float dZ = world.rand.nextFloat() * 0.8F + 0.1F;
|
|
||||||
EntityItem entityItem = new EntityItem(world, pos.getX() + dX, pos.getY() + dY, pos.getZ() + dZ, itemStack);
|
|
||||||
float factor = 0.05F;
|
|
||||||
entityItem.motionX = world.rand.nextGaussian() * factor;
|
|
||||||
entityItem.motionY = world.rand.nextGaussian() * factor + 0.2F;
|
|
||||||
entityItem.motionZ = world.rand.nextGaussian() * factor;
|
|
||||||
world.spawnEntity(entityItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
|
||||||
return EnumRarity.EPIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getStateFromMeta(int meta) {
|
|
||||||
return this.getDefaultState().withProperty(BlockHorizontal.FACING, Direction.byHorizontalIndex(meta));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetaFromState(BlockState state) {
|
|
||||||
return state.getValue(BlockHorizontal.FACING).getHorizontalIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BlockStateContainer createBlockState() {
|
|
||||||
return new BlockStateContainer(this, BlockHorizontal.FACING);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState withRotation(BlockState state, Rotation rot) {
|
|
||||||
return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState withMirror(BlockState state, Mirror mirror) {
|
|
||||||
return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING)));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -23,6 +23,63 @@ public class Shapes {
|
||||||
Block.makeCuboidShape(0.9, 15.5, 12.9, 3.1, 16, 15.1)
|
Block.makeCuboidShape(0.9, 15.5, 12.9, 3.1, 16, 15.1)
|
||||||
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||||
|
|
||||||
|
public static final VoxelShape CRYSTAL_CLUSTER_SHAPE = Stream.of(
|
||||||
|
Block.makeCuboidShape(5, 4, 5, 10, 19, 10), Block.makeCuboidShape(4, 0, 4, 11, 5, 11),
|
||||||
|
Block.makeCuboidShape(3, 0, 3, 5, 4, 5), Block.makeCuboidShape(10, 0, 3, 12, 2, 5),
|
||||||
|
Block.makeCuboidShape(12, 0, 4, 13, 1, 5), Block.makeCuboidShape(11, 0, 5, 12, 1, 6),
|
||||||
|
Block.makeCuboidShape(10, 0, 10, 12, 3, 12), Block.makeCuboidShape(3, 0, 10, 5, 1, 12),
|
||||||
|
Block.makeCuboidShape(9, 0, 3, 10, 3, 4), Block.makeCuboidShape(8, 0, 2, 11, 1, 4),
|
||||||
|
Block.makeCuboidShape(4, 0, 2, 5, 2, 3), Block.makeCuboidShape(5, 0, 3, 7, 1, 4),
|
||||||
|
Block.makeCuboidShape(2, 0, 4, 4, 1, 6), Block.makeCuboidShape(3, 0, 5, 4, 3, 6.5),
|
||||||
|
Block.makeCuboidShape(3, 0, 9, 4, 2, 10), Block.makeCuboidShape(2, 0, 8, 4, 1, 10),
|
||||||
|
Block.makeCuboidShape(5, 0, 11, 7, 2, 13), Block.makeCuboidShape(7, 0, 11, 11, 1, 13),
|
||||||
|
Block.makeCuboidShape(10, 0, 9, 13, 1, 11), Block.makeCuboidShape(11, 0, 7, 12, 3, 9)
|
||||||
|
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||||
|
|
||||||
|
static final VoxelShape DISPLAY_STAND_SHAPE = Stream.of(
|
||||||
|
Block.makeCuboidShape(1, 7, 0, 15, 8, 1), Block.makeCuboidShape(0, 0, 0, 16, 1, 16),
|
||||||
|
Block.makeCuboidShape(1, 1, 1, 15, 7, 15), Block.makeCuboidShape(6, 7, 6, 10, 9, 10),
|
||||||
|
Block.makeCuboidShape(0, 1, 0, 1, 7, 1), Block.makeCuboidShape(15, 1, 0, 16, 7, 1),
|
||||||
|
Block.makeCuboidShape(15, 1, 15, 16, 7, 16), Block.makeCuboidShape(0, 1, 15, 1, 7, 16),
|
||||||
|
Block.makeCuboidShape(0, 7, 0, 1, 8, 16), Block.makeCuboidShape(15, 7, 0, 16, 8, 16),
|
||||||
|
Block.makeCuboidShape(1, 7, 15, 15, 8, 16), Block.makeCuboidShape(5, 7, 5, 6, 9, 6),
|
||||||
|
Block.makeCuboidShape(5, 7, 10, 6, 9, 11), Block.makeCuboidShape(10, 7, 10, 11, 9, 11),
|
||||||
|
Block.makeCuboidShape(10, 7, 5, 11, 9, 6)
|
||||||
|
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||||
|
|
||||||
|
|
||||||
|
static final VoxelShape EMPOWERER_SHAPE = Stream.of(
|
||||||
|
Block.makeCuboidShape(0, 0, 0, 16, 1, 16), Block.makeCuboidShape(1, 1, 1, 15, 6, 15),
|
||||||
|
Block.makeCuboidShape(1, 6, 1, 15, 7, 15), Block.makeCuboidShape(0, 7, 0, 16, 8, 1),
|
||||||
|
Block.makeCuboidShape(0, 7, 15, 16, 8, 16), Block.makeCuboidShape(0, 7, 1, 1, 8, 15),
|
||||||
|
Block.makeCuboidShape(15, 7, 1, 16, 8, 15), Block.makeCuboidShape(4, 7, 4, 12, 9, 12),
|
||||||
|
Block.makeCuboidShape(0, 1, 0, 1, 7, 1), Block.makeCuboidShape(15, 1, 0, 16, 7, 1),
|
||||||
|
Block.makeCuboidShape(15, 1, 15, 16, 7, 16), Block.makeCuboidShape(0, 1, 15, 1, 7, 16),
|
||||||
|
Block.makeCuboidShape(3, 7, 4, 4, 8, 5), Block.makeCuboidShape(3, 7, 11, 4, 8, 12),
|
||||||
|
Block.makeCuboidShape(4, 7, 12, 5, 8, 13), Block.makeCuboidShape(11, 7, 12, 12, 8, 13),
|
||||||
|
Block.makeCuboidShape(12, 7, 11, 13, 8, 12), Block.makeCuboidShape(12, 7, 4, 13, 8, 5),
|
||||||
|
Block.makeCuboidShape(11, 7, 3, 12, 8, 4), Block.makeCuboidShape(4, 7, 3, 5, 8, 4)
|
||||||
|
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||||
|
|
||||||
|
static final VoxelShape ENERGIZER_SHAPE = Stream.of(
|
||||||
|
Block.makeCuboidShape(0, 15, 0, 1, 16, 16), Block.makeCuboidShape(15, 15, 0, 16, 16, 16),
|
||||||
|
Block.makeCuboidShape(1, 15, 0, 15, 16, 1), Block.makeCuboidShape(1, 15, 15, 15, 16, 16),
|
||||||
|
Block.makeCuboidShape(1, 0, 15, 15, 1, 16), Block.makeCuboidShape(1, 0, 0, 15, 1, 1),
|
||||||
|
Block.makeCuboidShape(15, 0, 0, 16, 1, 16), Block.makeCuboidShape(0, 0, 0, 1, 1, 16),
|
||||||
|
Block.makeCuboidShape(0, 1, 15, 1, 15, 16), Block.makeCuboidShape(15, 1, 15, 16, 15, 16),
|
||||||
|
Block.makeCuboidShape(15, 1, 0, 16, 15, 1), Block.makeCuboidShape(0, 1, 0, 1, 15, 1),
|
||||||
|
Block.makeCuboidShape(1, 14, 1, 15, 15, 15), Block.makeCuboidShape(1, 1, 1, 15, 2, 15),
|
||||||
|
Block.makeCuboidShape(14, 2, 1, 15, 14, 15), Block.makeCuboidShape(1, 2, 1, 2, 14, 15),
|
||||||
|
Block.makeCuboidShape(2, 2, 14, 14, 14, 15), Block.makeCuboidShape(2, 2, 1, 14, 14, 2),
|
||||||
|
Block.makeCuboidShape(9, 3, 0, 13, 4, 1), Block.makeCuboidShape(3, 3, 15, 7, 4, 16),
|
||||||
|
Block.makeCuboidShape(9, 12, 0, 13, 13, 1), Block.makeCuboidShape(3, 12, 15, 7, 13, 16),
|
||||||
|
Block.makeCuboidShape(10, 4, 0, 12, 12, 1), Block.makeCuboidShape(4, 4, 15, 6, 12, 16),
|
||||||
|
Block.makeCuboidShape(0, 3, 3, 1, 4, 7), Block.makeCuboidShape(15, 3, 9, 16, 4, 13),
|
||||||
|
Block.makeCuboidShape(0, 12, 3, 1, 13, 7), Block.makeCuboidShape(15, 12, 9, 16, 13, 13),
|
||||||
|
Block.makeCuboidShape(0, 4, 4, 1, 12, 6), Block.makeCuboidShape(15, 4, 10, 16, 12, 12)
|
||||||
|
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||||
|
|
||||||
|
|
||||||
static final class CoalGeneratorShapes {
|
static final class CoalGeneratorShapes {
|
||||||
static final VoxelShape NORTH = Stream.of(
|
static final VoxelShape NORTH = Stream.of(
|
||||||
Block.makeCuboidShape(0, 15, 0, 1, 16, 16), Block.makeCuboidShape(15, 15, 0, 16, 16, 16),
|
Block.makeCuboidShape(0, 15, 0, 1, 16, 16), Block.makeCuboidShape(15, 15, 0, 16, 16, 16),
|
||||||
|
@ -182,4 +239,85 @@ public class Shapes {
|
||||||
Block.makeCuboidShape(11, 11, 12, 13, 12, 14), Block.makeCuboidShape(11, 1, 14, 13, 12, 15)
|
Block.makeCuboidShape(11, 11, 12, 13, 12, 14), Block.makeCuboidShape(11, 1, 14, 13, 12, 15)
|
||||||
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class DirectionalBlockBreakerShapes {
|
||||||
|
static final VoxelShape SHAPE_U = Stream.of(
|
||||||
|
Block.makeCuboidShape(1, 1, 1, 15, 15, 15), Block.makeCuboidShape(0, 15, 15, 16, 16, 16),
|
||||||
|
Block.makeCuboidShape(0, 15, 0, 16, 16, 1), Block.makeCuboidShape(0, 0, 15, 16, 1, 16),
|
||||||
|
Block.makeCuboidShape(0, 0, 0, 16, 1, 1), Block.makeCuboidShape(0, 1, 15, 1, 15, 16),
|
||||||
|
Block.makeCuboidShape(0, 1, 0, 1, 15, 1), Block.makeCuboidShape(15, 1, 15, 16, 15, 16),
|
||||||
|
Block.makeCuboidShape(15, 1, 0, 16, 15, 1), Block.makeCuboidShape(0, 15, 1, 1, 16, 15),
|
||||||
|
Block.makeCuboidShape(0, 0, 1, 1, 1, 15), Block.makeCuboidShape(15, 0, 1, 16, 1, 15),
|
||||||
|
Block.makeCuboidShape(15, 15, 1, 16, 16, 15), Block.makeCuboidShape(15, 3, 9, 16, 13, 13),
|
||||||
|
Block.makeCuboidShape(15, 3, 3, 16, 13, 7), Block.makeCuboidShape(0, 3, 9, 1, 13, 13),
|
||||||
|
Block.makeCuboidShape(0, 3, 3, 1, 13, 7), Block.makeCuboidShape(5, 15, 5, 11, 16, 11),
|
||||||
|
Block.makeCuboidShape(3, 15, 6, 5, 16, 10), Block.makeCuboidShape(11, 15, 6, 13, 16, 10)
|
||||||
|
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||||
|
|
||||||
|
static final VoxelShape SHAPE_D = Stream.of(
|
||||||
|
Block.makeCuboidShape(1, 1, 1, 15, 15, 15), Block.makeCuboidShape(0, 0, 0, 16, 1, 1),
|
||||||
|
Block.makeCuboidShape(0, 0, 15, 16, 1, 16), Block.makeCuboidShape(0, 15, 0, 16, 16, 1),
|
||||||
|
Block.makeCuboidShape(0, 15, 15, 16, 16, 16), Block.makeCuboidShape(0, 1, 0, 1, 15, 1),
|
||||||
|
Block.makeCuboidShape(0, 1, 15, 1, 15, 16), Block.makeCuboidShape(15, 1, 0, 16, 15, 1),
|
||||||
|
Block.makeCuboidShape(15, 1, 15, 16, 15, 16), Block.makeCuboidShape(0, 0, 1, 1, 1, 15),
|
||||||
|
Block.makeCuboidShape(0, 15, 1, 1, 16, 15), Block.makeCuboidShape(15, 15, 1, 16, 16, 15),
|
||||||
|
Block.makeCuboidShape(15, 0, 1, 16, 1, 15), Block.makeCuboidShape(15, 3, 3, 16, 13, 7),
|
||||||
|
Block.makeCuboidShape(15, 3, 9, 16, 13, 13), Block.makeCuboidShape(0, 3, 3, 1, 13, 7),
|
||||||
|
Block.makeCuboidShape(0, 3, 9, 1, 13, 13), Block.makeCuboidShape(5, 0, 5, 11, 1, 11),
|
||||||
|
Block.makeCuboidShape(3, 0, 6, 5, 1, 10), Block.makeCuboidShape(11, 0, 6, 13, 1, 10)
|
||||||
|
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||||
|
|
||||||
|
static final VoxelShape SHAPE_N = Stream.of(
|
||||||
|
Block.makeCuboidShape(1, 1, 1, 15, 15, 15), Block.makeCuboidShape(0, 15, 0, 16, 16, 1),
|
||||||
|
Block.makeCuboidShape(0, 0, 0, 16, 1, 1), Block.makeCuboidShape(0, 15, 15, 16, 16, 16),
|
||||||
|
Block.makeCuboidShape(0, 0, 15, 16, 1, 16), Block.makeCuboidShape(0, 15, 1, 1, 16, 15),
|
||||||
|
Block.makeCuboidShape(0, 0, 1, 1, 1, 15), Block.makeCuboidShape(15, 15, 1, 16, 16, 15),
|
||||||
|
Block.makeCuboidShape(15, 0, 1, 16, 1, 15), Block.makeCuboidShape(0, 1, 0, 1, 15, 1),
|
||||||
|
Block.makeCuboidShape(0, 1, 15, 1, 15, 16), Block.makeCuboidShape(15, 1, 15, 16, 15, 16),
|
||||||
|
Block.makeCuboidShape(15, 1, 0, 16, 15, 1), Block.makeCuboidShape(15, 9, 3, 16, 13, 13),
|
||||||
|
Block.makeCuboidShape(15, 3, 3, 16, 7, 13), Block.makeCuboidShape(0, 9, 3, 1, 13, 13),
|
||||||
|
Block.makeCuboidShape(0, 3, 3, 1, 7, 13), Block.makeCuboidShape(5, 5, 0, 11, 11, 1),
|
||||||
|
Block.makeCuboidShape(3, 6, 0, 5, 10, 1), Block.makeCuboidShape(11, 6, 0, 13, 10, 1)
|
||||||
|
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||||
|
|
||||||
|
|
||||||
|
static final VoxelShape SHAPE_E = Stream.of(
|
||||||
|
Block.makeCuboidShape(1, 1, 1, 15, 15, 15), Block.makeCuboidShape(15, 15, 0, 16, 16, 16),
|
||||||
|
Block.makeCuboidShape(15, 0, 0, 16, 1, 16), Block.makeCuboidShape(0, 15, 0, 1, 16, 16),
|
||||||
|
Block.makeCuboidShape(0, 0, 0, 1, 1, 16), Block.makeCuboidShape(1, 15, 0, 15, 16, 1),
|
||||||
|
Block.makeCuboidShape(1, 0, 0, 15, 1, 1), Block.makeCuboidShape(1, 15, 15, 15, 16, 16),
|
||||||
|
Block.makeCuboidShape(1, 0, 15, 15, 1, 16), Block.makeCuboidShape(15, 1, 0, 16, 15, 1),
|
||||||
|
Block.makeCuboidShape(0, 1, 0, 1, 15, 1), Block.makeCuboidShape(0, 1, 15, 1, 15, 16),
|
||||||
|
Block.makeCuboidShape(15, 1, 15, 16, 15, 16), Block.makeCuboidShape(3, 9, 15, 13, 13, 16),
|
||||||
|
Block.makeCuboidShape(3, 3, 15, 13, 7, 16), Block.makeCuboidShape(3, 9, 0, 13, 13, 1),
|
||||||
|
Block.makeCuboidShape(3, 3, 0, 13, 7, 1), Block.makeCuboidShape(15, 5, 5, 16, 11, 11),
|
||||||
|
Block.makeCuboidShape(15, 6, 3, 16, 10, 5), Block.makeCuboidShape(15, 6, 11, 16, 10, 13)
|
||||||
|
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||||
|
|
||||||
|
static final VoxelShape SHAPE_S = Stream.of(
|
||||||
|
Block.makeCuboidShape(1, 1, 1, 15, 15, 15), Block.makeCuboidShape(0, 15, 15, 16, 16, 16),
|
||||||
|
Block.makeCuboidShape(0, 0, 15, 16, 1, 16), Block.makeCuboidShape(0, 15, 0, 16, 16, 1),
|
||||||
|
Block.makeCuboidShape(0, 0, 0, 16, 1, 1), Block.makeCuboidShape(15, 15, 1, 16, 16, 15),
|
||||||
|
Block.makeCuboidShape(15, 0, 1, 16, 1, 15), Block.makeCuboidShape(0, 15, 1, 1, 16, 15),
|
||||||
|
Block.makeCuboidShape(0, 0, 1, 1, 1, 15), Block.makeCuboidShape(15, 1, 15, 16, 15, 16),
|
||||||
|
Block.makeCuboidShape(15, 1, 0, 16, 15, 1), Block.makeCuboidShape(0, 1, 0, 1, 15, 1),
|
||||||
|
Block.makeCuboidShape(0, 1, 15, 1, 15, 16), Block.makeCuboidShape(0, 9, 3, 1, 13, 13),
|
||||||
|
Block.makeCuboidShape(0, 3, 3, 1, 7, 13), Block.makeCuboidShape(15, 9, 3, 16, 13, 13),
|
||||||
|
Block.makeCuboidShape(15, 3, 3, 16, 7, 13), Block.makeCuboidShape(5, 5, 15, 11, 11, 16),
|
||||||
|
Block.makeCuboidShape(11, 6, 15, 13, 10, 16), Block.makeCuboidShape(3, 6, 15, 5, 10, 16)
|
||||||
|
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||||
|
|
||||||
|
static final VoxelShape SHAPE_W = Stream.of(
|
||||||
|
Block.makeCuboidShape(1, 1, 1, 15, 15, 15), Block.makeCuboidShape(0, 15, 0, 1, 16, 16),
|
||||||
|
Block.makeCuboidShape(0, 0, 0, 1, 1, 16), Block.makeCuboidShape(15, 15, 0, 16, 16, 16),
|
||||||
|
Block.makeCuboidShape(15, 0, 0, 16, 1, 16), Block.makeCuboidShape(1, 15, 15, 15, 16, 16),
|
||||||
|
Block.makeCuboidShape(1, 0, 15, 15, 1, 16), Block.makeCuboidShape(1, 15, 0, 15, 16, 1),
|
||||||
|
Block.makeCuboidShape(1, 0, 0, 15, 1, 1), Block.makeCuboidShape(0, 1, 15, 1, 15, 16),
|
||||||
|
Block.makeCuboidShape(15, 1, 15, 16, 15, 16), Block.makeCuboidShape(15, 1, 0, 16, 15, 1),
|
||||||
|
Block.makeCuboidShape(0, 1, 0, 1, 15, 1), Block.makeCuboidShape(3, 9, 0, 13, 13, 1),
|
||||||
|
Block.makeCuboidShape(3, 3, 0, 13, 7, 1), Block.makeCuboidShape(3, 9, 15, 13, 13, 16),
|
||||||
|
Block.makeCuboidShape(3, 3, 15, 13, 7, 16), Block.makeCuboidShape(0, 5, 5, 1, 11, 11),
|
||||||
|
Block.makeCuboidShape(0, 6, 11, 1, 10, 13), Block.makeCuboidShape(0, 6, 3, 1, 10, 5)
|
||||||
|
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,10 +21,13 @@ import net.minecraft.block.ContainerBlock;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.fluid.FluidState;
|
import net.minecraft.fluid.FluidState;
|
||||||
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
@ -34,6 +37,7 @@ import net.minecraft.world.World;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraftforge.fluids.FluidUtil;
|
import net.minecraftforge.fluids.FluidUtil;
|
||||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
||||||
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -43,6 +47,18 @@ public abstract class BlockContainerBase extends ContainerBlock {
|
||||||
super(properties);
|
super(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionResultType openGui(World world, PlayerEntity player, BlockPos pos, Class<? extends INamedContainerProvider> expectedInstance) {
|
||||||
|
if (!world.isRemote) {
|
||||||
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
|
if (tile != null && tile.getClass().isInstance(expectedInstance)) {
|
||||||
|
NetworkHooks.openGui((ServerPlayerEntity) player, (INamedContainerProvider) tile, pos);
|
||||||
|
}
|
||||||
|
return ActionResultType.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ActionResultType.PASS;
|
||||||
|
}
|
||||||
|
|
||||||
private void dropInventory(World world, BlockPos position) {
|
private void dropInventory(World world, BlockPos position) {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
TileEntity aTile = world.getTileEntity(position);
|
TileEntity aTile = world.getTileEntity(position);
|
||||||
|
|
|
@ -12,21 +12,23 @@ import net.minecraft.util.Direction;
|
||||||
* Wrapper for Fully Direction block states extending from our base blocks. It's not super nice but it'll do.
|
* Wrapper for Fully Direction block states extending from our base blocks. It's not super nice but it'll do.
|
||||||
*/
|
*/
|
||||||
public abstract class FullyDirectionalBlock extends BlockBase {
|
public abstract class FullyDirectionalBlock extends BlockBase {
|
||||||
// public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
||||||
//
|
|
||||||
public FullyDirectionalBlock(Properties properties) {
|
public FullyDirectionalBlock(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
|
this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||||
|
return this.getDefaultState().with(FACING, context.getNearestLookingDirection().getOpposite());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||||
|
builder.add(FACING);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public BlockState getStateForPlacement(BlockItemUseContext context) {
|
|
||||||
// return this.getDefaultState().with(FACING, context.getNearestLookingDirection().getOpposite());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
|
||||||
// builder.add(FACING);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public abstract static class Container extends BlockContainerBase {
|
public abstract static class Container extends BlockContainerBase {
|
||||||
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
||||||
|
|
|
@ -157,7 +157,7 @@ public final class InitBooklet {
|
||||||
new BookletChapter("banners", ActuallyAdditionsAPI.entryMisc, new ItemStack(Items.BLUE_BANNER, 1), new PageTextOnly(1));
|
new BookletChapter("banners", ActuallyAdditionsAPI.entryMisc, new ItemStack(Items.BLUE_BANNER, 1), new PageTextOnly(1));
|
||||||
new BookletChapter("miscDecorStuffsAndThings", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyBlocks.blockTestifiBucksGreenWall), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeWhiteWall).setNoText(), new PageReconstructor(3, LensRecipeHandler.recipeGreenWall).setNoText());
|
new BookletChapter("miscDecorStuffsAndThings", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyBlocks.blockTestifiBucksGreenWall), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeWhiteWall).setNoText(), new PageReconstructor(3, LensRecipeHandler.recipeGreenWall).setNoText());
|
||||||
chaptersIntroduction[3] = new BookletChapter("quartz", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemMisc.get(), 1, TheMiscItems.QUARTZ.ordinal()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal())).addTextReplacement("<lowest>", AAWorldGen.QUARTZ_MIN).addTextReplacement("<highest>", AAWorldGen.QUARTZ_MAX), new PageTextOnly(2).addItemsToPage(new ItemStack(InitItems.itemMisc.get(), 1, TheMiscItems.QUARTZ.ordinal())), new PageCrafting(3, BlockCrafting.recipeQuartzBlock).setNoText(), new PageCrafting(4, BlockCrafting.recipeQuartzPillar).setNoText(), new PageCrafting(5, BlockCrafting.recipeQuartzChiseled).setNoText());
|
chaptersIntroduction[3] = new BookletChapter("quartz", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemMisc.get(), 1, TheMiscItems.QUARTZ.ordinal()), new PageTextOnly(1).addItemsToPage(new ItemStack(ActuallyBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal())).addTextReplacement("<lowest>", AAWorldGen.QUARTZ_MIN).addTextReplacement("<highest>", AAWorldGen.QUARTZ_MAX), new PageTextOnly(2).addItemsToPage(new ItemStack(InitItems.itemMisc.get(), 1, TheMiscItems.QUARTZ.ordinal())), new PageCrafting(3, BlockCrafting.recipeQuartzBlock).setNoText(), new PageCrafting(4, BlockCrafting.recipeQuartzPillar).setNoText(), new PageCrafting(5, BlockCrafting.recipeQuartzChiseled).setNoText());
|
||||||
new BookletChapter("cloud", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyBlocks.blockSmileyCloud), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeSmileyCloud).setWildcard()).setSpecial();
|
// new BookletChapter("cloud", ActuallyAdditionsAPI.entryMisc, new ItemStack(ActuallyBlocks.blockSmileyCloud), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeSmileyCloud).setWildcard()).setSpecial();
|
||||||
new BookletChapter("coalStuff", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemMisc.get(), 1, TheMiscItems.TINY_COAL.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeTinyCoal).setNoText(), new PageCrafting(3, ItemCrafting.recipeTinyChar).setNoText(), new PageCrafting(4, BlockCrafting.recipeBlockChar).setNoText());
|
new BookletChapter("coalStuff", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemMisc.get(), 1, TheMiscItems.TINY_COAL.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeTinyCoal).setNoText(), new PageCrafting(3, ItemCrafting.recipeTinyChar).setNoText(), new PageCrafting(4, BlockCrafting.recipeBlockChar).setNoText());
|
||||||
ArrayList<BookletPage> lampPages = new ArrayList<>();
|
ArrayList<BookletPage> lampPages = new ArrayList<>();
|
||||||
lampPages.add(new PageTextOnly(lampPages.size() + 1));
|
lampPages.add(new PageTextOnly(lampPages.size() + 1));
|
||||||
|
|
|
@ -27,4 +27,16 @@ public class ActuallyContainers {
|
||||||
|
|
||||||
public static final RegistryObject<ContainerType<ContainerCoffeeMachine>> COFFEE_MACHINE_CONTAINER
|
public static final RegistryObject<ContainerType<ContainerCoffeeMachine>> COFFEE_MACHINE_CONTAINER
|
||||||
= CONTAINERS.register("coffee_machine_container", () -> IForgeContainerType.create(ContainerCoffeeMachine::fromNetwork));
|
= CONTAINERS.register("coffee_machine_container", () -> IForgeContainerType.create(ContainerCoffeeMachine::fromNetwork));
|
||||||
|
|
||||||
|
public static final RegistryObject<ContainerType<ContainerDirectionalBreaker>> DIRECTIONAL_BREAKER_CONTAINER
|
||||||
|
= CONTAINERS.register("directional_breaker_container", () -> IForgeContainerType.create(ContainerDirectionalBreaker::fromNetwork));
|
||||||
|
|
||||||
|
public static final RegistryObject<ContainerType<ContainerDropper>> DROPPER_CONTAINER
|
||||||
|
= CONTAINERS.register("dropper_container", () -> IForgeContainerType.create(ContainerDropper::fromNetwork));
|
||||||
|
|
||||||
|
public static final RegistryObject<ContainerType<ContainerEnervator>> ENERVATOR_CONTAINER
|
||||||
|
= CONTAINERS.register("enervator_container", () -> IForgeContainerType.create(ContainerEnervator::fromNetwork));
|
||||||
|
|
||||||
|
public static final RegistryObject<ContainerType<ContainerEnergizer>> ENERGIZER_CONTAINER
|
||||||
|
= CONTAINERS.register("energizer_container", () -> IForgeContainerType.create(ContainerEnergizer::fromNetwork));
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,35 +11,42 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.inventory;
|
package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDirectionalBreaker;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDirectionalBreaker;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ContainerDirectionalBreaker extends Container {
|
public class ContainerDirectionalBreaker extends Container {
|
||||||
|
|
||||||
private final TileEntityDirectionalBreaker breaker;
|
private final TileEntityDirectionalBreaker breaker;
|
||||||
|
|
||||||
public ContainerDirectionalBreaker(PlayerInventory inventory, TileEntityBase tile) {
|
public static ContainerDirectionalBreaker fromNetwork(int windowId, PlayerInventory inv, PacketBuffer data) {
|
||||||
this.breaker = (TileEntityDirectionalBreaker) tile;
|
return new ContainerDirectionalBreaker(windowId, inv, (TileEntityDirectionalBreaker) Objects.requireNonNull(inv.player.world.getTileEntity(data.readBlockPos())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContainerDirectionalBreaker(int windowId, PlayerInventory inventory, TileEntityDirectionalBreaker tile) {
|
||||||
|
super(ActuallyContainers.DIRECTIONAL_BREAKER_CONTAINER.get(), windowId);
|
||||||
|
this.breaker = tile;
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.breaker.inv, j + i * 3, 74 + j * 18, 21 + i * 18));
|
this.addSlot(new SlotItemHandlerUnconditioned(this.breaker.inv, j + i * 3, 74 + j * 18, 21 + i * 18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
for (int j = 0; j < 9; j++) {
|
for (int j = 0; j < 9; j++) {
|
||||||
this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18));
|
this.addSlot(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155));
|
this.addSlot(new Slot(inventory, i, 8 + i * 18, 155));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,37 +12,44 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ContainerDropper extends Container {
|
public class ContainerDropper extends Container {
|
||||||
|
|
||||||
private final TileEntityDropper dropper;
|
private final TileEntityDropper dropper;
|
||||||
PlayerEntity player;
|
PlayerEntity player;
|
||||||
|
|
||||||
public ContainerDropper(PlayerEntity player, TileEntityBase tile) {
|
public static ContainerDropper fromNetwork(int windowId, PlayerInventory inv, PacketBuffer data) {
|
||||||
this.dropper = (TileEntityDropper) tile;
|
return new ContainerDropper(windowId, inv, (TileEntityDropper) Objects.requireNonNull(inv.player.world.getTileEntity(data.readBlockPos())));
|
||||||
this.player = player;
|
}
|
||||||
PlayerInventory inventory = player.inventory;
|
|
||||||
|
public ContainerDropper(int windowId, PlayerInventory inventory, TileEntityDropper tile) {
|
||||||
|
super(ActuallyContainers.DROPPER_CONTAINER.get(), windowId);
|
||||||
|
this.dropper = tile;
|
||||||
|
this.player = inventory.player;
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.dropper.inv, j + i * 3, 62 + j * 18, 21 + i * 18));
|
this.addSlot(new SlotItemHandlerUnconditioned(this.dropper.inv, j + i * 3, 62 + j * 18, 21 + i * 18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
for (int j = 0; j < 9; j++) {
|
for (int j = 0; j < 9; j++) {
|
||||||
this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18));
|
this.addSlot(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155));
|
this.addSlot(new Slot(inventory, i, 8 + i * 18, 155));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +108,7 @@ public class ContainerDropper extends Container {
|
||||||
public void onContainerClosed(PlayerEntity playerIn) {
|
public void onContainerClosed(PlayerEntity playerIn) {
|
||||||
super.onContainerClosed(playerIn);
|
super.onContainerClosed(playerIn);
|
||||||
if (!this.player.isSpectator()) {
|
if (!this.player.isSpectator()) {
|
||||||
this.dropper.getWorld().notifyNeighborsOfStateChange(this.dropper.getPos(), ActuallyBlocks.blockDropper, false);
|
this.dropper.getWorld().notifyNeighborsOfStateChange(this.dropper.getPos(), ActuallyBlocks.blockDropper.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,51 +12,54 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.Container;
|
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
|
||||||
import net.minecraft.inventory.EquipmentSlotType;
|
import net.minecraft.inventory.EquipmentSlotType;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.item.ItemArmor;
|
import net.minecraft.inventory.container.Slot;
|
||||||
|
import net.minecraft.item.ArmorItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
import net.minecraftforge.fml.relauncher.OnlyIn;
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ContainerEnergizer extends Container {
|
public class ContainerEnergizer extends Container {
|
||||||
|
|
||||||
public static final EquipmentSlotType[] VALID_EQUIPMENT_SLOTS = new EquipmentSlotType[]{EquipmentSlotType.HEAD, EquipmentSlotType.CHEST, EquipmentSlotType.LEGS, EquipmentSlotType.FEET};
|
public static final EquipmentSlotType[] VALID_EQUIPMENT_SLOTS = new EquipmentSlotType[]{EquipmentSlotType.HEAD, EquipmentSlotType.CHEST, EquipmentSlotType.LEGS, EquipmentSlotType.FEET};
|
||||||
private final TileEntityEnergizer energizer;
|
private final TileEntityEnergizer energizer;
|
||||||
|
|
||||||
public ContainerEnergizer(PlayerEntity player, TileEntityBase tile) {
|
public static ContainerEnergizer fromNetwork(int windowId, PlayerInventory inv, PacketBuffer data) {
|
||||||
this.energizer = (TileEntityEnergizer) tile;
|
return new ContainerEnergizer(windowId, inv, (TileEntityEnergizer) Objects.requireNonNull(inv.player.world.getTileEntity(data.readBlockPos())));
|
||||||
PlayerInventory inventory = player.inventory;
|
}
|
||||||
|
|
||||||
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.energizer.inv, 0, 76, 73) {
|
public ContainerEnergizer(int windowId, PlayerInventory inventory, TileEntityEnergizer tile) {
|
||||||
|
super(ActuallyContainers.ENERGIZER_CONTAINER.get(), windowId);
|
||||||
|
this.energizer = tile;
|
||||||
|
|
||||||
|
this.addSlot(new SlotItemHandlerUnconditioned(this.energizer.inv, 0, 76, 73) {
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(ItemStack stack) {
|
public boolean isItemValid(ItemStack stack) {
|
||||||
return super.isItemValid(stack) && stack.hasCapability(CapabilityEnergy.ENERGY, null);
|
return super.isItemValid(stack) && stack.getCapability(CapabilityEnergy.ENERGY, null).isPresent();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.addSlotToContainer(new SlotOutput(this.energizer.inv, 1, 76, 42));
|
this.addSlot(new SlotOutput(this.energizer.inv, 1, 76, 42));
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
for (int j = 0; j < 9; j++) {
|
for (int j = 0; j < 9; j++) {
|
||||||
this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18));
|
this.addSlot(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155));
|
this.addSlot(new Slot(inventory, i, 8 + i * 18, 155));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int k = 0; k < 4; ++k) {
|
for (int k = 0; k < 4; ++k) {
|
||||||
EntityEquipmentSlot slot = VALID_EQUIPMENT_SLOTS[k];
|
EquipmentSlotType slot = VALID_EQUIPMENT_SLOTS[k];
|
||||||
this.addSlotToContainer(new Slot(player.inventory, 36 + 3 - k, 102, 19 + k * 18) {
|
this.addSlot(new Slot(inventory, 36 + 3 - k, 102, 19 + k * 18) {
|
||||||
@Override
|
@Override
|
||||||
public int getSlotStackLimit() {
|
public int getSlotStackLimit() {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -64,22 +67,22 @@ public class ContainerEnergizer extends Container {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(ItemStack stack) {
|
public boolean isItemValid(ItemStack stack) {
|
||||||
return StackUtil.isValid(stack) && stack.getItem().isValidArmor(stack, slot, player);
|
return StackUtil.isValid(stack) && stack.getItem() instanceof ArmorItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTakeStack(PlayerEntity player) {
|
public boolean canTakeStack(PlayerEntity player) {
|
||||||
ItemStack itemstack = this.getStack();
|
ItemStack itemstack = this.getStack();
|
||||||
return !itemstack.isEmpty() && !player.isCreative() && EnchantmentHelper.hasBindingCurse(itemstack)
|
return (itemstack.isEmpty() || player.isCreative() || !EnchantmentHelper.hasBindingCurse(itemstack)) && super.canTakeStack(player);
|
||||||
? false
|
|
||||||
: super.canTakeStack(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// TODO: [port] add back
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public String getSlotTexture() {
|
// @Override
|
||||||
return ItemArmor.EMPTY_SLOT_NAMES[slot.getIndex()];
|
// @OnlyIn(Dist.CLIENT)
|
||||||
}
|
// public String getSlotTexture() {
|
||||||
|
// return Armor.EMPTY_SLOT_NAMES[slot.getIndex()];
|
||||||
|
// }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,7 +110,7 @@ public class ContainerEnergizer extends Container {
|
||||||
//Other Slots in Inventory excluded
|
//Other Slots in Inventory excluded
|
||||||
else if (slot >= inventoryStart) {
|
else if (slot >= inventoryStart) {
|
||||||
//Shift from Inventory
|
//Shift from Inventory
|
||||||
if (newStack.hasCapability(CapabilityEnergy.ENERGY, null)) {
|
if (newStack.getCapability(CapabilityEnergy.ENERGY, null).isPresent()) {
|
||||||
if (!this.mergeItemStack(newStack, 0, 1, false)) {
|
if (!this.mergeItemStack(newStack, 0, 1, false)) {
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,57 +12,65 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.EquipmentSlotType;
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
import net.minecraft.item.ItemArmor;
|
import net.minecraft.item.ArmorItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
import net.minecraftforge.fml.relauncher.OnlyIn;
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ContainerEnervator extends Container {
|
public class ContainerEnervator extends Container {
|
||||||
|
|
||||||
private final TileEntityEnervator enervator;
|
private final TileEntityEnervator enervator;
|
||||||
|
|
||||||
public ContainerEnervator(PlayerEntity player, TileEntityBase tile) {
|
public static ContainerEnervator fromNetwork(int windowId, PlayerInventory inv, PacketBuffer data) {
|
||||||
this.enervator = (TileEntityEnervator) tile;
|
return new ContainerEnervator(windowId, inv, (TileEntityEnervator) Objects.requireNonNull(inv.player.world.getTileEntity(data.readBlockPos())));
|
||||||
PlayerInventory inventory = player.inventory;
|
}
|
||||||
|
|
||||||
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.enervator.inv, 0, 76, 73));
|
public ContainerEnervator(int windowId, PlayerInventory inventory, TileEntityEnervator tile) {
|
||||||
this.addSlotToContainer(new SlotOutput(this.enervator.inv, 1, 76, 42));
|
super(ActuallyContainers.ENERGIZER_CONTAINER.get(), windowId);
|
||||||
|
this.enervator = tile;
|
||||||
|
|
||||||
|
this.addSlot(new SlotItemHandlerUnconditioned(this.enervator.inv, 0, 76, 73));
|
||||||
|
this.addSlot(new SlotOutput(this.enervator.inv, 1, 76, 42));
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
for (int j = 0; j < 9; j++) {
|
for (int j = 0; j < 9; j++) {
|
||||||
this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18));
|
this.addSlot(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155));
|
this.addSlot(new Slot(inventory, i, 8 + i * 18, 155));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int k = 0; k < 4; ++k) {
|
for (int k = 0; k < 4; ++k) {
|
||||||
EntityEquipmentSlot slot = ContainerEnergizer.VALID_EQUIPMENT_SLOTS[k];
|
EquipmentSlotType slot = ContainerEnergizer.VALID_EQUIPMENT_SLOTS[k];
|
||||||
this.addSlotToContainer(new Slot(player.inventory, 36 + 3 - k, 102, 19 + k * 18) {
|
this.addSlot(new Slot(inventory, 36 + 3 - k, 102, 19 + k * 18) {
|
||||||
@Override
|
@Override
|
||||||
public int getSlotStackLimit() {
|
public int getSlotStackLimit() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: [port] validate that this is correct
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(ItemStack stack) {
|
public boolean isItemValid(ItemStack stack) {
|
||||||
return StackUtil.isValid(stack) && stack.getItem().isValidArmor(stack, slot, player);
|
return StackUtil.isValid(stack) && stack.getItem() instanceof ArmorItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// TODO: [port] add this back
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public String getSlotTexture() {
|
// @Override
|
||||||
return ItemArmor.EMPTY_SLOT_NAMES[slot.getIndex()];
|
// @OnlyIn(Dist.CLIENT)
|
||||||
}
|
// public String getSlotTexture() {
|
||||||
|
// return ItemArmor.EMPTY_SLOT_NAMES[slot.getIndex()];
|
||||||
|
// }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +98,7 @@ public class ContainerEnervator extends Container {
|
||||||
//Other Slots in Inventory excluded
|
//Other Slots in Inventory excluded
|
||||||
else if (slot >= inventoryStart) {
|
else if (slot >= inventoryStart) {
|
||||||
//Shift from Inventory
|
//Shift from Inventory
|
||||||
if (newStack.hasCapability(CapabilityEnergy.ENERGY, null)) {
|
if (newStack.getCapability(CapabilityEnergy.ENERGY).isPresent()) {
|
||||||
if (!this.mergeItemStack(newStack, 0, 1, false)) {
|
if (!this.mergeItemStack(newStack, 0, 1, false)) {
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class ItemChestToCrateUpgrade extends ItemBase {
|
||||||
|
|
||||||
world.removeTileEntity(pos);
|
world.removeTileEntity(pos);
|
||||||
world.setBlockState(pos, this.end, 2);
|
world.setBlockState(pos, this.end, 2);
|
||||||
if (!player.capabilities.isCreativeMode) {
|
if (!player.isCreative()) {
|
||||||
heldStack.shrink(1);
|
heldStack.shrink(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class ItemDrill extends ItemEnergy {
|
||||||
try {
|
try {
|
||||||
//Places the Block into the World
|
//Places the Block into the World
|
||||||
if (toPlaceStack.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ) != EnumActionResult.FAIL) {
|
if (toPlaceStack.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ) != EnumActionResult.FAIL) {
|
||||||
if (!player.capabilities.isCreativeMode) {
|
if (!player.isCreative()) {
|
||||||
WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, toPlaceStack.copy());
|
WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, toPlaceStack.copy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ public class ItemDrill extends ItemEnergy {
|
||||||
@Override
|
@Override
|
||||||
public boolean hitEntity(ItemStack stack, EntityLivingBase entity1, EntityLivingBase entity2) {
|
public boolean hitEntity(ItemStack stack, EntityLivingBase entity1, EntityLivingBase entity2) {
|
||||||
int use = this.getEnergyUsePerBlock(stack);
|
int use = this.getEnergyUsePerBlock(stack);
|
||||||
if (!(entity2 instanceof PlayerEntity) || !((PlayerEntity) entity2).capabilities.isCreativeMode) {
|
if (!(entity2 instanceof PlayerEntity) || !((PlayerEntity) entity2).isCreative()) {
|
||||||
if (this.getEnergyStored(stack) >= use) {
|
if (this.getEnergyStored(stack) >= use) {
|
||||||
this.extractEnergyInternal(stack, use, false);
|
this.extractEnergyInternal(stack, use, false);
|
||||||
}
|
}
|
||||||
|
@ -478,7 +478,7 @@ public class ItemDrill extends ItemEnergy {
|
||||||
float hardness = state.getBlockHardness(world, pos);
|
float hardness = state.getBlockHardness(world, pos);
|
||||||
boolean canHarvest = (ForgeHooks.canHarvestBlock(block, player, world, pos) || this.canHarvestBlock(state, stack)) && (!isExtra || this.getDestroySpeed(stack, world.getBlockState(pos)) > 1.0F);
|
boolean canHarvest = (ForgeHooks.canHarvestBlock(block, player, world, pos) || this.canHarvestBlock(state, stack)) && (!isExtra || this.getDestroySpeed(stack, world.getBlockState(pos)) > 1.0F);
|
||||||
if (hardness >= 0.0F && (!isExtra || canHarvest && !block.hasTileEntity(world.getBlockState(pos)))) {
|
if (hardness >= 0.0F && (!isExtra || canHarvest && !block.hasTileEntity(world.getBlockState(pos)))) {
|
||||||
if (!player.capabilities.isCreativeMode) {
|
if (!player.isCreative()) {
|
||||||
this.extractEnergyInternal(stack, use, false);
|
this.extractEnergyInternal(stack, use, false);
|
||||||
}
|
}
|
||||||
//Break the Block
|
//Break the Block
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class ItemGrowthRing extends ItemEnergy {
|
||||||
world.playEvent(2005, pos, 0);
|
world.playEvent(2005, pos, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.capabilities.isCreativeMode) {
|
if (!player.isCreative()) {
|
||||||
this.extractEnergyInternal(stack, energyUse, false);
|
this.extractEnergyInternal(stack, energyUse, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class ItemMagnetRing extends ItemEnergy {
|
||||||
|
|
||||||
item.onCollideWithPlayer(player);
|
item.onCollideWithPlayer(player);
|
||||||
|
|
||||||
if (!player.capabilities.isCreativeMode) {
|
if (!player.isCreative()) {
|
||||||
if (item.isDead || !ItemStack.areItemStacksEqual(item.getItem(), oldItem)) {
|
if (item.isDead || !ItemStack.areItemStacksEqual(item.getItem(), oldItem)) {
|
||||||
this.extractEnergyInternal(stack, energyForItem, false);
|
this.extractEnergyInternal(stack, energyForItem, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,12 +59,12 @@ public class ItemSolidifiedExperience extends ItemBase {
|
||||||
int amount;
|
int amount;
|
||||||
if (!player.isSneaking()) {
|
if (!player.isSneaking()) {
|
||||||
amount = SOLID_XP_AMOUNT;
|
amount = SOLID_XP_AMOUNT;
|
||||||
if (!player.capabilities.isCreativeMode) {
|
if (!player.isCreative()) {
|
||||||
stack.shrink(1);
|
stack.shrink(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
amount = SOLID_XP_AMOUNT * stack.getCount();
|
amount = SOLID_XP_AMOUNT * stack.getCount();
|
||||||
if (!player.capabilities.isCreativeMode) {
|
if (!player.isCreative()) {
|
||||||
stack.setCount(0);
|
stack.setCount(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class ItemSpawnerChanger extends ItemBase {
|
||||||
|
|
||||||
ItemPhantomConnector.clearStorage(stack, "Entity");
|
ItemPhantomConnector.clearStorage(stack, "Entity");
|
||||||
|
|
||||||
if (!player.capabilities.isCreativeMode) {
|
if (!player.isCreative()) {
|
||||||
player.setHeldItem(hand, StackUtil.shrink(stack, 1));
|
player.setHeldItem(hand, StackUtil.shrink(stack, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class ItemTeleStaff extends ItemEnergy {
|
||||||
((ServerPlayerEntity) player).connection.setPlayerLocation(x, y, z, player.rotationYaw, player.rotationPitch);
|
((ServerPlayerEntity) player).connection.setPlayerLocation(x, y, z, player.rotationYaw, player.rotationPitch);
|
||||||
player.dismountRidingEntity();
|
player.dismountRidingEntity();
|
||||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
|
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F);
|
||||||
if (!player.capabilities.isCreativeMode) {
|
if (!player.isCreative()) {
|
||||||
this.extractEnergyInternal(stack, use, false);
|
this.extractEnergyInternal(stack, use, false);
|
||||||
player.getCooldownTracker().setCooldown(this, 50);
|
player.getCooldownTracker().setCooldown(this, 50);
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class ItemWaterBowl extends ItemBase {
|
||||||
if (!player.canPlayerEdit(pos1, trace.sideHit, stack)) {
|
if (!player.canPlayerEdit(pos1, trace.sideHit, stack)) {
|
||||||
return new ActionResult<>(EnumActionResult.FAIL, stack);
|
return new ActionResult<>(EnumActionResult.FAIL, stack);
|
||||||
} else if (this.tryPlaceContainedLiquid(player, world, pos1, false)) {
|
} else if (this.tryPlaceContainedLiquid(player, world, pos1, false)) {
|
||||||
return !player.capabilities.isCreativeMode
|
return !player.isCreative()
|
||||||
? new ActionResult<>(EnumActionResult.SUCCESS, new ItemStack(Items.BOWL))
|
? new ActionResult<>(EnumActionResult.SUCCESS, new ItemStack(Items.BOWL))
|
||||||
: new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
: new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class ItemWaterRemovalRing extends ItemEnergy {
|
||||||
if ((block == Blocks.WATER || block == Blocks.FLOWING_WATER) && this.getEnergyStored(stack) >= energyUse) {
|
if ((block == Blocks.WATER || block == Blocks.FLOWING_WATER) && this.getEnergyStored(stack) >= energyUse) {
|
||||||
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||||
|
|
||||||
if (!player.capabilities.isCreativeMode) {
|
if (!player.isCreative()) {
|
||||||
this.extractEnergyInternal(stack, energyUse, false);
|
this.extractEnergyInternal(stack, energyUse, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public class ItemWaterRemovalRing extends ItemEnergy {
|
||||||
else if ((block == Blocks.LAVA || block == Blocks.FLOWING_LAVA) && this.getEnergyStored(stack) >= energyUse * 2) {
|
else if ((block == Blocks.LAVA || block == Blocks.FLOWING_LAVA) && this.getEnergyStored(stack) >= energyUse * 2) {
|
||||||
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||||
|
|
||||||
if (!player.capabilities.isCreativeMode) {
|
if (!player.isCreative()) {
|
||||||
this.extractEnergyInternal(stack, energyUse * 2, false);
|
this.extractEnergyInternal(stack, energyUse * 2, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
if (event.getEntityLiving() instanceof PlayerEntity) {
|
if (event.getEntityLiving() instanceof PlayerEntity) {
|
||||||
PlayerEntity player = (PlayerEntity) event.getEntityLiving();
|
PlayerEntity player = (PlayerEntity) event.getEntityLiving();
|
||||||
|
|
||||||
if (!player.capabilities.isCreativeMode && !player.isSpectator()) {
|
if (!player.isCreative() && !player.isSpectator()) {
|
||||||
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
||||||
|
|
||||||
if (!player.world.isRemote) {
|
if (!player.world.isRemote) {
|
||||||
|
|
|
@ -10,23 +10,31 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.inventory.ContainerDirectionalBreaker;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.inventory.container.Container;
|
||||||
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileEntityDirectionalBreaker extends TileEntityInventoryBase {
|
public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implements INamedContainerProvider {
|
||||||
|
|
||||||
public static final int RANGE = 8;
|
public static final int RANGE = 8;
|
||||||
public static final int ENERGY_USE = 5;
|
public static final int ENERGY_USE = 5;
|
||||||
|
@ -128,4 +136,15 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase {
|
||||||
public LazyOptional<IEnergyStorage> getEnergyStorage(Direction facing) {
|
public LazyOptional<IEnergyStorage> getEnergyStorage(Direction facing) {
|
||||||
return this.lazyEnergy;
|
return this.lazyEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITextComponent getDisplayName() {
|
||||||
|
return StringTextComponent.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity playerEntity) {
|
||||||
|
return new ContainerDirectionalBreaker(windowId, playerInventory, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,22 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.inventory.ContainerDropper;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.inventory.container.Container;
|
||||||
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
|
||||||
public class TileEntityDropper extends TileEntityInventoryBase {
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class TileEntityDropper extends TileEntityInventoryBase implements INamedContainerProvider {
|
||||||
|
|
||||||
private int currentTime;
|
private int currentTime;
|
||||||
|
|
||||||
|
@ -91,4 +100,15 @@ public class TileEntityDropper extends TileEntityInventoryBase {
|
||||||
public void activateOnPulse() {
|
public void activateOnPulse() {
|
||||||
this.doWork();
|
this.doWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITextComponent getDisplayName() {
|
||||||
|
return StringTextComponent.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity player) {
|
||||||
|
return new ContainerDropper(windowId, playerInventory, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,17 +10,26 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.inventory.ContainerEnergizer;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.inventory.container.Container;
|
||||||
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
|
|
||||||
public class TileEntityEnergizer extends TileEntityInventoryBase {
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class TileEntityEnergizer extends TileEntityInventoryBase implements INamedContainerProvider {
|
||||||
|
|
||||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 1000, 0);
|
public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 1000, 0);
|
||||||
public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
|
public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
|
||||||
|
@ -86,4 +95,15 @@ public class TileEntityEnergizer extends TileEntityInventoryBase {
|
||||||
public LazyOptional<IEnergyStorage> getEnergyStorage(Direction facing) {
|
public LazyOptional<IEnergyStorage> getEnergyStorage(Direction facing) {
|
||||||
return this.lazyEnergy;
|
return this.lazyEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITextComponent getDisplayName() {
|
||||||
|
return StringTextComponent.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity playerEntity) {
|
||||||
|
return new ContainerEnergizer(windowId, playerInventory, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,17 +10,26 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.inventory.ContainerEnervator;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
|
import net.minecraft.inventory.container.Container;
|
||||||
|
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
|
|
||||||
public class TileEntityEnervator extends TileEntityInventoryBase implements ISharingEnergyProvider {
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class TileEntityEnervator extends TileEntityInventoryBase implements ISharingEnergyProvider, INamedContainerProvider {
|
||||||
|
|
||||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 0, 1000);
|
public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 0, 1000);
|
||||||
public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
|
public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
|
||||||
|
@ -109,4 +118,15 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements ISha
|
||||||
public LazyOptional<IEnergyStorage> getEnergyStorage(Direction facing) {
|
public LazyOptional<IEnergyStorage> getEnergyStorage(Direction facing) {
|
||||||
return this.lazyEnergy;
|
return this.lazyEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITextComponent getDisplayName() {
|
||||||
|
return StringTextComponent.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity playerEntity) {
|
||||||
|
return new ContainerEnervator(windowId, playerInventory, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,7 +315,7 @@ public final class WorldUtil {
|
||||||
BlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
|
|
||||||
if (player.capabilities.isCreativeMode) {
|
if (player.isCreative()) {
|
||||||
if (block.removedByPlayer(state, world, pos, player, false)) {
|
if (block.removedByPlayer(state, world, pos, player, false)) {
|
||||||
block.onPlayerDestroy(world, pos, state);
|
block.onPlayerDestroy(world, pos, state);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue