chore: a few blocks, containers, etc ported over

This commit is contained in:
Michael Hillcox 2021-02-28 11:33:01 +00:00
parent d39cdb5de8
commit 97bc966606
48 changed files with 655 additions and 437 deletions

View file

@ -12,30 +12,26 @@ package de.ellpeck.actuallyadditions.mod.blocks;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import de.ellpeck.actuallyadditions.api.lens.ILensItem; import de.ellpeck.actuallyadditions.api.lens.ILensItem;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.Lang; 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.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
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.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;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.state.DirectionProperty; import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType; import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
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.BlockRayTraceResult;
@ -51,7 +47,7 @@ import net.minecraftforge.common.ToolType;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class BlockAtomicReconstructor extends BlockContainerBase implements IHudDisplay { public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container implements IHudDisplay {
public static final DirectionProperty FACING = BlockStateProperties.FACING; public static final DirectionProperty FACING = BlockStateProperties.FACING;
public static final int NAME_FLAVOR_AMOUNTS_1 = 12; public static final int NAME_FLAVOR_AMOUNTS_1 = 12;
@ -59,7 +55,6 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
public BlockAtomicReconstructor() { public BlockAtomicReconstructor() {
super(Properties.create(Material.ROCK).harvestTool(ToolType.PICKAXE).hardnessAndResistance(10F, 80F).sound(SoundType.STONE)); super(Properties.create(Material.ROCK).harvestTool(ToolType.PICKAXE).hardnessAndResistance(10F, 80F).sound(SoundType.STONE));
this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH));
} }
@Override @Override
@ -102,19 +97,9 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
return new TileEntityAtomicReconstructor(); return new TileEntityAtomicReconstructor();
} }
public BlockState getBaseConstructorState() { // public BlockState getBaseConstructorState() {
return this.stateContainer.getBaseState().with(FACING, Direction.NORTH); // return 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 @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)

View file

@ -10,97 +10,55 @@
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.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.BlockDirectional; import net.minecraft.block.BlockState;
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.entity.EntityLivingBase;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity; import net.minecraft.entity.player.ServerPlayerEntity;
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;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.network.NetworkHooks;
public class BlockBreaker extends BlockContainerBase { import javax.annotation.Nullable;
public class BlockBreaker extends FullyDirectionalBlock.Container {
private final boolean isPlacer; private final boolean isPlacer;
public BlockBreaker(boolean isPlacer) { public BlockBreaker(boolean isPlacer) {
super(Material.ROCK, this.name); super(Properties.create(Material.ROCK).hardnessAndResistance(1.5F, 10.0F).harvestTool(ToolType.PICKAXE).harvestLevel(0).sound(SoundType.STONE));
this.isPlacer = isPlacer; this.isPlacer = isPlacer;
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setSoundType(SoundType.STONE);
} }
@Nullable
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader world) {
return this.isPlacer return this.isPlacer
? new TileEntityPlacer() ? new TileEntityPlacer()
: new TileEntityBreaker(); : new TileEntityBreaker();
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { 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) { if (!world.isRemote) {
TileEntityBreaker breaker = (TileEntityBreaker) world.getTileEntity(pos); TileEntityBreaker tile = (TileEntityBreaker) world.getTileEntity(pos);
if (breaker != null) { if (tile != null) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BREAKER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
} }
return true; return ActionResultType.PASS;
} }
return true; return super.onBlockActivated(state, world, pos, player, handIn, hit);
}
@Override
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.UNCOMMON;
}
@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)));
} }
} }

View file

@ -10,62 +10,60 @@
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.TileEntityCanolaPress; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress;
import net.minecraft.block.BlockState;
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.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity; import net.minecraft.entity.player.ServerPlayerEntity;
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.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;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.network.NetworkHooks;
import javax.annotation.Nullable;
public class BlockCanolaPress extends BlockContainerBase { public class BlockCanolaPress extends BlockContainerBase {
public BlockCanolaPress() { public BlockCanolaPress() {
super(Material.ROCK, this.name); super(Properties.create(Material.ROCK).harvestTool(ToolType.PICKAXE).harvestLevel(0).hardnessAndResistance(1.5F, 10.0F).sound(SoundType.STONE));
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setSoundType(SoundType.STONE);
} }
@Override // @Override
public boolean isFullCube(BlockState state) { // public boolean isFullCube(BlockState state) {
return false; // return false;
} // }
@Nullable
@Override @Override
public boolean isOpaqueCube(BlockState state) { public TileEntity createNewTileEntity(IBlockReader world) {
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityCanolaPress(); return new TileEntityCanolaPress();
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction side, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
if (!world.isRemote) { if (!world.isRemote) {
TileEntityCanolaPress press = (TileEntityCanolaPress) world.getTileEntity(pos); TileEntityCanolaPress tile = (TileEntityCanolaPress) world.getTileEntity(pos);
if (press != null) { if (tile != null) {
if (!this.tryUseItemOnTank(player, hand, press.tank)) { if (!this.tryUseItemOnTank(player, hand, tile.tank)) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.CANOLA_PRESS.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
} }
} }
return true; return ActionResultType.PASS;
} }
return true; return super.onBlockActivated(state, world, pos, player, hand, hit);
} }
@Override @Override
public EnumRarity getRarity(ItemStack stack) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return EnumRarity.RARE; return Shapes.CANOLA_PRESS_SHAPE;
} }
} }

View file

@ -10,115 +10,75 @@
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.DirectionalBlock;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator;
import net.minecraft.block.BlockHorizontal; import net.minecraft.block.BlockState;
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.entity.EntityLivingBase;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.particles.ParticleTypes;
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;
import net.minecraftforge.api.distmarker.Dist; import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.fml.relauncher.OnlyIn; import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.network.NetworkHooks;
import java.util.Random; import java.util.Random;
public class BlockCoalGenerator extends BlockContainerBase { public class BlockCoalGenerator extends DirectionalBlock.Container {
public BlockCoalGenerator() { public BlockCoalGenerator() {
super(Material.ROCK, this.name); super(Properties.create(Material.ROCK).harvestTool(ToolType.PICKAXE).harvestLevel(0).hardnessAndResistance(1.5F, 10.0F).sound(SoundType.STONE).tickRandomly());
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setSoundType(SoundType.STONE);
this.setTickRandomly(true);
} }
@Override @Override
public boolean isFullCube(BlockState state) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return false;
}
@Override
public boolean isOpaqueCube(BlockState state) {
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int par2) {
return new TileEntityCoalGenerator(); return new TileEntityCoalGenerator();
} }
@Override @Override
@OnlyIn(Dist.CLIENT) public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random rand) {
TileEntity tile = world.getTileEntity(pos); TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityCoalGenerator) { if (tile instanceof TileEntityCoalGenerator) {
if (((TileEntityCoalGenerator) tile).currentBurnTime > 0) { if (((TileEntityCoalGenerator) tile).currentBurnTime > 0) {
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) pos.getX() + 0.5F, (double) pos.getY() + 1.0F, (double) pos.getZ() + 0.5F, 0.0D, 0.0D, 0.0D); world.addParticle(ParticleTypes.SMOKE, (double) pos.getX() + 0.5F, (double) pos.getY() + 1.0F, (double) pos.getZ() + 0.5F, 0.0D, 0.0D, 0.0D);
} }
} }
} }
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
if (!world.isRemote) { if (!world.isRemote) {
TileEntityCoalGenerator press = (TileEntityCoalGenerator) world.getTileEntity(pos); TileEntityCoalGenerator tile = (TileEntityCoalGenerator) world.getTileEntity(pos);
if (press != null) { if (tile != null) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.COAL_GENERATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
} }
return true; return ActionResultType.PASS;
} }
return true;
return super.onBlockActivated(state, world, pos, player, hand, hit);
} }
@Override @Override
public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, EntityLivingBase player, ItemStack stack) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2); switch (state.get(FACING)) {
case EAST:
super.onBlockPlacedBy(world, pos, state, player, stack); return Shapes.CoalGeneratorShapes.EAST;
} case SOUTH:
return Shapes.CoalGeneratorShapes.SOUTH;
@Override case WEST:
public EnumRarity getRarity(ItemStack stack) { return Shapes.CoalGeneratorShapes.WEST;
return EnumRarity.RARE; default:
} return Shapes.CoalGeneratorShapes.NORTH;
}
@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)));
} }
} }

