Merge remote-tracking branch 'origin/master'

This commit is contained in:
Michael 2020-09-09 15:34:40 +01:00
commit 4c439f5b56
No known key found for this signature in database
GPG Key ID: 971C5B254742488F
27 changed files with 373 additions and 573 deletions

View File

@ -3,43 +3,42 @@ package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDirectional;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.Rarity;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.ActionResultType;
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.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.List;
@ -55,20 +54,13 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
.harvestTool(ToolType.PICKAXE)
.sound(SoundType.STONE));
}
// @Override
// public boolean isOpaqueCube(IBlockState state) {
// return false;
// }
@Override
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit){
ItemStack heldItem = player.getHeldItem(hand);
if (this.tryToggleRedstone(world, pos, player)) {
return ActionResultType.SUCCESS;
}
if (!world.isRemote) {
TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor) world.getTileEntity(pos);
if (reconstructor != null) {
@ -96,120 +88,62 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
}
return ActionResultType.SUCCESS;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
public TileEntity createTileEntity(BlockState state, IBlockReader world){
return new TileEntityAtomicReconstructor();
}
@Override
@OnlyIn(Dist.CLIENT)
public void displayHud(Minecraft minecraft, PlayerEntity player, ItemStack stack, RayTraceResult posHit, int scaledWidth, int scaledHeight) {
TileEntity tile = minecraft.world.getTileEntity(((BlockRayTraceResult) posHit).getPos());
public void displayHud(Minecraft minecraft, PlayerEntity player, ItemStack stack, BlockRayTraceResult posHit, MainWindow window) {
TileEntity tile = minecraft.world.getTileEntity(posHit.getPos());
if (tile instanceof TileEntityAtomicReconstructor) {
ItemStack slot = ((TileEntityAtomicReconstructor) tile).inv.getStackInSlot(0);
String strg;
ITextComponent displayString;
if (!StackUtil.isValid(slot)) {
strg = StringUtil.localize("info." + ActuallyAdditions.MODID + ".noLens");
displayString = new TranslationTextComponent("info." + ActuallyAdditions.MODID + ".noLens");
} else {
strg = slot.getItem().getItemStackDisplayName(slot);
displayString = slot.getItem().getDisplayName(slot);
AssetUtil.renderStackToGui(slot, resolution.getScaledWidth() / 2 + 15, resolution.getScaledHeight() / 2 - 19, 1F);
AssetUtil.renderStackToGui(slot, window.getScaledWidth() / 2 + 15, window.getScaledHeight() / 2 - 19, 1F);
}
minecraft.fontRenderer.drawStringWithShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg, resolution.getScaledWidth() / 2 + 35, resolution.getScaledHeight() / 2 - 15, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.fontRenderer.drawStringWithShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + displayString.getFormattedText(), window.getScaledWidth() / 2 + 35, window.getScaledHeight() / 2 - 15, StringUtil.DECIMAL_COLOR_WHITE);
}
}
@Override
protected ItemBlockBase getItemBlock() {
return new TheItemBlock(this);
protected BlockItemBase getItemBlock() {
return new BlockItem();
}
@Override
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
public Rarity getRarity(){
return Rarity.EPIC;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
int rotation = EnumFacing.getDirectionFromEntityLiving(pos, player).ordinal();
world.setBlockState(pos, this.getStateFromMeta(rotation), 2);
super.onBlockPlacedBy(world, pos, state, player, stack);
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder){
builder.add(BlockStateProperties.FACING);
}
@Override
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta));
public BlockState rotate(BlockState state, Rotation rot){
return state.with(BlockStateProperties.FACING, rot.rotate(state.get(BlockStateProperties.FACING)));
}
@Override
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockDirectional.FACING).getIndex();
public BlockState mirror(BlockState state, Mirror mirrorIn){
return this.rotate(state, mirrorIn.toRotation(state.get(BlockStateProperties.FACING)));
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockDirectional.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING)));
}
public static class TheItemBlock extends ItemBlockBase {
private long lastSysTime;
private int toPick1;
private int toPick2;
public TheItemBlock(Block block) {
super(block);
this.setHasSubtypes(false);
this.setMaxDamage(0);
}
@Override
public String getTranslationKey(ItemStack stack) {
return this.getTranslationKey();
}
@Override
public int getMetadata(int damage) {
return damage;
}
@Override
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag advanced) {
long sysTime = System.currentTimeMillis();
if (this.lastSysTime + 3000 < sysTime) {
this.lastSysTime = sysTime;
if (world != null) {
this.toPick1 = world.rand.nextInt(NAME_FLAVOR_AMOUNTS_1) + 1;
this.toPick2 = world.rand.nextInt(NAME_FLAVOR_AMOUNTS_2) + 1;
}
}
String base = "tile." + ActuallyAdditions.MODID + "." + ((BlockAtomicReconstructor) this.block).getBaseName() + ".info.";
tooltip.add(StringUtil.localize(base + "1." + this.toPick1) + " " + StringUtil.localize(base + "2." + this.toPick2));
}
}
@Override
public boolean hasComparatorInputOverride(IBlockState state) {
public boolean hasComparatorInputOverride(BlockState state){
return true;
}
@Override
public int getComparatorInputOverride(IBlockState blockState, World world, BlockPos pos) {
public int getComparatorInputOverride(BlockState blockState, World world, BlockPos pos) {
TileEntity t = world.getTileEntity(pos);
int i = 0;
if (t instanceof TileEntityAtomicReconstructor) {
@ -217,4 +151,32 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
}
return MathHelper.clamp(i / 20000, 0, 15);
}
public class BlockItem extends BlockItemBase {
private long lastSysTime;
private int toPick1;
private int toPick2;
public BlockItem() {
super(BlockAtomicReconstructor.this, new Properties());
}
@Override
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag){
long sysTime = System.currentTimeMillis();
if (this.lastSysTime + 3000 < sysTime) {
this.lastSysTime = sysTime;
if (world != null) {
this.toPick1 = world.rand.nextInt(NAME_FLAVOR_AMOUNTS_1) + 1;
this.toPick2 = world.rand.nextInt(NAME_FLAVOR_AMOUNTS_2) + 1;
}
}
String base = String.format("tile.%s.%s.info", ActuallyAdditions.MODID, BlockAtomicReconstructor.this.getRegistryName().getPath());
tooltip.add(new TranslationTextComponent(String.format("%s1.%s", base, this.toPick1)).appendSibling(new TranslationTextComponent(String.format("%s2.%s", base, this.toPick2))));
}
}
}

