Made Baseblock abstract, removed rarity and blockItem handlers for now

This might come back but I don't know how we're going to handle block item handling yet
This commit is contained in:
Michael 2020-09-09 16:18:09 +01:00
parent 69df7e0e81
commit 9d8e711d35
No known key found for this signature in database
GPG key ID: 971C5B254742488F
17 changed files with 41 additions and 89 deletions

View file

@ -3,7 +3,6 @@ package de.ellpeck.actuallyadditions.common.blocks;
import de.ellpeck.actuallyadditions.api.lens.ILensItem; import de.ellpeck.actuallyadditions.api.lens.ILensItem;
import de.ellpeck.actuallyadditions.common.ActuallyAdditions; import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
import de.ellpeck.actuallyadditions.common.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.common.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.common.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.common.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.common.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.common.tile.TileEntityAtomicReconstructor; import de.ellpeck.actuallyadditions.common.tile.TileEntityAtomicReconstructor;
import de.ellpeck.actuallyadditions.common.util.AssetUtil; import de.ellpeck.actuallyadditions.common.util.AssetUtil;
@ -17,10 +16,7 @@ import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item; import net.minecraft.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.StateContainer;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -151,7 +147,7 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
return MathHelper.clamp(i / 20000, 0, 15); return MathHelper.clamp(i / 20000, 0, 15);
} }
public class BlockItem extends BlockItemBase { public class BlockItem extends net.minecraft.item.BlockItem {
private long lastSysTime; private long lastSysTime;
private int toPick1; private int toPick1;

View file

@ -3,7 +3,6 @@ package de.ellpeck.actuallyadditions.common.blocks;
import java.util.Random; import java.util.Random;
import de.ellpeck.actuallyadditions.common.ActuallyAdditions; import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
import de.ellpeck.actuallyadditions.common.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.common.blocks.metalists.TheColoredLampColors; import de.ellpeck.actuallyadditions.common.blocks.metalists.TheColoredLampColors;
import de.ellpeck.actuallyadditions.common.util.StackUtil; import de.ellpeck.actuallyadditions.common.util.StackUtil;
import de.ellpeck.actuallyadditions.common.util.StringUtil; import de.ellpeck.actuallyadditions.common.util.StringUtil;
@ -15,6 +14,7 @@ import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.BlockItem;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -132,7 +132,7 @@ public class BlockColoredLamp extends Block {
return new BlockStateContainer(this, TYPE); return new BlockStateContainer(this, TYPE);
} }
public static class TheItemBlock extends BlockItemBase { public static class TheItemBlock extends BlockItem {
public TheItemBlock(Block block) { public TheItemBlock(Block block) {
super(block); super(block);

View file

@ -1,7 +1,6 @@
package de.ellpeck.actuallyadditions.common.blocks; package de.ellpeck.actuallyadditions.common.blocks;
import de.ellpeck.actuallyadditions.common.ActuallyAdditions; import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
import de.ellpeck.actuallyadditions.common.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.common.items.metalists.TheCrystals; import de.ellpeck.actuallyadditions.common.items.metalists.TheCrystals;
import de.ellpeck.actuallyadditions.common.util.StringUtil; import de.ellpeck.actuallyadditions.common.util.StringUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -11,6 +10,7 @@ import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.BlockItem;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
@ -75,7 +75,7 @@ public class BlockCrystal extends Block {
return new BlockStateContainer(this, TYPE); return new BlockStateContainer(this, TYPE);
} }
public static class TheItemBlock extends BlockItemBase { public static class TheItemBlock extends BlockItem {
public TheItemBlock(Block block) { public TheItemBlock(Block block) {
super(block); super(block);

View file

@ -2,7 +2,6 @@ package de.ellpeck.actuallyadditions.common.blocks;
import de.ellpeck.actuallyadditions.common.ActuallyAdditions; import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
import de.ellpeck.actuallyadditions.common.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.common.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.common.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.common.inventory.GuiHandler; import de.ellpeck.actuallyadditions.common.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.common.tile.TileEntityFurnaceDouble; import de.ellpeck.actuallyadditions.common.tile.TileEntityFurnaceDouble;
import de.ellpeck.actuallyadditions.common.util.StringUtil; import de.ellpeck.actuallyadditions.common.util.StringUtil;
@ -16,6 +15,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.BlockItem;
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;
@ -120,7 +120,7 @@ public class BlockFurnaceDouble extends BlockContainerBase {
return new TheItemBlock(this); return new TheItemBlock(this);
} }
public static class TheItemBlock extends BlockItemBase { public static class TheItemBlock extends BlockItem {
public TheItemBlock(Block block) { public TheItemBlock(Block block) {
super(block); super(block);

View file

@ -2,7 +2,6 @@ package de.ellpeck.actuallyadditions.common.blocks;
import de.ellpeck.actuallyadditions.common.ActuallyAdditions; import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
import de.ellpeck.actuallyadditions.common.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.common.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.common.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.common.inventory.GuiHandler; import de.ellpeck.actuallyadditions.common.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.common.tile.TileEntityInputter; import de.ellpeck.actuallyadditions.common.tile.TileEntityInputter;
import de.ellpeck.actuallyadditions.common.tile.TileEntityInputterAdvanced; import de.ellpeck.actuallyadditions.common.tile.TileEntityInputterAdvanced;
@ -13,6 +12,7 @@ import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.BlockItem;
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;
@ -67,7 +67,7 @@ public class BlockInputter extends BlockContainerBase {
return EnumRarity.EPIC; return EnumRarity.EPIC;
} }
public static class TheItemBlock extends BlockItemBase { public static class TheItemBlock extends BlockItem {
private final Random rand = new Random(); private final Random rand = new Random();
private long lastSysTime; private long lastSysTime;

View file

@ -1,7 +1,6 @@
package de.ellpeck.actuallyadditions.common.blocks; package de.ellpeck.actuallyadditions.common.blocks;
import de.ellpeck.actuallyadditions.common.ActuallyAdditions; import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
import de.ellpeck.actuallyadditions.common.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.common.blocks.metalists.TheMiscBlocks; import de.ellpeck.actuallyadditions.common.blocks.metalists.TheMiscBlocks;
import de.ellpeck.actuallyadditions.common.util.StringUtil; import de.ellpeck.actuallyadditions.common.util.StringUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -11,6 +10,7 @@ import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.BlockItem;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
@ -72,7 +72,7 @@ public class BlockMisc extends Block {
return new BlockStateContainer(this, TYPE); return new BlockStateContainer(this, TYPE);
} }
public static class TheItemBlock extends BlockItemBase { public static class TheItemBlock extends BlockItem {
public TheItemBlock(Block block) { public TheItemBlock(Block block) {
super(block); super(block);

View file

@ -1,6 +1,5 @@
package de.ellpeck.actuallyadditions.common.blocks; package de.ellpeck.actuallyadditions.common.blocks;
import de.ellpeck.actuallyadditions.common.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.common.util.StackUtil; import de.ellpeck.actuallyadditions.common.util.StackUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockSlab; import net.minecraft.block.BlockSlab;
@ -10,6 +9,7 @@ import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.BlockItem;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumActionResult;
@ -91,7 +91,7 @@ public class BlockSlabs extends Block {
return new BlockStateContainer(this, BlockSlab.HALF); return new BlockStateContainer(this, BlockSlab.HALF);
} }
public static class TheItemBlock extends BlockItemBase { public static class TheItemBlock extends BlockItem {
public TheItemBlock(Block block) { public TheItemBlock(Block block) {
super(block); super(block);

View file

@ -3,7 +3,6 @@ package de.ellpeck.actuallyadditions.common.blocks;
import de.ellpeck.actuallyadditions.common.ActuallyAdditions; import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
import de.ellpeck.actuallyadditions.common.blocks.base.BlockBushBase; import de.ellpeck.actuallyadditions.common.blocks.base.BlockBushBase;
import de.ellpeck.actuallyadditions.common.blocks.base.BlockPlant; import de.ellpeck.actuallyadditions.common.blocks.base.BlockPlant;
import de.ellpeck.actuallyadditions.common.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.common.blocks.metalists.TheWildPlants; import de.ellpeck.actuallyadditions.common.blocks.metalists.TheWildPlants;
import de.ellpeck.actuallyadditions.common.util.StringUtil; import de.ellpeck.actuallyadditions.common.util.StringUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -14,6 +13,7 @@ import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.BlockItem;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
@ -101,7 +101,7 @@ public class BlockWildPlant extends BlockBushBase {
return stack.getItemDamage() >= ALL_WILD_PLANTS.length ? EnumRarity.COMMON : ALL_WILD_PLANTS[stack.getItemDamage()].getRarity(); return stack.getItemDamage() >= ALL_WILD_PLANTS.length ? EnumRarity.COMMON : ALL_WILD_PLANTS[stack.getItemDamage()].getRarity();
} }
public static class TheItemBlock extends BlockItemBase { public static class TheItemBlock extends BlockItem {
public TheItemBlock(Block block) { public TheItemBlock(Block block) {
super(block); super(block);

View file

@ -0,0 +1,21 @@
package de.ellpeck.actuallyadditions.common.blocks.base;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraftforge.common.ToolType;
public abstract class ActuallyBlockBase extends Block {
private static final Properties STONE_PROPS = Block.Properties.create(Material.ROCK)
.harvestTool(ToolType.PICKAXE)
.sound(SoundType.STONE);
private static final Properties STONE_PROPS_WITH_TICK = STONE_PROPS.tickRandomly();
private static final Properties STONE_PROPS_WITH_HARDNESS = STONE_PROPS.hardnessAndResistance(1.5f, 10.0f);
public ActuallyBlockBase(Properties properties) {
super(properties);
}
}

View file

@ -1,17 +0,0 @@
package de.ellpeck.actuallyadditions.common.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,17 +2,10 @@ package de.ellpeck.actuallyadditions.common.blocks.base;
import net.minecraft.block.BushBlock; import net.minecraft.block.BushBlock;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.item.Item;
public class BlockBushBase extends BushBlock implements IBaseBlock { public class BlockBushBase extends BushBlock {
public BlockBushBase(Properties properties) { public BlockBushBase(Properties properties) {
super(properties.sound(SoundType.PLANT)); super(properties.sound(SoundType.PLANT));
} }
@Override
public BlockItemBase getItemBlock(){
return new BlockItemBase(this, new Item.Properties());
}
} }

View file

@ -29,7 +29,7 @@ import net.minecraftforge.fluids.capability.templates.FluidTank;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Random; import java.util.Random;
public abstract class BlockContainerBase extends BlockBase { public abstract class BlockContainerBase extends ActuallyBlockBase {
public BlockContainerBase(Properties properties) { public BlockContainerBase(Properties properties) {
super(properties); super(properties);

View file

@ -1,13 +0,0 @@
package de.ellpeck.actuallyadditions.common.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,7 +30,7 @@ import net.minecraftforge.items.ItemHandlerHelper;
import java.util.List; import java.util.List;
public class BlockPlant extends CropsBlock implements IBaseBlock { public class BlockPlant extends CropsBlock {
private final int minDropAmount; private final int minDropAmount;
private final int addDropAmount; private final int addDropAmount;
@ -52,16 +52,7 @@ public class BlockPlant extends CropsBlock implements IBaseBlock {
this.returnItem = returnItem; this.returnItem = returnItem;
this.returnMeta = returnMeta; this.returnMeta = returnMeta;
} }
@Override
public BlockItemBase getItemBlock(){
return new BlockItemBase(this, new Item.Properties());
}
public boolean shouldAddCreative() {
return false;
}
@Override @Override
public PlantType getPlantType(IBlockReader world, BlockPos pos) { public PlantType getPlantType(IBlockReader world, BlockPos pos) {
return PlantType.Crop; return PlantType.Crop;

View file

@ -1,17 +0,0 @@
package de.ellpeck.actuallyadditions.common.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

@ -2,7 +2,6 @@ package de.ellpeck.actuallyadditions.common.items.base;
import de.ellpeck.actuallyadditions.api.misc.IDisableableItem; import de.ellpeck.actuallyadditions.api.misc.IDisableableItem;
import de.ellpeck.actuallyadditions.common.ActuallyAdditions; import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
import de.ellpeck.actuallyadditions.common.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.common.config.ConfigurationHandler; import de.ellpeck.actuallyadditions.common.config.ConfigurationHandler;
import de.ellpeck.actuallyadditions.common.util.ItemUtil; import de.ellpeck.actuallyadditions.common.util.ItemUtil;
import de.ellpeck.actuallyadditions.common.util.StringUtil; import de.ellpeck.actuallyadditions.common.util.StringUtil;

View file

@ -5,7 +5,6 @@ import java.util.List;
import de.ellpeck.actuallyadditions.common.ActuallyAdditions; import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
import de.ellpeck.actuallyadditions.common.RegistryHandler; import de.ellpeck.actuallyadditions.common.RegistryHandler;
import de.ellpeck.actuallyadditions.common.blocks.base.BlockItemBase;
import de.ellpeck.actuallyadditions.common.creative.CreativeTab; import de.ellpeck.actuallyadditions.common.creative.CreativeTab;
import de.ellpeck.actuallyadditions.common.util.compat.IMCHandler; import de.ellpeck.actuallyadditions.common.util.compat.IMCHandler;
import net.minecraft.block.Block; import net.minecraft.block.Block;