View file

@ -10,122 +10,63 @@
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.DirectionalBlock;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
import net.minecraft.block.BlockHorizontal; import net.minecraft.block.BlockState;
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.entity.EntityLivingBase;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity; import net.minecraft.entity.player.ServerPlayerEntity;
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.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.IBlockAccess; 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 net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.network.NetworkHooks;
public class BlockCoffeeMachine extends BlockContainerBase { import javax.annotation.Nullable;
private static final AxisAlignedBB AABB = new AxisAlignedBB(0.0625, 0, 0.0625, 1 - 0.0625, 1 - 0.0625 * 2, 1 - 0.0625);
public class BlockCoffeeMachine extends DirectionalBlock.Container {
public BlockCoffeeMachine() { public BlockCoffeeMachine() {
super(Material.ROCK, this.name); super(Properties.create(Material.ROCK).harvestTool(ToolType.PICKAXE).harvestLevel(0).hardnessAndResistance(1.5F, 10.0F).sound(SoundType.STONE));
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setSoundType(SoundType.STONE);
} }
@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 AABB;
}
@Override
public boolean isFullCube(BlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(BlockState state) {
return false;
}
@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) { if (!world.isRemote) {
TileEntityCoffeeMachine machine = (TileEntityCoffeeMachine) world.getTileEntity(pos); TileEntityCoffeeMachine tile = (TileEntityCoffeeMachine) world.getTileEntity(pos);
if (machine != null) { if (tile != null) {
if (!this.tryUseItemOnTank(player, hand, machine.tank)) { if (!this.tryUseItemOnTank(player, hand, tile.tank)) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.COFFEE_MACHINE.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
} }
} }
return true; return ActionResultType.PASS;
} }
return true; return super.onBlockActivated(state, world, pos, player, hand, hit);
} }
@Nullable
@Override @Override
public TileEntity createNewTileEntity(World world, int meta) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityCoffeeMachine(); return new TileEntityCoffeeMachine();
} }
@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 EAST:
return Shapes.CoffeeMachineShapes.EAST;
@Override case SOUTH:
public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, EntityLivingBase player, ItemStack stack) { return Shapes.CoffeeMachineShapes.SOUTH;
int rotation = MathHelper.floor(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; case WEST:
return Shapes.CoffeeMachineShapes.WEST;
if (rotation == 0) { default:
world.setBlockState(pos, this.getStateFromMeta(0), 2); return Shapes.CoffeeMachineShapes.NORTH;
} }
if (rotation == 1) {
world.setBlockState(pos, this.getStateFromMeta(3), 2);
}
if (rotation == 2) {
world.setBlockState(pos, this.getStateFromMeta(1), 2);
}
if (rotation == 3) {
world.setBlockState(pos, this.getStateFromMeta(2), 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)));
} }
} }

View file

@ -41,12 +41,12 @@ public class BlockDirectionalBreaker extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityDirectionalBreaker(); return new TileEntityDirectionalBreaker();
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (this.tryToggleRedstone(world, pos, player)) { if (this.tryToggleRedstone(world, pos, player)) {
return true; return true;
} }

View file