View File

@ -4,82 +4,75 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.items.ItemBattery;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBatteryBox;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Rarity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import javax.annotation.Nullable;
// todo add rarity RARE
public class BlockBatteryBox extends BlockContainerBase {
public static final VoxelShape SHAPE = Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D);
public BlockBatteryBox() {
super(Properties.create(Material.ROCK)
.hardnessAndResistance(1.5f, 10.0f)
.harvestLevel(0)
.harvestTool(ToolType.PICKAXE)
.sound(SoundType.STONE));
// this.setHarvestLevel("pickaxe", 0);
// this.setHardness(1.5F);
// this.setResistance(10.0F);
// this.setSoundType(SoundType.STONE);
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return BlockSlabs.AABB_BOTTOM_HALF;
public Rarity getRarity(){
return Rarity.RARE;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context){
return SHAPE;
}
@Override
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit){
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityBatteryBox) {
TileEntityBatteryBox box = (TileEntityBatteryBox) tile;
ItemStack stack = player.getHeldItem(hand);
if (StackUtil.isValid(stack)) {
if (stack.getItem() instanceof ItemBattery && !StackUtil.isValid(box.inv.getStackInSlot(0))) {
box.inv.setStackInSlot(0, stack.copy());
player.setHeldItem(hand, StackUtil.getEmpty());
return true;
return ActionResultType.SUCCESS;
}
} else {
ItemStack inSlot = box.inv.getStackInSlot(0);
if (StackUtil.isValid(inSlot)) {
player.setHeldItem(hand, inSlot.copy());
box.inv.setStackInSlot(0, StackUtil.getEmpty());
return true;
return ActionResultType.SUCCESS;
}
}
}
return false;
return super.onBlockActivated(state, world, pos, player, hand, hit);
}
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
@Nullable
@Override
public TileEntity createNewTileEntity(IBlockReader worldIn) {
public TileEntity createTileEntity(BlockState state, IBlockReader world){
return new TileEntityBatteryBox();
}
}

View File

@ -1,19 +1,18 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBioReactor;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Rarity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
@ -25,24 +24,24 @@ public class BlockBioReactor extends BlockContainerBase {
.harvestTool(ToolType.PICKAXE)
.sound(SoundType.STONE));
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
public TileEntity createTileEntity(BlockState state, IBlockReader world){
return new TileEntityBioReactor();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing 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.getTileEntity(pos) instanceof TileEntityBioReactor) {
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BIO_REACTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
// todo open gui: player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BIO_REACTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}
return true;
return ActionResultType.SUCCESS;
}
@Override
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
public Rarity getRarity() {
return Rarity.EPIC;
}
}

View File