@ -50,7 +50,7 @@ public class BlockDisplayStand extends BlockContainerBase {
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { 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);

View file

@ -41,12 +41,12 @@ public class BlockDropper extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityDropper(); return new TileEntityDropper();
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (this.tryToggleRedstone(world, pos, player)) { if (this.tryToggleRedstone(world, pos, player)) {
return true; return true;
} }

View file

@ -20,7 +20,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity; 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.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -49,7 +48,7 @@ public class BlockEmpowerer extends BlockContainerBase {
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { 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);

View file

@ -21,7 +21,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity; 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.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -40,14 +39,14 @@ public class BlockEnergizer extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return this.isEnergizer return this.isEnergizer
? new TileEntityEnergizer() ? new TileEntityEnergizer()
: new TileEntityEnervator(); : new TileEntityEnervator();
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!world.isRemote) { if (!world.isRemote) {
if (this.isEnergizer) { if (this.isEnergizer) {
TileEntityEnergizer energizer = (TileEntityEnergizer) world.getTileEntity(pos); TileEntityEnergizer energizer = (TileEntityEnergizer) world.getTileEntity(pos);

View file

@ -41,12 +41,12 @@ public class BlockFarmer extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityFarmer(); return new TileEntityFarmer();
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!world.isRemote) { if (!world.isRemote) {
TileEntityFarmer farmer = (TileEntityFarmer) world.getTileEntity(pos); TileEntityFarmer farmer = (TileEntityFarmer) world.getTileEntity(pos);
if (farmer != null) { if (farmer != null) {

View file

@ -20,7 +20,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity; 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.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -36,12 +35,12 @@ public class BlockFeeder extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityFeeder(); return new TileEntityFeeder();
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!world.isRemote) { if (!world.isRemote) {
TileEntityFeeder feeder = (TileEntityFeeder) world.getTileEntity(pos); TileEntityFeeder feeder = (TileEntityFeeder) world.getTileEntity(pos);
if (feeder != null) { if (feeder != null) {

View file

@ -20,7 +20,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity; 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.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -46,12 +45,12 @@ public class BlockFermentingBarrel extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityFermentingBarrel(); return new TileEntityFermentingBarrel();
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!world.isRemote) { if (!world.isRemote) {
TileEntityFermentingBarrel press = (TileEntityFermentingBarrel) world.getTileEntity(pos); TileEntityFermentingBarrel press = (TileEntityFermentingBarrel) world.getTileEntity(pos);
if (press != null) { if (press != null) {

View file

@ -20,7 +20,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity; 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.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -36,7 +35,7 @@ public class BlockFireworkBox extends BlockContainerBase {
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (this.tryToggleRedstone(world, pos, player)) { if (this.tryToggleRedstone(world, pos, player)) {
return true; return true;
} else if (!world.isRemote) { } else if (!world.isRemote) {
@ -49,7 +48,7 @@ public class BlockFireworkBox extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityFireworkBox(); return new TileEntityFireworkBox();
} }

View file

@ -19,7 +19,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB; 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.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockFishingNet extends BlockContainerBase { public class BlockFishingNet extends BlockContainerBase {
@ -39,7 +38,7 @@ public class BlockFishingNet extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityFishingNet(); return new TileEntityFishingNet();
} }

View file

@ -45,14 +45,14 @@ public class BlockFluidCollector extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return this.isPlacer return this.isPlacer
? new TileEntityFluidPlacer() ? new TileEntityFluidPlacer()
: new TileEntityFluidCollector(); : new TileEntityFluidCollector();
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (this.tryToggleRedstone(world, pos, player)) { if (this.tryToggleRedstone(world, pos, player)) {
return true; return true;
} }

View file

@ -56,7 +56,7 @@ public class BlockFurnaceDouble extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityFurnaceDouble(); return new TileEntityFurnaceDouble();
} }
@ -71,7 +71,7 @@ public class BlockFurnaceDouble extends BlockContainerBase {
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!world.isRemote) { if (!world.isRemote) {
TileEntityFurnaceDouble furnace = (TileEntityFurnaceDouble) world.getTileEntity(pos); TileEntityFurnaceDouble furnace = (TileEntityFurnaceDouble) world.getTileEntity(pos);
if (furnace != null) { if (furnace != null) {

View file

@ -20,7 +20,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB; 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.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockFurnaceSolar extends BlockContainerBase { public class BlockFurnaceSolar extends BlockContainerBase {
@ -40,7 +39,7 @@ public class BlockFurnaceSolar extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityFurnaceSolar(); return new TileEntityFurnaceSolar();
} }

View file

@ -33,7 +33,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListNBT;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -60,7 +59,7 @@ public class BlockGiantChest extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
switch (this.type) { switch (this.type) {
case 1: case 1:
return new TileEntityGiantChestMedium(); return new TileEntityGiantChestMedium();
@ -82,7 +81,7 @@ public class BlockGiantChest extends BlockContainerBase {
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!world.isRemote) { if (!world.isRemote) {
TileEntityGiantChest chest = (TileEntityGiantChest) world.getTileEntity(pos); TileEntityGiantChest chest = (TileEntityGiantChest) world.getTileEntity(pos);
if (chest != null) { if (chest != null) {

View file

@ -22,7 +22,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity; 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.EnumParticleTypes; import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -48,7 +47,7 @@ public class BlockGrinder extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return this.isDouble return this.isDouble
? new TileEntityGrinderDouble() ? new TileEntityGrinderDouble()
: new TileEntityGrinder(); : new TileEntityGrinder();
@ -68,7 +67,7 @@ public class BlockGrinder extends BlockContainerBase {
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!world.isRemote) { if (!world.isRemote) {
TileEntityGrinder grinder = (TileEntityGrinder) world.getTileEntity(pos); TileEntityGrinder grinder = (TileEntityGrinder) world.getTileEntity(pos);
if (grinder != null) { if (grinder != null) {

View file

@ -17,7 +17,6 @@ import net.minecraft.block.material.Material;
import net.minecraft.item.EnumRarity; 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.world.World;
public class BlockHeatCollector extends BlockContainerBase { public class BlockHeatCollector extends BlockContainerBase {
@ -30,7 +29,7 @@ public class BlockHeatCollector extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityHeatCollector(); return new TileEntityHeatCollector();
} }

View file

@ -25,7 +25,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity; 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.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -49,14 +48,14 @@ public class BlockInputter extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return this.isAdvanced return this.isAdvanced
? new TileEntityInputterAdvanced() ? new TileEntityInputterAdvanced()
: new TileEntityInputter(); : new TileEntityInputter();
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!world.isRemote) { if (!world.isRemote) {
TileEntityInputter inputter = (TileEntityInputter) world.getTileEntity(pos); TileEntityInputter inputter = (TileEntityInputter) world.getTileEntity(pos);
if (inputter != null) { if (inputter != null) {

View file

@ -19,7 +19,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity; 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.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -37,12 +36,12 @@ public class BlockItemRepairer extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityItemRepairer(); return new TileEntityItemRepairer();
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!world.isRemote) { if (!world.isRemote) {
TileEntityItemRepairer repairer = (TileEntityItemRepairer) world.getTileEntity(pos); TileEntityItemRepairer repairer = (TileEntityItemRepairer) world.getTileEntity(pos);
if (repairer != null) { if (repairer != null) {

View file

@ -160,7 +160,7 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay {
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
ItemStack stack = player.getHeldItem(hand); ItemStack stack = player.getHeldItem(hand);
TileEntity tile = world.getTileEntity(pos); TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityLaserRelay) { if (tile instanceof TileEntityLaserRelay) {

View file

@ -24,7 +24,6 @@ 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.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.relauncher.OnlyIn; import net.minecraftforge.fml.relauncher.OnlyIn;
@ -39,7 +38,7 @@ public class BlockLavaFactoryController extends BlockContainerBase implements IH
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityLavaFactoryController(); return new TileEntityLavaFactoryController();
} }

View file

@ -17,7 +17,6 @@ import net.minecraft.block.material.Material;
import net.minecraft.item.EnumRarity; 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.world.World;
public class BlockLeafGenerator extends BlockContainerBase { public class BlockLeafGenerator extends BlockContainerBase {
@ -30,7 +29,7 @@ public class BlockLeafGenerator extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityLeafGenerator(); return new TileEntityLeafGenerator();
} }

View file

@ -24,7 +24,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity; 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.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
@ -48,7 +47,7 @@ public class BlockMiner extends BlockContainerBase implements IHudDisplay {
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!world.isRemote) { if (!world.isRemote) {
TileEntity tile = world.getTileEntity(pos); TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityMiner) { if (tile instanceof TileEntityMiner) {

View file

@ -56,7 +56,7 @@ public class BlockOilGenerator extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityOilGenerator(); return new TileEntityOilGenerator();
} }
@ -74,7 +74,7 @@ public class BlockOilGenerator extends BlockContainerBase {
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!world.isRemote) { if (!world.isRemote) {
TileEntityOilGenerator generator = (TileEntityOilGenerator) world.getTileEntity(pos); TileEntityOilGenerator generator = (TileEntityOilGenerator) world.getTileEntity(pos);
if (generator != null) { if (generator != null) {

View file

@ -84,7 +84,7 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
switch (this.type) { switch (this.type) {
case PLACER: case PLACER:
return new TileEntityPhantomPlacer(); return new TileEntityPhantomPlacer();

View file

@ -41,7 +41,7 @@ public class BlockPlayerInterface extends BlockContainerBase implements IHudDisp
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityPlayerInterface(); return new TileEntityPlayerInterface();
} }

View file

@ -20,7 +20,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity; 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.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -36,12 +35,12 @@ public class BlockRangedCollector extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityRangedCollector(); return new TileEntityRangedCollector();
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (this.tryToggleRedstone(world, pos, player)) { if (this.tryToggleRedstone(world, pos, player)) {
return true; return true;
} }

View file

@ -62,7 +62,7 @@ public class BlockTreasureChest extends BlockBase {
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!world.isRemote) { if (!world.isRemote) {
world.playSound(null, pos, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.2F, world.rand.nextFloat() * 0.1F + 0.9F); world.playSound(null, pos, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.2F, world.rand.nextFloat() * 0.1F + 0.9F);
this.dropItems(world, pos); this.dropItems(world, pos);

View file

@ -41,12 +41,12 @@ public class BlockXPSolidifier extends BlockContainerBase {
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int par2) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileEntityXPSolidifier(); return new TileEntityXPSolidifier();
} }
@Override @Override
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction par6, float par7, float par8, float par9) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!world.isRemote) { if (!world.isRemote) {
TileEntityXPSolidifier solidifier = (TileEntityXPSolidifier) world.getTileEntity(pos); TileEntityXPSolidifier solidifier = (TileEntityXPSolidifier) world.getTileEntity(pos);
if (solidifier != null) { if (solidifier != null) {

View file

@ -0,0 +1,185 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import net.minecraft.block.Block;
import net.minecraft.util.math.shapes.IBooleanFunction;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import java.util.stream.Stream;
public class Shapes {
static final VoxelShape CANOLA_PRESS_SHAPE = Stream.of(
Block.makeCuboidShape(13, 0, 1, 15, 15.5, 3), Block.makeCuboidShape(2, 0, 2, 14, 6, 14),
Block.makeCuboidShape(2, 10, 2, 14, 15, 14), Block.makeCuboidShape(3, 6, 3, 13, 10, 13),
Block.makeCuboidShape(1, 0, 1, 3, 15.5, 3), Block.makeCuboidShape(1, 0, 13, 3, 15.5, 15),
Block.makeCuboidShape(13, 0, 13, 15, 15.5, 15), Block.makeCuboidShape(0.9, 0, 0.9, 3.1, 0.5, 3.1),
Block.makeCuboidShape(0.9, 0, 12.9, 3.1, 0.5, 15.1), Block.makeCuboidShape(0.9, 5, 12.9, 3.1, 6.5, 15.1),
Block.makeCuboidShape(0.9, 5, 0.9, 3.1, 6.5, 3.1), Block.makeCuboidShape(12.9, 5, 12.9, 15.1, 6.5, 15.1),
Block.makeCuboidShape(12.9, 5, 0.9, 15.1, 6.5, 3.1), Block.makeCuboidShape(0.9, 9.5, 12.9, 3.1, 11, 15.1),
Block.makeCuboidShape(0.9, 9.5, 0.9, 3.1, 11, 3.1), Block.makeCuboidShape(12.9, 9.5, 12.9, 15.1, 11, 15.1),
Block.makeCuboidShape(12.9, 9.5, 0.9, 15.1, 11, 3.1), Block.makeCuboidShape(12.9, 0, 0.9, 15.1, 0.5, 3.1),
Block.makeCuboidShape(12.9, 0, 12.9, 15.1, 0.5, 15.1), Block.makeCuboidShape(12.9, 15.5, 0.9, 15.1, 16, 3.1),
Block.makeCuboidShape(12.9, 15.5, 12.9, 15.1, 16, 15.1), Block.makeCuboidShape(0.9, 15.5, 0.9, 3.1, 16, 3.1),
Block.makeCuboidShape(0.9, 15.5, 12.9, 3.1, 16, 15.1)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
static final class CoalGeneratorShapes {
static final VoxelShape NORTH = 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(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(2, 0, 2, 14, 1, 14), Block.makeCuboidShape(5, 14, 6, 11, 15, 7),
Block.makeCuboidShape(5, 14, 8, 11, 15, 9), Block.makeCuboidShape(5, 14, 10, 11, 15, 14),
Block.makeCuboidShape(5, 14, 2, 11, 15, 5), Block.makeCuboidShape(11, 14, 2, 14, 15, 14),
Block.makeCuboidShape(2, 14, 2, 5, 15, 14), Block.makeCuboidShape(1, 0, 2, 2, 15, 14),
Block.makeCuboidShape(14, 0, 2, 15, 15, 14), Block.makeCuboidShape(1, 0, 14, 15, 15, 15),
Block.makeCuboidShape(3, 11, 0, 13, 12, 1), Block.makeCuboidShape(5, 3, 1, 6, 8, 2),
Block.makeCuboidShape(10, 3, 1, 11, 8, 2), Block.makeCuboidShape(3, 8, 1, 13, 15, 2),
Block.makeCuboidShape(3, 0, 1, 13, 3, 2), Block.makeCuboidShape(1, 0, 1, 3, 15, 2),
Block.makeCuboidShape(13, 0, 1, 15, 15, 2), Block.makeCuboidShape(5, 13, 5, 11, 14, 10),
Block.makeCuboidShape(2, 3, 2, 14, 8, 3), Block.makeCuboidShape(0, 0, 15, 1, 1, 16),
Block.makeCuboidShape(15, 0, 15, 16, 1, 16), Block.makeCuboidShape(15, 0, 0, 16, 1, 1),
Block.makeCuboidShape(0, 0, 0, 1, 1, 1)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
static final VoxelShape EAST = Stream.of(
Block.makeCuboidShape(0, 15, 0, 16, 16, 1), Block.makeCuboidShape(0, 15, 15, 16, 16, 16),
Block.makeCuboidShape(15, 15, 1, 16, 16, 15), Block.makeCuboidShape(0, 15, 1, 1, 16, 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(2, 0, 2, 14, 1, 14), Block.makeCuboidShape(9, 14, 5, 10, 15, 11),
Block.makeCuboidShape(7, 14, 5, 8, 15, 11), Block.makeCuboidShape(2, 14, 5, 6, 15, 11),
Block.makeCuboidShape(11, 14, 5, 14, 15, 11), Block.makeCuboidShape(2, 14, 11, 14, 15, 14),
Block.makeCuboidShape(2, 14, 2, 14, 15, 5), Block.makeCuboidShape(2, 0, 1, 14, 15, 2),
Block.makeCuboidShape(2, 0, 14, 14, 15, 15), Block.makeCuboidShape(1, 0, 1, 2, 15, 15),
Block.makeCuboidShape(15, 11, 3, 16, 12, 13), Block.makeCuboidShape(14, 3, 5, 15, 8, 6),
Block.makeCuboidShape(14, 3, 10, 15, 8, 11), Block.makeCuboidShape(14, 8, 3, 15, 15, 13),
Block.makeCuboidShape(14, 0, 3, 15, 3, 13), Block.makeCuboidShape(14, 0, 1, 15, 15, 3),
Block.makeCuboidShape(14, 0, 13, 15, 15, 15), Block.makeCuboidShape(6, 13, 5, 11, 14, 11),
Block.makeCuboidShape(13, 3, 2, 14, 8, 14), Block.makeCuboidShape(0, 0, 0, 1, 1, 1),
Block.makeCuboidShape(0, 0, 15, 1, 1, 16), Block.makeCuboidShape(15, 0, 15, 16, 1, 16),
Block.makeCuboidShape(15, 0, 0, 16, 1, 1)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
static final VoxelShape SOUTH = Stream.of(
Block.makeCuboidShape(15, 15, 0, 16, 16, 16), Block.makeCuboidShape(0, 15, 0, 1, 16, 16),
Block.makeCuboidShape(1, 15, 15, 15, 16, 16), Block.makeCuboidShape(1, 15, 0, 15, 16, 1),
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(2, 0, 2, 14, 1, 14), Block.makeCuboidShape(5, 14, 9, 11, 15, 10),
Block.makeCuboidShape(5, 14, 7, 11, 15, 8), Block.makeCuboidShape(5, 14, 2, 11, 15, 6),
Block.makeCuboidShape(5, 14, 11, 11, 15, 14), Block.makeCuboidShape(2, 14, 2, 5, 15, 14),
Block.makeCuboidShape(11, 14, 2, 14, 15, 14), Block.makeCuboidShape(14, 0, 2, 15, 15, 14),
Block.makeCuboidShape(1, 0, 2, 2, 15, 14), Block.makeCuboidShape(1, 0, 1, 15, 15, 2),
Block.makeCuboidShape(3, 11, 15, 13, 12, 16), Block.makeCuboidShape(10, 3, 14, 11, 8, 15),
Block.makeCuboidShape(5, 3, 14, 6, 8, 15), Block.makeCuboidShape(3, 8, 14, 13, 15, 15),
Block.makeCuboidShape(3, 0, 14, 13, 3, 15), Block.makeCuboidShape(13, 0, 14, 15, 15, 15),
Block.makeCuboidShape(1, 0, 14, 3, 15, 15), Block.makeCuboidShape(5, 13, 6, 11, 14, 11),
Block.makeCuboidShape(2, 3, 13, 14, 8, 14), Block.makeCuboidShape(15, 0, 0, 16, 1, 1),
Block.makeCuboidShape(0, 0, 0, 1, 1, 1), Block.makeCuboidShape(0, 0, 15, 1, 1, 16),
Block.makeCuboidShape(15, 0, 15, 16, 1, 16)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
static final VoxelShape WEST = Stream.of(
Block.makeCuboidShape(0, 15, 15, 16, 16, 16), Block.makeCuboidShape(0, 15, 0, 16, 16, 1),
Block.makeCuboidShape(0, 15, 1, 1, 16, 15), Block.makeCuboidShape(15, 15, 1, 16, 16, 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(2, 0, 2, 14, 1, 14), Block.makeCuboidShape(6, 14, 5, 7, 15, 11),
Block.makeCuboidShape(8, 14, 5, 9, 15, 11), Block.makeCuboidShape(10, 14, 5, 14, 15, 11),
Block.makeCuboidShape(2, 14, 5, 5, 15, 11), Block.makeCuboidShape(2, 14, 2, 14, 15, 5),
Block.makeCuboidShape(2, 14, 11, 14, 15, 14), Block.makeCuboidShape(2, 0, 14, 14, 15, 15),
Block.makeCuboidShape(2, 0, 1, 14, 15, 2), Block.makeCuboidShape(14, 0, 1, 15, 15, 15),
Block.makeCuboidShape(0, 11, 3, 1, 12, 13), Block.makeCuboidShape(1, 3, 10, 2, 8, 11),
Block.makeCuboidShape(1, 3, 5, 2, 8, 6), Block.makeCuboidShape(1, 8, 3, 2, 15, 13),
Block.makeCuboidShape(1, 0, 3, 2, 3, 13), Block.makeCuboidShape(1, 0, 13, 2, 15, 15),
Block.makeCuboidShape(1, 0, 1, 2, 15, 3), Block.makeCuboidShape(5, 13, 5, 10, 14, 11),
Block.makeCuboidShape(2, 3, 2, 3, 8, 14), Block.makeCuboidShape(15, 0, 15, 16, 1, 16),
Block.makeCuboidShape(15, 0, 0, 16, 1, 1), Block.makeCuboidShape(0, 0, 0, 1, 1, 1),
Block.makeCuboidShape(0, 0, 15, 1, 1, 16)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
}
static class CoffeeMachineShapes {
static final VoxelShape NORTH = Stream.of(
Block.makeCuboidShape(8, 11, 7, 13, 14, 8), Block.makeCuboidShape(1, 0, 1, 15, 1, 15),
Block.makeCuboidShape(7, 1, 8, 14, 9, 14), Block.makeCuboidShape(6, 9, 3, 15, 11, 15),
Block.makeCuboidShape(8, 11, 8, 13, 13, 13), Block.makeCuboidShape(10, 8, 3.5, 11, 9, 4.5),
Block.makeCuboidShape(9, 1, 2, 12, 2, 5), Block.makeCuboidShape(9, 2, 5, 12, 7, 6),
Block.makeCuboidShape(9, 2, 1, 12, 7, 2), Block.makeCuboidShape(12, 2, 2, 13, 7, 5),
Block.makeCuboidShape(8, 2, 2, 9, 7, 5), Block.makeCuboidShape(13, 2, 3, 14, 3, 4),
Block.makeCuboidShape(13, 5, 3, 14, 6, 4), Block.makeCuboidShape(14, 3, 3, 15, 5, 4),
Block.makeCuboidShape(13, 10.2, 4.2, 14, 11.2, 5.2), Block.makeCuboidShape(11, 10.2, 4.2, 12, 11.2, 5.2),
Block.makeCuboidShape(13, 11, 7, 14, 14, 14), Block.makeCuboidShape(7, 11, 7, 8, 14, 14),
Block.makeCuboidShape(8, 11, 13, 13, 14, 14), Block.makeCuboidShape(14, 1, 14, 15, 9, 15),
Block.makeCuboidShape(6, 1, 14, 7, 9, 15), Block.makeCuboidShape(14, 1, 7, 15, 9, 8),
Block.makeCuboidShape(6, 1, 7, 7, 9, 8), Block.makeCuboidShape(6.8, 1.9, 11.9, 7, 3.1, 13.1),
Block.makeCuboidShape(6.8, 1.9, 9.9, 7, 3.1, 11.1), Block.makeCuboidShape(3, 3, 10, 4, 5, 11),
Block.makeCuboidShape(2.9, 4.8, 9.9, 4.1, 5, 11.1), Block.makeCuboidShape(2.9, 4.8, 11.9, 4.1, 5, 13.1),
Block.makeCuboidShape(3, 2, 12, 7, 3, 13), Block.makeCuboidShape(3, 2, 10, 7, 3, 11),
Block.makeCuboidShape(3, 3, 12, 4, 5, 13), Block.makeCuboidShape(2, 5, 9, 5, 11, 14),
Block.makeCuboidShape(2, 11, 11, 4, 12, 13), Block.makeCuboidShape(1, 1, 11, 2, 12, 13)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
static final VoxelShape EAST = Stream.of(
Block.makeCuboidShape(8, 11, 8, 9, 14, 13), Block.makeCuboidShape(1, 0, 1, 15, 1, 15),
Block.makeCuboidShape(2, 1, 7, 8, 9, 14), Block.makeCuboidShape(1, 9, 6, 13, 11, 15),
Block.makeCuboidShape(3, 11, 8, 8, 13, 13), Block.makeCuboidShape(11.5, 8, 10, 12.5, 9, 11),
Block.makeCuboidShape(11, 1, 9, 14, 2, 12), Block.makeCuboidShape(10, 2, 9, 11, 7, 12),
Block.makeCuboidShape(14, 2, 9, 15, 7, 12), Block.makeCuboidShape(11, 2, 12, 14, 7, 13),
Block.makeCuboidShape(11, 2, 8, 14, 7, 9), Block.makeCuboidShape(12, 2, 13, 13, 3, 14),
Block.makeCuboidShape(12, 5, 13, 13, 6, 14), Block.makeCuboidShape(12, 3, 14, 13, 5, 15),
Block.makeCuboidShape(10.8, 10.2, 13, 11.8, 11.2, 14), Block.makeCuboidShape(10.8, 10.2, 11, 11.8, 11.2, 12),
Block.makeCuboidShape(2, 11, 13, 9, 14, 14), Block.makeCuboidShape(2, 11, 7, 9, 14, 8),
Block.makeCuboidShape(2, 11, 8, 3, 14, 13), Block.makeCuboidShape(1, 1, 14, 2, 9, 15),
Block.makeCuboidShape(1, 1, 6, 2, 9, 7), Block.makeCuboidShape(8, 1, 14, 9, 9, 15),
Block.makeCuboidShape(8, 1, 6, 9, 9, 7), Block.makeCuboidShape(2.9000000000000004, 1.9, 6.8, 4.1, 3.1, 7),
Block.makeCuboidShape(4.9, 1.9, 6.8, 6.1, 3.1, 7), Block.makeCuboidShape(5, 3, 3, 6, 5, 4),
Block.makeCuboidShape(4.9, 4.8, 2.9000000000000004, 6.1, 5, 4.1), Block.makeCuboidShape(2.9000000000000004, 4.8, 2.9000000000000004, 4.1, 5, 4.1),
Block.makeCuboidShape(3, 2, 3, 4, 3, 7), Block.makeCuboidShape(5, 2, 3, 6, 3, 7),
Block.makeCuboidShape(3, 3, 3, 4, 5, 4), Block.makeCuboidShape(2, 5, 2, 7, 11, 5),
Block.makeCuboidShape(3, 11, 2, 5, 12, 4), Block.makeCuboidShape(3, 1, 1, 5, 12, 2)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
static final VoxelShape SOUTH = Stream.of(
Block.makeCuboidShape(3, 11, 8, 8, 14, 9), Block.makeCuboidShape(1, 0, 1, 15, 1, 15),
Block.makeCuboidShape(2, 1, 2, 9, 9, 8), Block.makeCuboidShape(1, 9, 1, 10, 11, 13),
Block.makeCuboidShape(3, 11, 3, 8, 13, 8), Block.makeCuboidShape(5, 8, 11.5, 6, 9, 12.5),
Block.makeCuboidShape(4, 1, 11, 7, 2, 14), Block.makeCuboidShape(4, 2, 10, 7, 7, 11),
Block.makeCuboidShape(4, 2, 14, 7, 7, 15), Block.makeCuboidShape(3, 2, 11, 4, 7, 14),
Block.makeCuboidShape(7, 2, 11, 8, 7, 14), Block.makeCuboidShape(2, 2, 12, 3, 3, 13),
Block.makeCuboidShape(2, 5, 12, 3, 6, 13), Block.makeCuboidShape(1, 3, 12, 2, 5, 13),
Block.makeCuboidShape(2, 10.2, 10.8, 3, 11.2, 11.8), Block.makeCuboidShape(4, 10.2, 10.8, 5, 11.2, 11.8),
Block.makeCuboidShape(2, 11, 2, 3, 14, 9), Block.makeCuboidShape(8, 11, 2, 9, 14, 9),
Block.makeCuboidShape(3, 11, 2, 8, 14, 3), Block.makeCuboidShape(1, 1, 1, 2, 9, 2),
Block.makeCuboidShape(9, 1, 1, 10, 9, 2), Block.makeCuboidShape(1, 1, 8, 2, 9, 9),
Block.makeCuboidShape(9, 1, 8, 10, 9, 9), Block.makeCuboidShape(9, 1.9, 2.9000000000000004, 9.2, 3.1, 4.1),
Block.makeCuboidShape(9, 1.9, 4.9, 9.2, 3.1, 6.1), Block.makeCuboidShape(12, 3, 5, 13, 5, 6),
Block.makeCuboidShape(11.9, 4.8, 4.9, 13.1, 5, 6.1), Block.makeCuboidShape(11.9, 4.8, 2.9000000000000004, 13.1, 5, 4.1),
Block.makeCuboidShape(9, 2, 3, 13, 3, 4), Block.makeCuboidShape(9, 2, 5, 13, 3, 6),
Block.makeCuboidShape(12, 3, 3, 13, 5, 4), Block.makeCuboidShape(11, 5, 2, 14, 11, 7),
Block.makeCuboidShape(12, 11, 3, 14, 12, 5), Block.makeCuboidShape(14, 1, 3, 15, 12, 5)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
static final VoxelShape WEST = Stream.of(
Block.makeCuboidShape(7, 11, 3, 8, 14, 8), Block.makeCuboidShape(1, 0, 1, 15, 1, 15),
Block.makeCuboidShape(8, 1, 2, 14, 9, 9), Block.makeCuboidShape(3, 9, 1, 15, 11, 10),
Block.makeCuboidShape(8, 11, 3, 13, 13, 8), Block.makeCuboidShape(3.5, 8, 5, 4.5, 9, 6),
Block.makeCuboidShape(2, 1, 4, 5, 2, 7), Block.makeCuboidShape(5, 2, 4, 6, 7, 7),
Block.makeCuboidShape(1, 2, 4, 2, 7, 7), Block.makeCuboidShape(2, 2, 3, 5, 7, 4),
Block.makeCuboidShape(2, 2, 7, 5, 7, 8), Block.makeCuboidShape(3, 2, 2, 4, 3, 3),
Block.makeCuboidShape(3, 5, 2, 4, 6, 3), Block.makeCuboidShape(3, 3, 1, 4, 5, 2),
Block.makeCuboidShape(4.199999999999999, 10.2, 2, 5.199999999999999, 11.2, 3), Block.makeCuboidShape(4.199999999999999, 10.2, 4, 5.199999999999999, 11.2, 5),
Block.makeCuboidShape(7, 11, 2, 14, 14, 3), Block.makeCuboidShape(7, 11, 8, 14, 14, 9),
Block.makeCuboidShape(13, 11, 3, 14, 14, 8), Block.makeCuboidShape(14, 1, 1, 15, 9, 2),
Block.makeCuboidShape(14, 1, 9, 15, 9, 10), Block.makeCuboidShape(7, 1, 1, 8, 9, 2),
Block.makeCuboidShape(7, 1, 9, 8, 9, 10), Block.makeCuboidShape(11.9, 1.9, 9, 13.1, 3.1, 9.2),
Block.makeCuboidShape(9.9, 1.9, 9, 11.1, 3.1, 9.2), Block.makeCuboidShape(10, 3, 12, 11, 5, 13),
Block.makeCuboidShape(9.9, 4.8, 11.9, 11.1, 5, 13.1), Block.makeCuboidShape(11.9, 4.8, 11.9, 13.1, 5, 13.1),
Block.makeCuboidShape(12, 2, 9, 13, 3, 13), Block.makeCuboidShape(10, 2, 9, 11, 3, 13),
Block.makeCuboidShape(12, 3, 12, 13, 5, 13), Block.makeCuboidShape(9, 5, 11, 14, 11, 14),
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();
}
}

View file

@ -0,0 +1,50 @@
package de.ellpeck.actuallyadditions.mod.blocks.base;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction;
/**
* Wrapper for Directional block states extending from our base blocks. It's not super nice but it'll do.
*/
public abstract class DirectionalBlock extends BlockBase {
// public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
//
public DirectionalBlock(Properties properties) {
super(properties);
}
//
// @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 static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
public Container(Properties 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);
}
}
}

View file

@ -0,0 +1,50 @@
package de.ellpeck.actuallyadditions.mod.blocks.base;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
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.
*/
public abstract class FullyDirectionalBlock extends BlockBase {
// public static final DirectionProperty FACING = BlockStateProperties.FACING;
//
public FullyDirectionalBlock(Properties properties) {
super(properties);
}
//
// @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 static final DirectionProperty FACING = BlockStateProperties.FACING;
public Container(Properties 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);
}
}
}

View file

@ -16,4 +16,15 @@ public class ActuallyContainers {
public static final RegistryObject<ContainerType<ContainerBioReactor>> BIO_REACTOR_CONTAINER public static final RegistryObject<ContainerType<ContainerBioReactor>> BIO_REACTOR_CONTAINER
= CONTAINERS.register("bioreactor_container", () -> IForgeContainerType.create(ContainerBioReactor::fromNetwork)); = CONTAINERS.register("bioreactor_container", () -> IForgeContainerType.create(ContainerBioReactor::fromNetwork));
public static final RegistryObject<ContainerType<ContainerBreaker>> BREAKER_CONTAINER
= CONTAINERS.register("breaker_container", () -> IForgeContainerType.create(ContainerBreaker::fromNetwork));
public static final RegistryObject<ContainerType<ContainerCanolaPress>> CANOLA_PRESS_CONTAINER
= CONTAINERS.register("canola_press_container", () -> IForgeContainerType.create(ContainerCanolaPress::fromNetwork));
public static final RegistryObject<ContainerType<ContainerCoalGenerator>> COAL_GENERATOR_CONTAINER
= CONTAINERS.register("coal_generator_container", () -> IForgeContainerType.create(ContainerCoalGenerator::fromNetwork));
public static final RegistryObject<ContainerType<ContainerCoffeeMachine>> COFFEE_MACHINE_CONTAINER
= CONTAINERS.register("coffee_machine_container", () -> IForgeContainerType.create(ContainerCoffeeMachine::fromNetwork));
} }

View file

@ -11,35 +11,43 @@
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.TileEntityBreaker; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker;
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 ContainerBreaker extends Container { public class ContainerBreaker extends Container {
private final TileEntityBreaker breaker; public final TileEntityBreaker breaker;
public ContainerBreaker(PlayerInventory inventory, TileEntityBase tile) { public static ContainerBreaker fromNetwork(int windowId, PlayerInventory inv, PacketBuffer data) {
this.breaker = (TileEntityBreaker) tile; return new ContainerBreaker(windowId, inv, (TileEntityBreaker) Objects.requireNonNull(inv.player.world.getTileEntity(data.readBlockPos())));
}
public ContainerBreaker(int windowId, PlayerInventory inventory, TileEntityBreaker tile) {
super(ActuallyContainers.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, 62 + j * 18, 21 + i * 18)); this.addSlot(new SlotItemHandlerUnconditioned(this.breaker.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));
} }
} }

View file

@ -12,32 +12,38 @@ 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.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress;
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 ContainerCanolaPress extends Container { public class ContainerCanolaPress extends Container {
private final TileEntityCanolaPress press; private final TileEntityCanolaPress press;
public ContainerCanolaPress(PlayerInventory inventory, TileEntityBase tile) { public static ContainerCanolaPress fromNetwork(int windowId, PlayerInventory inv, PacketBuffer data) {
this.press = (TileEntityCanolaPress) tile; return new ContainerCanolaPress(windowId, inv, (TileEntityCanolaPress) Objects.requireNonNull(inv.player.world.getTileEntity(data.readBlockPos())));
}
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.press.inv, 0, 81, 10)); public ContainerCanolaPress(int windowId, PlayerInventory inventory, TileEntityCanolaPress tile) {
super(ActuallyContainers.CANOLA_PRESS_CONTAINER.get(), windowId);
this.press = tile;
this.addSlot(new SlotItemHandlerUnconditioned(this.press.inv, 0, 81, 10));
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));
} }
} }
@ -57,7 +63,7 @@ public class ContainerCanolaPress extends Container {
//Other Slots in Inventory excluded //Other Slots in Inventory excluded
if (slot >= inventoryStart) { if (slot >= inventoryStart) {
//Shift from Inventory //Shift from Inventory
if (newStack.getItem() == InitItems.itemMisc && newStack.getItemDamage() == TheMiscItems.CANOLA.ordinal()) { if (newStack.getItem() == InitItems.itemCanola.get()) {
if (!this.mergeItemStack(newStack, 0, 1, false)) { if (!this.mergeItemStack(newStack, 0, 1, false)) {
return StackUtil.getEmpty(); return StackUtil.getEmpty();
} }

View file

@ -11,32 +11,39 @@
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.TileEntityCoalGenerator; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator;
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.tileentity.TileEntityFurnace; import net.minecraft.network.PacketBuffer;
import net.minecraftforge.common.ForgeHooks;
import java.util.Objects;
public class ContainerCoalGenerator extends Container { public class ContainerCoalGenerator extends Container {
private final TileEntityCoalGenerator generator; private final TileEntityCoalGenerator generator;
public ContainerCoalGenerator(PlayerInventory inventory, TileEntityBase tile) { public static ContainerCoalGenerator fromNetwork(int windowId, PlayerInventory inv, PacketBuffer data) {
this.generator = (TileEntityCoalGenerator) tile; return new ContainerCoalGenerator(windowId, inv, (TileEntityCoalGenerator) Objects.requireNonNull(inv.player.world.getTileEntity(data.readBlockPos())));
}
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.generator.inv, 0, 87, 43)); public ContainerCoalGenerator(int windowId, PlayerInventory inventory, TileEntityCoalGenerator tile) {
super(ActuallyContainers.COAL_GENERATOR_CONTAINER.get(), windowId);
this.generator = tile;
this.addSlot(new SlotItemHandlerUnconditioned(this.generator.inv, 0, 87, 43));
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));
} }
} }
@ -56,7 +63,7 @@ public class ContainerCoalGenerator extends Container {
//Other Slots in Inventory excluded //Other Slots in Inventory excluded
if (slot >= inventoryStart) { if (slot >= inventoryStart) {
//Shift from Inventory //Shift from Inventory
if (TileEntityFurnace.getItemBurnTime(newStack) > 0) { if (ForgeHooks.getBurnTime(newStack) > 0) {
if (!this.mergeItemStack(newStack, 0, 1, false)) { if (!this.mergeItemStack(newStack, 0, 1, false)) {
return StackUtil.getEmpty(); return StackUtil.getEmpty();
} }

View file

@ -15,40 +15,46 @@ import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditio
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee; import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
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 ContainerCoffeeMachine extends Container { public class ContainerCoffeeMachine extends Container {
private final TileEntityCoffeeMachine machine; public final TileEntityCoffeeMachine machine;
public ContainerCoffeeMachine(PlayerInventory inventory, TileEntityBase tile) { public static ContainerCoffeeMachine fromNetwork(int windowId, PlayerInventory inv, PacketBuffer data) {
this.machine = (TileEntityCoffeeMachine) tile; return new ContainerCoffeeMachine(windowId, inv, (TileEntityCoffeeMachine) Objects.requireNonNull(inv.player.world.getTileEntity(data.readBlockPos())));
}
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.inv, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS, 37, 6)); public ContainerCoffeeMachine(int windowId, PlayerInventory inventory, TileEntityCoffeeMachine tile) {
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.inv, TileEntityCoffeeMachine.SLOT_INPUT, 80, 42)); super(ActuallyContainers.COFFEE_MACHINE_CONTAINER.get(), windowId);
this.addSlotToContainer(new SlotOutput(this.machine.inv, TileEntityCoffeeMachine.SLOT_OUTPUT, 80, 73)); this.machine = tile;
this.addSlot(new SlotItemHandlerUnconditioned(this.machine.inv, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS, 37, 6));
this.addSlot(new SlotItemHandlerUnconditioned(this.machine.inv, TileEntityCoffeeMachine.SLOT_INPUT, 80, 42));
this.addSlot(new SlotOutput(this.machine.inv, TileEntityCoffeeMachine.SLOT_OUTPUT, 80, 73));
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
for (int j = 0; j < 2; j++) { for (int j = 0; j < 2; j++) {
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.inv, j + i * 2 + 3, 125 + j * 18, 6 + i * 18)); this.addSlot(new SlotItemHandlerUnconditioned(this.machine.inv, j + i * 2 + 3, 125 + j * 18, 6 + 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));
} }
} }
@ -75,7 +81,7 @@ public class ContainerCoffeeMachine 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.getItem() == InitItems.itemMisc && newStack.getItemDamage() == TheMiscItems.CUP.ordinal()) { if (newStack.getItem() == InitItems.itemCoffeeCup.get()) {
if (!this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_INPUT, TileEntityCoffeeMachine.SLOT_INPUT + 1, false)) { if (!this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_INPUT, TileEntityCoffeeMachine.SLOT_INPUT + 1, false)) {
return StackUtil.getEmpty(); return StackUtil.getEmpty();
} }

View file

@ -10,41 +10,43 @@
package de.ellpeck.actuallyadditions.mod.inventory.gui; package de.ellpeck.actuallyadditions.mod.inventory.gui;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerBreaker; import de.ellpeck.actuallyadditions.mod.inventory.ContainerBreaker;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.OnlyIn; import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class GuiBreaker extends GuiWtfMojang { public class GuiBreaker extends GuiWtfMojang<ContainerBreaker> {
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_breaker"); private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_breaker");
private final TileEntityBreaker breaker; private final TileEntityBreaker breaker;
public GuiBreaker(PlayerInventory inventory, TileEntityBase tile) { public GuiBreaker(ContainerBreaker container, PlayerInventory inventory, ITextComponent title) {
super(new ContainerBreaker(inventory, tile)); super(container, inventory);
this.breaker = (TileEntityBreaker) tile; this.breaker = container.breaker;
this.xSize = 176; this.xSize = 176;
this.ySize = 93 + 86; this.ySize = 93 + 86;
} }
@Override @Override
public void drawGuiContainerForegroundLayer(int x, int y) { protected void drawGuiContainerForegroundLayer(MatrixStack matrices, int x, int y) {
AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.breaker); AssetUtil.displayNameString(matrices, this.font, this.xSize, -10, this.breaker);
} }
@Override @Override
public void drawGuiContainerBackgroundLayer(float f, int x, int y) { protected void drawGuiContainerBackgroundLayer(MatrixStack matrices, float partialTicks, int x, int y) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); this.getMinecraft().getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION);
this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.blit(matrices, this.guiLeft, this.guiTop + 93, 0, 0, 176, 86);
this.mc.getTextureManager().bindTexture(RES_LOC); this.getMinecraft().getTextureManager().bindTexture(RES_LOC);
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); this.blit(matrices, this.guiLeft, this.guiTop, 0, 0, 176, 93);
} }
} }

View file

@ -31,6 +31,7 @@ public final class InitItems {
// REMOVE ME // REMOVE ME
@Deprecated @Deprecated
public static final RegistryObject<Item> itemMisc = ITEMS.register("item_misc", ItemBase::new); public static final RegistryObject<Item> itemMisc = ITEMS.register("item_misc", ItemBase::new);
public static final RegistryObject<Item> itemCanola = ITEMS.register("canola", ItemBase::new);
public static final RegistryObject<Item> itemCoffeeCup = ITEMS.register("coffee_cup", ItemBase::new); public static final RegistryObject<Item> itemCoffeeCup = ITEMS.register("coffee_cup", ItemBase::new);
// SHARDS // SHARDS

View file

@ -10,23 +10,31 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerBreaker;
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.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
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.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidBlock;
import javax.annotation.Nullable;
import java.util.List; import java.util.List;
public class TileEntityBreaker extends TileEntityInventoryBase { public class TileEntityBreaker extends TileEntityInventoryBase implements INamedContainerProvider {
public boolean isPlacer; public boolean isPlacer;
private int currentTime; private int currentTime;
@ -114,4 +122,14 @@ public class TileEntityBreaker extends TileEntityInventoryBase {
this.doWork(); this.doWork();
} }
@Override
public ITextComponent getDisplayName() {
return StringTextComponent.EMPTY;
}
@Nullable
@Override
public Container createMenu(int windowId, PlayerInventory playerInventory, PlayerEntity playerEntity) {
return new ContainerBreaker(windowId, playerInventory, this);
}
} }

View file

@ -11,14 +11,21 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerCanolaPress;
import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.InitItems;
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 de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.Util;
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.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
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.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
@ -27,7 +34,9 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.templates.FluidTank; import net.minecraftforge.fluids.capability.templates.FluidTank;
public class TileEntityCanolaPress extends TileEntityInventoryBase implements ISharingFluidHandler { import javax.annotation.Nullable;
public class TileEntityCanolaPress extends TileEntityInventoryBase implements INamedContainerProvider, ISharingFluidHandler {
public static final int PRODUCE = 80; public static final int PRODUCE = 80;
public static final int ENERGY_USE = 35; public static final int ENERGY_USE = 35;
@ -101,7 +110,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS
this.inv.setStackInSlot(0, StackUtil.shrink(this.inv.getStackInSlot(0), 1)); this.inv.setStackInSlot(0, StackUtil.shrink(this.inv.getStackInSlot(0), 1));
this.tank.fill(new FluidStack(InitFluids.fluidCanolaOil, PRODUCE), IFluidHandler.FluidAction.EXECUTE); this.tank.fill(new FluidStack(InitFluids.fluidCanolaOil.get(), PRODUCE), IFluidHandler.FluidAction.EXECUTE);
this.markDirty(); this.markDirty();
} }
} }
@ -123,7 +132,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS
} }
public static boolean isCanola(ItemStack stack) { public static boolean isCanola(ItemStack stack) {
return stack.getItem() == InitItems.itemCanola; return stack.getItem() == InitItems.itemCanola.get();
} }
@Override @Override
@ -155,4 +164,15 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS
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 ContainerCanolaPress(windowId, playerInventory, this);
}
} }

View file

@ -11,20 +11,29 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerCoalGenerator;
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.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.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
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.ForgeHooks; import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.energy.IEnergyStorage;
public class TileEntityCoalGenerator extends TileEntityInventoryBase implements ISharingEnergyProvider { import javax.annotation.Nullable;
public class TileEntityCoalGenerator extends TileEntityInventoryBase implements INamedContainerProvider, ISharingEnergyProvider {
public final CustomEnergyStorage storage = new CustomEnergyStorage(60000, 0, 80); public final CustomEnergyStorage storage = new CustomEnergyStorage(60000, 0, 80);
public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage); public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
@ -158,4 +167,15 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
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 player) {
return new ContainerCoalGenerator(windowId, playerInventory, this);
}
} }

View file

@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.api.ActuallyTags; import de.ellpeck.actuallyadditions.api.ActuallyTags;
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerCoffeeMachine;
import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee; import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
@ -22,11 +23,16 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.fluid.Fluids; import net.minecraft.fluid.Fluids;
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.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
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.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
@ -36,8 +42,9 @@ import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.templates.FluidTank; import net.minecraftforge.fluids.capability.templates.FluidTank;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements IButtonReactor, ISharingFluidHandler { public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements INamedContainerProvider, IButtonReactor, ISharingFluidHandler {
public static final int SLOT_COFFEE_BEANS = 0; public static final int SLOT_COFFEE_BEANS = 0;
public static final int SLOT_INPUT = 1; public static final int SLOT_INPUT = 1;
@ -232,4 +239,15 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
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 player) {
return new ContainerCoffeeMachine(windowId, playerInventory, this);
}
} }

View file

@ -17,35 +17,26 @@ import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient; import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient;
import de.ellpeck.actuallyadditions.mod.particle.ParticleBeam; import de.ellpeck.actuallyadditions.mod.particle.ParticleBeam;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager.DestFactor;
import net.minecraft.client.renderer.GlStateManager.SourceFactor;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockAccess;
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.client.ForgeHooksClient; import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.network.NetworkRegistry;
import net.minecraftforge.fml.relauncher.OnlyIn;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
public final class AssetUtil { public final class AssetUtil {
@ -64,19 +55,18 @@ public final class AssetUtil {
} }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static void displayNameString(FontRenderer font, int xSize, int yPositionOfMachineText, String text) { public static void displayNameString(MatrixStack matrices, FontRenderer font, int xSize, int yPositionOfMachineText, String text) {
font.drawString(text, xSize / 2 - font.getStringWidth(text) / 2, yPositionOfMachineText, StringUtil.DECIMAL_COLOR_WHITE); font.drawString(matrices, text, xSize / 2f - font.getStringWidth(text) / 2f, yPositionOfMachineText, StringUtil.DECIMAL_COLOR_WHITE);
} }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static void displayNameString(FontRenderer font, int xSize, int yPositionOfMachineText, TileEntityBase tile) { public static void displayNameString(MatrixStack matrices, FontRenderer font, int xSize, int yPositionOfMachineText, TileEntityBase tile) {
displayNameString(font, xSize, yPositionOfMachineText, StringUtil.localize(tile.getNameForTranslation())); displayNameString(matrices, font, xSize, yPositionOfMachineText, StringUtil.localize(tile.getNameForTranslation()));
} }
@OnlyIn(Dist.CLIENT) // public static void renderBlockInWorld(Block block, int meta) {
public static void renderBlockInWorld(Block block, int meta) { // renderItemInWorld(new ItemStack(block, 1, meta), combinedLightIn, combinedOverlayIn, matrices, buffer);
renderItemInWorld(new ItemStack(block, 1, meta), combinedLightIn, combinedOverlayIn, matrices, buffer); // }
}
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static void renderItemInWorld(ItemStack stack, int combinedLight, int combinedOverlay, MatrixStack matrices, IRenderTypeBuffer buffer) { public static void renderItemInWorld(ItemStack stack, int combinedLight, int combinedOverlay, MatrixStack matrices, IRenderTypeBuffer buffer) {
@ -87,19 +77,19 @@ public final class AssetUtil {
} }
} }
@OnlyIn(Dist.CLIENT) // @OnlyIn(Dist.CLIENT)
public static void renderStateInWorld(BlockState state, IBlockAccess world, BlockPos pos, float brightness) { // public static void renderStateInWorld(BlockState state, IWorldReader world, BlockPos pos, float brightness) {
Minecraft.getInstance().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); // Minecraft.getInstance().getTextureManager().bindTexture(PlayerContainer.LOCATION_BLOCKS_TEXTURE);
IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(state); // IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(state);
GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F); // GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
int i = Minecraft.getInstance().getBlockColors().colorMultiplier(state, world, pos, 0); // int i = Minecraft.getInstance().getBlockColors().colorMultiplier(state, world, pos, 0);
//
float r = (i >> 16 & 255) / 255F; // float r = (i >> 16 & 255) / 255F;
float g = (i >> 8 & 255) / 255F; // float g = (i >> 8 & 255) / 255F;
float b = (i & 255) / 255F; // float b = (i & 255) / 255F;
//
Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(state, model, brightness, r, g, b); // Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(state, model, brightness, r, g, b);
} // }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static void renderItemWithoutScrewingWithColors(ItemStack stack) { public static void renderItemWithoutScrewingWithColors(ItemStack stack) {