@ -1,11 +1,9 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.Properties;
import java.util.Random;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
@ -103,7 +101,7 @@ public class BlockColoredLamp extends Block {
}
@Override
protected ItemBlockBase getItemBlock() {
protected BlockItemBase getItemBlock() {
return new TheItemBlock(this);
}
@ -134,7 +132,7 @@ public class BlockColoredLamp extends Block {
return new BlockStateContainer(this, TYPE);
}
public static class TheItemBlock extends ItemBlockBase {
public static class TheItemBlock extends BlockItemBase {
public TheItemBlock(Block block) {
super(block);

View File

@ -1,8 +1,7 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
@ -50,7 +49,7 @@ public class BlockCrystal extends Block {
}
@Override
protected ItemBlockBase getItemBlock() {
protected BlockItemBase getItemBlock() {
return new TheItemBlock(this);
}
@ -76,7 +75,7 @@ public class BlockCrystal extends Block {
return new BlockStateContainer(this, TYPE);
}
public static class TheItemBlock extends ItemBlockBase {
public static class TheItemBlock extends BlockItemBase {
public TheItemBlock(Block block) {
super(block);

View File

@ -1,40 +1,23 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Direction;
import org.apache.commons.lang3.ArrayUtils;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.gen.WorldGenLushCaves;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
import de.ellpeck.actuallyadditions.mod.util.IColorProvidingBlock;
import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem;
import net.minecraft.block.BlockDirectional;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.world.IBlockReader;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockCrystalCluster extends Block implements IColorProvidingBlock, IColorProvidingItem {
@ -47,93 +30,68 @@ public class BlockCrystalCluster extends Block implements IColorProvidingBlock,
.lightValue(7));
this.crystal = crystal;
// this.setHardness(0.25F);
// this.setResistance(1.0F);
// this.setSoundType(SoundType.GLASS);
// this.setLightOpacity(1);
// this.setLightLevel(0.7F);
}
// @Override
// public boolean isFullCube(BlockState state) {
// return false;
// }
//
// @Override
// public boolean isOpaqueCube(BlockState state) {
// return false;
// }
@Override
public BlockState getStateForPlacement(World world, BlockPos pos, Direction side, float hitX, float hitY, float hitZ, int meta, LivingEntity base) {
return this.getStateFromMeta(side.ordinal());
public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos){
return 1;
}
@Override
public BlockState getStateForPlacement(BlockItemUseContext context){
return super.getStateForPlacement(context).with(BlockStateProperties.FACING, context.getPlacementHorizontalFacing().getOpposite());
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder){
builder.add(BlockStateProperties.FACING);
}
@Override
public BlockState rotate(BlockState state, Rotation rot){
return state.with(BlockStateProperties.FACING, rot.rotate(state.get(BlockStateProperties.FACING)));
}
@Override
public BlockState mirror(BlockState state, Mirror mirror){
return this.rotate(state, mirror.toRotation(state.get(BlockStateProperties.FACING)));
}
@Override
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta));
}
@Override
public int getMetaFromState(IBlockState state) {
return state.getValue(BlockDirectional.FACING).getIndex();
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, BlockDirectional.FACING);
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot) {
return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirror) {
return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING)));
}
@Override
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public IBlockColor getBlockColor() {
return (state, world, pos, tintIndex) -> BlockCrystalCluster.this.crystal.clusterColor;
}
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.TRANSLUCENT;
}
@Override
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public IItemColor getItemColor() {
return (stack, tintIndex) -> BlockCrystalCluster.this.crystal.clusterColor;
}
/* todo canitzp: realise block drops with loot tables
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
public Item getItemDropped(BlockState state, Random rand, int fortune) {
return InitItems.itemCrystalShard;
}
@Override
public int damageDropped(IBlockState state) {
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder){
return Collections.singletonList(new ItemStack(InitItems.itemCrystalShard, new Random().nextInt(5) + 2));
}
@Override
public int damageDropped(BlockState state) {
return ArrayUtils.indexOf(WorldGenLushCaves.CRYSTAL_CLUSTERS, this);
}
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
return new ItemStack(this);
public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player){
super.onBlockHarvested(worldIn, pos, state, player);
}
@Override
public int quantityDropped(Random random) {
return random.nextInt(5) + 2;
}
@Override
public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
return true;
}
}*/
}

View File

@ -2,7 +2,7 @@ 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.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceDouble;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
@ -116,11 +116,11 @@ public class BlockFurnaceDouble extends BlockContainerBase {
}
@Override
protected ItemBlockBase getItemBlock() {
protected BlockItemBase getItemBlock() {
return new TheItemBlock(this);
}
public static class TheItemBlock extends ItemBlockBase {
public static class TheItemBlock extends BlockItemBase {
public TheItemBlock(Block block) {
super(block);

View File

@ -2,7 +2,7 @@ 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.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInputter;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInputterAdvanced;
@ -58,7 +58,7 @@ public class BlockInputter extends BlockContainerBase {
}
@Override
protected ItemBlockBase getItemBlock() {
protected BlockItemBase getItemBlock() {
return new TheItemBlock(this);
}
@ -67,7 +67,7 @@ public class BlockInputter extends BlockContainerBase {
return EnumRarity.EPIC;
}
public static class TheItemBlock extends ItemBlockBase {
public static class TheItemBlock extends BlockItemBase {
private final Random rand = new Random();
private long lastSysTime;

View File

@ -1,8 +1,7 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
@ -42,7 +41,7 @@ public class BlockMisc extends Block {
}
@Override
protected ItemBlockBase getItemBlock() {
protected BlockItemBase getItemBlock() {
return new TheItemBlock(this);
}
@ -73,7 +72,7 @@ public class BlockMisc extends Block {
return new BlockStateContainer(this, TYPE);
}
public static class TheItemBlock extends ItemBlockBase {
public static class TheItemBlock extends BlockItemBase {
public TheItemBlock(Block block) {
super(block);

View File

@ -1,12 +1,11 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
@ -19,15 +18,15 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockSlabs extends Block {
public static final AxisAlignedBB AABB_BOTTOM_HALF = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.5D, 1.0D);
public static final VoxelShape AABB_BOTTOM_HALF = Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D);
private static final AxisAlignedBB AABB_TOP_HALF = new AxisAlignedBB(0.0D, 0.5D, 0.0D, 1.0D, 1.0D, 1.0D);
private final BlockState fullBlockState;
@ -68,7 +67,7 @@ public class BlockSlabs extends Block {
}
@Override
protected ItemBlockBase getItemBlock() {
protected BlockItemBase getItemBlock() {
return new TheItemBlock(this);
}
@ -92,7 +91,7 @@ public class BlockSlabs extends Block {
return new BlockStateContainer(this, BlockSlab.HALF);
}
public static class TheItemBlock extends ItemBlockBase {
public static class TheItemBlock extends BlockItemBase {
public TheItemBlock(Block block) {
super(block);

View File

@ -3,12 +3,11 @@ package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBushBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheWildPlants;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
@ -66,7 +65,7 @@ public class BlockWildPlant extends BlockBushBase {
}
@Override
protected ItemBlockBase getItemBlock() {
protected BlockItemBase getItemBlock() {
return new TheItemBlock(this);
}
@ -102,7 +101,7 @@ public class BlockWildPlant extends BlockBushBase {
return stack.getItemDamage() >= ALL_WILD_PLANTS.length ? EnumRarity.COMMON : ALL_WILD_PLANTS[stack.getItemDamage()].getRarity();
}
public static class TheItemBlock extends ItemBlockBase {
public static class TheItemBlock extends BlockItemBase {
public TheItemBlock(Block block) {
super(block);

View File

@ -1,9 +1,10 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -12,6 +13,6 @@ import javax.annotation.Nullable;
public interface IHudDisplay {
@OnlyIn(Dist.CLIENT)
void displayHud(Minecraft minecraft, PlayerEntity player, ItemStack stack, @Nullable RayTraceResult posHit, int scaledWidth, int scaledHeight);
void displayHud(Minecraft minecraft, PlayerEntity player, ItemStack stack, BlockRayTraceResult posHit, MainWindow window);
}

View File

@ -1,51 +1,17 @@
//package de.ellpeck.actuallyadditions.mod.blocks.base;
//
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.blocks.render.IHasModel;
//import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
//import net.minecraft.block.Block;
//import net.minecraft.block.material.Material;
//import net.minecraft.item.EnumRarity;
//import net.minecraft.item.ItemStack;
//import net.minecraft.item.Rarity;
//import net.minecraftforge.common.IRarity;
//
//public class BlockBase extends Block implements ItemBlockBase.ICustomRarity, IHasModel {
//
// private final String name;
//
// public BlockBase(Material material, String name) {
// super(material);
// this.name = name;
//
// this.register();
// }
//
// private void register() {
// ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative());
// }
//
// protected String getBaseName() {
// return this.name;
// }
//
// protected ItemBlockBase getItemBlock() {
// return new ItemBlockBase(this);
// }
//
// public boolean shouldAddCreative() {
// return true;
// }
//
// @Override
// public void registerRendering() {
// ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
// }
//
//
//
// @Override
// public Rarity getRarity(ItemStack stack) {
// return EnumRarity.COMMON;
// }
//}
package de.ellpeck.actuallyadditions.mod.blocks.base;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
public class BlockBase extends Block implements IBaseBlock{
public BlockBase(Properties properties) {
super(properties);
}
@Override
public BlockItemBase getItemBlock() {
return new BlockItemBase(this, new Item.Properties());
}
}

View File

@ -2,32 +2,17 @@ package de.ellpeck.actuallyadditions.mod.blocks.base;
import net.minecraft.block.BushBlock;
import net.minecraft.block.SoundType;
import net.minecraft.item.Item;
public class BlockBushBase extends BushBlock {
public class BlockBushBase extends BushBlock implements IBaseBlock {
public BlockBushBase(Properties properties) {
super(properties.sound(SoundType.PLANT));
// this.register();
}
// private void register() {
// ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative());
// }
// protected ItemBlockBase getItemBlock() {
// return new ItemBlockBase(this);
// }
public boolean shouldAddCreative() {
return true;
@Override
public BlockItemBase getItemBlock(){
return new BlockItemBase(this, new Item.Properties());
}
// @Override
// public void registerRendering() {
// ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
// }
// @Override
// public EnumRarity getRarity(ItemStack stack) {
// return EnumRarity.COMMON;
// }
}

View File

@ -29,36 +29,13 @@ import net.minecraftforge.fluids.capability.templates.FluidTank;
import javax.annotation.Nullable;
import java.util.Random;
public abstract class BlockContainerBase extends Block {
public abstract class BlockContainerBase extends BlockBase {
public BlockContainerBase(Properties properties) {
super(properties);
// this.register();
}
// private void register() {
// ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative());
// }
// protected ItemBlockBase getItemBlock() {
// return new ItemBlockBase(this);
// }
public boolean shouldAddCreative() {
return true;
}
// @Override
// public void registerRendering() {
// ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
// }
//
// @Override
// public EnumRarity getRarity(ItemStack stack) {
// return EnumRarity.COMMON;
// }
private void dropInventory(World world, BlockPos position) {
if (!world.isRemote) {
TileEntity aTile = world.getTileEntity(position);

View File

@ -0,0 +1,13 @@
package de.ellpeck.actuallyadditions.mod.blocks.base;
import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
public class BlockItemBase extends BlockItem {
public <T extends Block & IBaseBlock> BlockItemBase(T block , Item.Properties properties) {
super(block, properties.rarity(block.getRarity()));
}
}

View File

@ -30,9 +30,8 @@ import net.minecraftforge.items.ItemHandlerHelper;
import java.util.List;
public class BlockPlant extends CropsBlock {// implements ItemBlockBase.ICustomRarity, IHasModel {
public class BlockPlant extends CropsBlock implements IBaseBlock {
// private final String name;
private final int minDropAmount;
private final int addDropAmount;
public Item seedItem;
@ -42,59 +41,43 @@ public class BlockPlant extends CropsBlock {// implements ItemBlockBase.ICustomR
// todo: find the correct properties for crops
public BlockPlant(int minDropAmount, int addDropAmount) {
super(Properties.create(Material.PLANTS));
// this.name = name;
this.minDropAmount = minDropAmount;
this.addDropAmount = addDropAmount;
// this.register();
}
// todo: check what this is doing
public void doStuff(Item seedItem, Item returnItem, int returnMeta) {
this.seedItem = seedItem;
this.returnItem = returnItem;
this.returnMeta = returnMeta;
}
// private void register() {
// ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative());
// }
// protected String getBaseName() {
// return this.name;
// }
// protected ItemBlockBase getItemBlock() {
// return new ItemBlockBase(this);
// }
@Override
public BlockItemBase getItemBlock(){
return new BlockItemBase(this, new Item.Properties());
}
public boolean shouldAddCreative() {
return false;
}
// @Override
// public void registerRendering() {
// ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
// }
//
@Override
public PlantType getPlantType(IBlockReader world, BlockPos pos) {
return PlantType.Crop;
}
//
// @Override
// public int damageDropped(IBlockState state) {
// return this.getMetaFromState(state) >= 7 ? this.returnMeta : 0;
// }
@Override
protected IItemProvider getSeedsItem() {
return this.seedItem;
}
@Override
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (getAge(state) > 7) {
if (!world.isRemote) {
List<ItemStack> drops = getDrops(state, (ServerWorld) world, pos, null);
boolean deductedSeedSize = false;
for (ItemStack drop : drops) {
if (StackUtil.isValid(drop)) {
@ -107,36 +90,36 @@ public class BlockPlant extends CropsBlock {// implements ItemBlockBase.ICustomR
}
}
}
world.setBlockState(pos, state.with(AGE, 0));
}
return ActionResultType.SUCCESS;
}
return super.onBlockActivated(state, world, pos, player, handIn, hit);
}
/* todo: this is likely handled by loot tables now
@Override
public int damageDropped(IBlockState state) {
return this.getMetaFromState(state) >= 7 ? this.returnMeta : 0;
}
@Override
protected IItemProvider getSeedsItem() {
return this.seedItem;
public int quantityDropped(IBlockState state, int fortune, Random random) {
return this.getMetaFromState(state) >= 7 ? random.nextInt(this.addDropAmount) + this.minDropAmount : super.quantityDropped(state, fortune, random);
}
// todo: this is likely handled by loot tables now
@Override
public Item getCrop() {
return this.returnItem;
}
// @Override
// public int quantityDropped(IBlockState state, int fortune, Random random) {
// return this.getMetaFromState(state) >= 7 ? random.nextInt(this.addDropAmount) + this.minDropAmount : super.quantityDropped(state, fortune, random);
// }
// @Override
// public Item getCrop() {
// return this.returnItem;
// }
// @Override
// public Item getItemDropped(IBlockState state, Random rand, int par3) {
// return this.getMetaFromState(state) >= 7 ? this.getCrop() : this.getSeed();
// }
@Override
public Item getItemDropped(IBlockState state, Random rand, int par3) {
return this.getMetaFromState(state) >= 7 ? this.getCrop() : this.getSeed();
}
*/
}

View File

@ -0,0 +1,17 @@
package de.ellpeck.actuallyadditions.mod.blocks.base;
import net.minecraft.item.Rarity;
public interface IBaseBlock {
BlockItemBase getItemBlock();
default boolean shouldAddCreative() {
return true;
}
default Rarity getRarity() {
return Rarity.COMMON;
}
}

View File

@ -1,25 +0,0 @@
package de.ellpeck.actuallyadditions.mod.blocks.base;
import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
@Deprecated
public class ItemBlockBase extends BlockItem {
public ItemBlockBase(Block block, Item.Properties properties) {
super(block, properties);
// this.setHasSubtypes(false);
// this.setMaxDamage(0);
}
// @Override
// public String getTranslationKey(ItemStack stack) {
// return this.getTranslationKey();
// }
//
// @Override
// public int getMetadata(int damage) {
// return damage;
// }
}

View File

@ -2,6 +2,7 @@ package de.ellpeck.actuallyadditions.mod.event;
import java.util.Locale;
import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay;
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
@ -17,30 +18,26 @@ import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.item.SwordItem;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class ClientEvents {
private static final String ADVANCED_INFO_TEXT_PRE = TextFormatting.DARK_GRAY + " ";
@ -53,9 +50,9 @@ public class ClientEvents {
}
@SubscribeEvent
public void onClientTick(ClientTickEvent event) {
if (event.phase == Phase.END) {
Minecraft mc = Minecraft.getMinecraft();
public void onClientTick(TickEvent.ClientTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
Minecraft mc = Minecraft.getInstance();
if (mc.world == null) {
WorldData.clear();
@ -79,7 +76,7 @@ public class ClientEvents {
}
}
if (ItemWingsOfTheBats.THE_BAT_BAT.equalsIgnoreCase(stack.getDisplayName()) && stack.getItem() instanceof ItemSword) {
if (ItemWingsOfTheBats.THE_BAT_BAT.equalsIgnoreCase(stack.getDisplayName()) && stack.getItem() instanceof SwordItem) {
event.getToolTip().set(0, TextFormatting.GOLD + event.getToolTip().get(0));
event.getToolTip().add(1, TextFormatting.RED.toString() + TextFormatting.ITALIC + "That's a really bat pun");
}
@ -88,7 +85,7 @@ public class ClientEvents {
//Advanced Item Info
if (event.getFlags().isAdvanced() && StackUtil.isValid(event.getItemStack())) {
if (ConfigBoolValues.CTRL_EXTRA_INFO.isEnabled()) {
if (GuiScreen.isCtrlKeyDown()) {
if (Screen.hasControlDown()) {
event.getToolTip().add(TextFormatting.DARK_GRAY + "" + TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".extraInfo.desc") + ":");
//OreDict Names
@ -127,10 +124,10 @@ public class ClientEvents {
}
//NBT
NBTTagCompound compound = event.getItemStack().getTagCompound();
CompoundNBT compound = event.getItemStack().getTag();
if (compound != null && !compound.isEmpty()) {
event.getToolTip().add(ADVANCED_INFO_HEADER_PRE + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".nbt.desc") + ":");
if (GuiScreen.isShiftKeyDown()) {
if (Screen.hasShiftDown()) {
int limit = ConfigIntValues.CTRL_INFO_NBT_CHAR_LIMIT.getValue();
String compoundStrg = compound.toString();
int compoundStrgLength = compoundStrg.length();
@ -161,58 +158,63 @@ public class ClientEvents {
@SubscribeEvent
public void onGameOverlay(RenderGameOverlayEvent.Post event) {
if (event.getType() == RenderGameOverlayEvent.ElementType.ALL && Minecraft.getMinecraft().currentScreen == null) {
Minecraft minecraft = Minecraft.getMinecraft();
if (event.getType() == RenderGameOverlayEvent.ElementType.ALL && Minecraft.getInstance().currentScreen == null) {
Minecraft minecraft = Minecraft.getInstance();
PlayerEntity player = minecraft.player;
RayTraceResult posHit = minecraft.objectMouseOver;
FontRenderer font = minecraft.fontRenderer;
ItemStack stack = player.getHeldItemMainhand();
if (StackUtil.isValid(stack)) {
if (stack.getItem() instanceof IHudDisplay) {
((IHudDisplay) stack.getItem()).displayHud(minecraft, player, stack, posHit, event.getResolution());
}
}
if (posHit != null && posHit.getBlockPos() != null) {
Block blockHit = minecraft.world.getBlockState(posHit.getBlockPos()).getBlock();
TileEntity tileHit = minecraft.world.getTileEntity(posHit.getBlockPos());
if (blockHit instanceof IHudDisplay) {
((IHudDisplay) blockHit).displayHud(minecraft, player, stack, posHit, event.getResolution());
}
if (tileHit instanceof TileEntityBase) {
TileEntityBase base = (TileEntityBase) tileHit;
if (base.isRedstoneToggle()) {
String strg = String.format("%s: %s", StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode.name"), TextFormatting.DARK_RED + StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode." + (base.isPulseMode ? "pulse" : "deactivation")) + TextFormatting.RESET);
font.drawStringWithShadow(strg, event.getResolution().getScaledWidth() / 2 + 5, event.getResolution().getScaledHeight() / 2 + 5, StringUtil.DECIMAL_COLOR_WHITE);
String expl;
if (StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemRedstoneTorchConfigurator) {
expl = TextFormatting.GREEN + StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode.validItem");
} else {
expl = TextFormatting.GRAY.toString() + TextFormatting.ITALIC + StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".redstoneMode.invalidItem", StringUtil.localize(ConfigValues.itemRedstoneTorchConfigurator.getTranslationKey() + ".name"));
}
font.drawStringWithShadow(expl, event.getResolution().getScaledWidth() / 2 + 5, event.getResolution().getScaledHeight() / 2 + 15, StringUtil.DECIMAL_COLOR_WHITE);
if(posHit instanceof BlockRayTraceResult){
BlockRayTraceResult blockRayTraceResult = ((BlockRayTraceResult) posHit);
if (StackUtil.isValid(stack)) {
if (stack.getItem() instanceof IHudDisplay) {
((IHudDisplay) stack.getItem()).displayHud(minecraft, player, stack, blockRayTraceResult, event.getWindow());
}
}
if (tileHit instanceof IEnergyDisplay) {
IEnergyDisplay display = (IEnergyDisplay) tileHit;
if (!display.needsHoldShift() || player.isSneaking()) {
if (energyDisplay == null) {
energyDisplay = new EnergyDisplay(0, 0, null);
if (blockRayTraceResult.getPos() != null) {
Block blockHit = minecraft.world.getBlockState(blockRayTraceResult.getPos()).getBlock();
TileEntity tileHit = minecraft.world.getTileEntity(blockRayTraceResult.getPos());
if (blockHit instanceof IHudDisplay) {
((IHudDisplay) blockHit).displayHud(minecraft, player, stack, blockRayTraceResult, event.getWindow());
}
if (tileHit instanceof TileEntityBase) {
TileEntityBase base = (TileEntityBase) tileHit;
if (base.isRedstoneToggle()) {
String strg = String.format("%s: %s", StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode.name"), TextFormatting.DARK_RED + StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode." + (base.isPulseMode ? "pulse" : "deactivation")) + TextFormatting.RESET);
font.drawStringWithShadow(strg, event.getWindow().getScaledWidth() / 2 + 5, event.getWindow().getScaledHeight() / 2 + 5, StringUtil.DECIMAL_COLOR_WHITE);
String expl;
if (StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemRedstoneTorchConfigurator) {
expl = TextFormatting.GREEN + StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode.validItem");
} else {
expl = TextFormatting.GRAY.toString() + TextFormatting.ITALIC + StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".redstoneMode.invalidItem", StringUtil.localize(ConfigValues.itemRedstoneTorchConfigurator.getTranslationKey() + ".name"));
}
font.drawStringWithShadow(expl, event.getWindow().getScaledWidth() / 2 + 5, event.getWindow().getScaledHeight() / 2 + 15, StringUtil.DECIMAL_COLOR_WHITE);
}
}
if (tileHit instanceof IEnergyDisplay) {
IEnergyDisplay display = (IEnergyDisplay) tileHit;
if (!display.needsHoldShift() || player.isSneaking()) {
if (energyDisplay == null) {
energyDisplay = new EnergyDisplay(0, 0, null);
}
energyDisplay.setData(2, event.getWindow().getScaledHeight() - 96, display.getEnergyStorage(), true, true);
GlStateManager.pushMatrix();
GlStateManager.color4f(1F, 1F, 1F, 1F);
energyDisplay.draw();
GlStateManager.popMatrix();
}
energyDisplay.setData(2, event.getResolution().getScaledHeight() - 96, display.getEnergyStorage(), true, true);
GlStateManager.pushMatrix();
GlStateManager.color(1F, 1F, 1F, 1F);
energyDisplay.draw();
GlStateManager.popMatrix();
}
}
}
}
}

View File

@ -2,7 +2,7 @@ package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.api.misc.IDisableableItem;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
@ -46,8 +46,8 @@ public class ItemSwordAA extends ItemSword implements IDisableableItem {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
protected Class<? extends ItemBlockBase> getItemBlock() {
return ItemBlockBase.class;
protected Class<? extends BlockItemBase> getItemBlock() {
return BlockItemBase.class;
}
@Override

View File

@ -1,8 +1,8 @@
package de.ellpeck.actuallyadditions.mod.items.metalists;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.item.Rarity;
import net.minecraft.util.IStringSerializable;
import net.minecraftforge.common.IRarity;
public enum TheCrystals implements IStringSerializable {
@ -14,11 +14,11 @@ public enum TheCrystals implements IStringSerializable {
IRON("white", Util.CRYSTAL_WHITE_RARITY, 0xCEDDD4, 0.8F, 0.8F, 0.8F);
public final String name;
public final IRarity rarity;
public final Rarity rarity;
public final float[] conversionColorParticles;
public final int clusterColor;
TheCrystals(String name, IRarity rarity, int clusterColor, float... conversionColorParticles) {
TheCrystals(String name, Rarity rarity, int clusterColor, float... conversionColorParticles) {
this.name = name;
this.rarity = rarity;
this.conversionColorParticles = conversionColorParticles;

View File

@ -1,12 +1,12 @@
package de.ellpeck.actuallyadditions.mod.util;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public interface IColorProvidingBlock {
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
IBlockColor getBlockColor();
}

View File

@ -1,12 +1,12 @@
package de.ellpeck.actuallyadditions.mod.util;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public interface IColorProvidingItem {
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
IItemColor getItemColor();
}

View File

@ -5,7 +5,7 @@ import java.util.List;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.RegistryHandler;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
import de.ellpeck.actuallyadditions.mod.util.compat.IMCHandler;
import net.minecraft.block.Block;
@ -25,7 +25,8 @@ public final class ItemUtil {
return ForgeRegistries.ITEMS.getValue(new ResourceLocation(name));
}
public static void registerBlock(Block block, ItemBlockBase itemBlock, String name, boolean addTab) {
@Deprecated // canitzp: should be removed
public static void registerBlock(Block block, BlockItemBase itemBlock, String name, boolean addTab) {
block.setTranslationKey(ActuallyAdditions.MODID + "." + name);
block.setRegistryName(ActuallyAdditions.MODID, name);
@ -43,6 +44,7 @@ public final class ItemUtil {
}
}
@Deprecated // canitzp: should be removed
public static void registerItem(Item item, String name, boolean addTab) {
item.setTranslationKey(ActuallyAdditions.MODID + "." + name);

View File

@ -1,26 +0,0 @@
package de.ellpeck.actuallyadditions.mod.util;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.IRarity;
public class Rarity implements IRarity {
TextFormatting color;
String name;
public Rarity(TextFormatting color, String name) {
this.color = color;
this.name = name;
}
@Override
public TextFormatting getColor() {
return color;
}
@Override
public String getName() {
return name;
}
}

View File

@ -1,36 +1,35 @@
package de.ellpeck.actuallyadditions.mod.util;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import net.minecraft.item.Rarity;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.IRarity;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.oredict.OreDictionary;
public final class Util {
public static final int WILDCARD = OreDictionary.WILDCARD_VALUE;
public static final int BUCKET = Fluid.BUCKET_VOLUME;
@Deprecated // canitzp: Wildcards and Oredict not supported anymore -> Tags
public static final int WILDCARD = -1;//OreDictionary.WILDCARD_VALUE;
public static final int BUCKET = 1000;
public static final IRarity CRYSTAL_RED_RARITY = addRarity("crystalRed", TextFormatting.DARK_RED, ActuallyAdditions.NAME + " Red Crystal");
public static final IRarity CRYSTAL_BLUE_RARITY = addRarity("crystalBlue", TextFormatting.DARK_BLUE, ActuallyAdditions.NAME + " Blue Crystal");
public static final IRarity CRYSTAL_LIGHT_BLUE_RARITY = addRarity("crystalLightBlue", TextFormatting.BLUE, ActuallyAdditions.NAME + " Light Blue Crystal");
public static final IRarity CRYSTAL_BLACK_RARITY = addRarity("crystalBlack", TextFormatting.DARK_GRAY, ActuallyAdditions.NAME + " Black Crystal");
public static final IRarity CRYSTAL_GREEN_RARITY = addRarity("crystalGreen", TextFormatting.DARK_GREEN, ActuallyAdditions.NAME + " Green Crystal");
public static final IRarity CRYSTAL_WHITE_RARITY = addRarity("crystalWhite", TextFormatting.GRAY, ActuallyAdditions.NAME + " White Crystal");
public static final Rarity CRYSTAL_RED_RARITY = addRarity("crystalRed", TextFormatting.DARK_RED, ActuallyAdditions.NAME + " Red Crystal");
public static final Rarity CRYSTAL_BLUE_RARITY = addRarity("crystalBlue", TextFormatting.DARK_BLUE, ActuallyAdditions.NAME + " Blue Crystal");
public static final Rarity CRYSTAL_LIGHT_BLUE_RARITY = addRarity("crystalLightBlue", TextFormatting.BLUE, ActuallyAdditions.NAME + " Light Blue Crystal");
public static final Rarity CRYSTAL_BLACK_RARITY = addRarity("crystalBlack", TextFormatting.DARK_GRAY, ActuallyAdditions.NAME + " Black Crystal");
public static final Rarity CRYSTAL_GREEN_RARITY = addRarity("crystalGreen", TextFormatting.DARK_GREEN, ActuallyAdditions.NAME + " Green Crystal");
public static final Rarity CRYSTAL_WHITE_RARITY = addRarity("crystalWhite", TextFormatting.GRAY, ActuallyAdditions.NAME + " White Crystal");
public static final IRarity FALLBACK_RARITY = addRarity("fallback", TextFormatting.STRIKETHROUGH, ActuallyAdditions.NAME + " Fallback");
public static final Rarity FALLBACK_RARITY = addRarity("fallback", TextFormatting.STRIKETHROUGH, ActuallyAdditions.NAME + " Fallback");
private static IRarity addRarity(String name, TextFormatting color, String displayName) {
return new Rarity(color, displayName);
private static Rarity addRarity(String name, TextFormatting color, String displayName) {
return Rarity.create(displayName, color);
}
public static boolean isDevVersion() {
return ActuallyAdditions.VERSION.equals("@VERSION@");
}
@Deprecated // canitzp: should not be used and removed asap
public static boolean isClient() {
return FMLCommonHandler.instance().getEffectiveSide().isClient();
return false;//FMLCommonHandler.instance().getEffectiveSide().isClient();
}
private static String[] splitVersion() {