mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Stop using IFuelHandler and remove fake air block
also various generics/deprecation stuff cuz wabealwdnamflkaw. Might put fake air block back if lex doesnt know how to make dummy blocks work
This commit is contained in:
parent
f2b24c3318
commit
ab76551cde
17 changed files with 47 additions and 110 deletions
|
@ -32,7 +32,6 @@ import de.ellpeck.actuallyadditions.mod.misc.apiimpl.MethodHandler;
|
|||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.proxy.IProxy;
|
||||
import de.ellpeck.actuallyadditions.mod.recipe.EmpowererHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.recipe.FuelHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.recipe.HairyBallHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.recipe.TreasureChestHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
|
@ -98,7 +97,6 @@ public class ActuallyAdditions{
|
|||
ModUtil.LOGGER.info("Starting Initialization Phase...");
|
||||
|
||||
BannerHelper.init();
|
||||
FuelHandler.init();
|
||||
//InitAchievements.init();
|
||||
GuiHandler.init();
|
||||
new OreGen();
|
||||
|
|
|
@ -35,7 +35,6 @@ import net.minecraft.util.NonNullList;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
|
|
@ -16,9 +16,9 @@ import net.minecraft.world.World;
|
|||
|
||||
public class BlockFakeAir extends Block
|
||||
{
|
||||
public BlockFakeAir(){
|
||||
public BlockFakeAir(String name){
|
||||
super(Material.AIR);
|
||||
setRegistryName("actuallyadditions:block_oil");
|
||||
setRegistryName(name);
|
||||
setUnlocalizedName("stop");
|
||||
RegistryHandler.BLOCKS_TO_REGISTER.add(this);
|
||||
}
|
||||
|
|
|
@ -97,5 +97,11 @@ public class BlockMisc extends BlockBase{
|
|||
public String getUnlocalizedName(ItemStack stack){
|
||||
return stack.getItemDamage() >= ALL_MISC_BLOCKS.length ? StringUtil.BUGGED_ITEM_NAME : this.getUnlocalizedName()+"_"+ALL_MISC_BLOCKS[stack.getItemDamage()].name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemBurnTime(ItemStack stack) {
|
||||
if(stack.getMetadata() == TheMiscBlocks.CHARCOAL_BLOCK.ordinal()) return 16000;
|
||||
return super.getItemBurnTime(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator;
|
|||
import net.minecraft.block.BlockHorizontal;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
|
|
@ -76,7 +76,7 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
|
|||
return ((TileEntityPhantomRedstoneface)tile).providesStrong[side.ordinal()];
|
||||
}
|
||||
}
|
||||
return super.getStrongPower(state, world, pos, side);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -132,28 +132,28 @@ public class BlockSlabs extends BlockBase{
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
|
||||
ItemStack stack = playerIn.getHeldItem(hand);
|
||||
if(StackUtil.isValid(stack) && playerIn.canPlayerEdit(pos.offset(facing), facing, stack)){
|
||||
IBlockState state = worldIn.getBlockState(pos);
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if(StackUtil.isValid(stack) && player.canPlayerEdit(pos.offset(facing), facing, stack)){
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
|
||||
if(state.getBlock() == this.block){
|
||||
BlockSlabs theBlock = (BlockSlabs)this.block;
|
||||
if((facing == EnumFacing.UP && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) || (facing == EnumFacing.DOWN && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP)){
|
||||
IBlockState newState = theBlock.fullBlock.getStateFromMeta(theBlock.meta);
|
||||
AxisAlignedBB bound = newState.getCollisionBoundingBox(worldIn, pos);
|
||||
AxisAlignedBB bound = newState.getCollisionBoundingBox(world, pos);
|
||||
|
||||
if(bound != Block.NULL_AABB && worldIn.checkNoEntityCollision(bound.offset(pos)) && worldIn.setBlockState(pos, newState, 11)){
|
||||
SoundType soundtype = theBlock.fullBlock.getSoundType();
|
||||
worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F);
|
||||
playerIn.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
|
||||
if(bound != Block.NULL_AABB && world.checkNoEntityCollision(bound.offset(pos)) && world.setBlockState(pos, newState, 11)){
|
||||
SoundType soundtype = theBlock.fullBlock.getSoundType(theBlock.fullBlock.getDefaultState(), world, pos, player);
|
||||
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F);
|
||||
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return this.tryPlace(playerIn, stack, hand, worldIn, pos.offset(facing)) ? EnumActionResult.SUCCESS : super.onItemUse(playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ);
|
||||
return this.tryPlace(player, stack, hand, world, pos.offset(facing)) ? EnumActionResult.SUCCESS : super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
|
||||
}
|
||||
else{
|
||||
return EnumActionResult.FAIL;
|
||||
|
@ -174,17 +174,17 @@ public class BlockSlabs extends BlockBase{
|
|||
return worldIn.getBlockState(pos.offset(side)).getBlock() == this.block || super.canPlaceBlockOnSide(worldIn, pos, side, player, stack);
|
||||
}
|
||||
|
||||
private boolean tryPlace(EntityPlayer player, ItemStack stack, EnumHand hand, World worldIn, BlockPos pos){
|
||||
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||
private boolean tryPlace(EntityPlayer player, ItemStack stack, EnumHand hand, World world, BlockPos pos){
|
||||
IBlockState iblockstate = world.getBlockState(pos);
|
||||
|
||||
if(iblockstate.getBlock() == this.block){
|
||||
BlockSlabs theBlock = (BlockSlabs)this.block;
|
||||
IBlockState newState = theBlock.fullBlock.getStateFromMeta(theBlock.meta);
|
||||
AxisAlignedBB bound = newState.getCollisionBoundingBox(worldIn, pos);
|
||||
AxisAlignedBB bound = newState.getCollisionBoundingBox(world, pos);
|
||||
|
||||
if(bound != Block.NULL_AABB && worldIn.checkNoEntityCollision(bound.offset(pos)) && worldIn.setBlockState(pos, newState, 11)){
|
||||
SoundType soundtype = theBlock.fullBlock.getSoundType();
|
||||
worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F);
|
||||
if(bound != Block.NULL_AABB && world.checkNoEntityCollision(bound.offset(pos)) && world.setBlockState(pos, newState, 11)){
|
||||
SoundType soundtype = theBlock.fullBlock.getSoundType(theBlock.fullBlock.getDefaultState(), world, pos, player);
|
||||
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F);
|
||||
|
||||
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
|
|||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.CompatUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockAir;
|
||||
|
||||
public final class InitBlocks{
|
||||
|
||||
|
@ -117,7 +116,6 @@ public final class InitBlocks{
|
|||
public static Block blockCrystalClusterCoal;
|
||||
public static Block blockCrystalClusterEmerald;
|
||||
public static Block blockCrystalClusterIron;
|
||||
public static final Block FAKE_AIR_BLOCK = new BlockFakeAir();
|
||||
|
||||
public static void init(){
|
||||
ModUtil.LOGGER.info("Initializing Blocks...");
|
||||
|
|
|
@ -103,4 +103,15 @@ public class ItemMisc extends ItemBase{
|
|||
public boolean hasEffect(ItemStack stack){
|
||||
return stack.getItemDamage() == TheMiscItems.EMPOWERED_CANOLA_SEED.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemBurnTime(ItemStack stack) {
|
||||
int k = stack.getMetadata();
|
||||
|
||||
if(k == TheMiscItems.TINY_CHAR.ordinal()) return 200;
|
||||
if(k == TheMiscItems.TINY_COAL.ordinal()) return 200;
|
||||
if(k == TheMiscItems.BIOCOAL.ordinal()) return 80;
|
||||
|
||||
return super.getItemBurnTime(stack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -225,18 +225,19 @@ public abstract class ItemEnergy extends ItemBase{
|
|||
return this.getCapability(capability, facing) != null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")//gud quality system needs @SuppressWarnings to not complain
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing){
|
||||
if(capability == CapabilityEnergy.ENERGY){
|
||||
return (T)this.storage;
|
||||
return (T) this.storage;
|
||||
}
|
||||
else if(ActuallyAdditions.teslaLoaded){
|
||||
if(capability == TeslaUtil.teslaConsumer || capability == TeslaUtil.teslaProducer || capability == TeslaUtil.teslaHolder){
|
||||
if(this.teslaWrapper == null){
|
||||
this.teslaWrapper = new TeslaForgeUnitsWrapper(this.storage);
|
||||
}
|
||||
return (T)this.teslaWrapper;
|
||||
return (T) this.teslaWrapper;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -45,7 +45,7 @@ public final class BannerHelper{
|
|||
* pattern.
|
||||
*/
|
||||
public static void addCraftingPattern(String name, ItemStack craftingStack){
|
||||
Class[] paramTypes = {String.class, String.class, ItemStack.class};
|
||||
Class<?>[] paramTypes = {String.class, String.class, ItemStack.class};
|
||||
Object[] paramValues = {ModUtil.MOD_ID+name, ModUtil.MOD_ID+name, craftingStack};
|
||||
EnumHelper.addEnum(BannerPattern.class, (ModUtil.MOD_ID+"_"+name).toUpperCase(Locale.ROOT), paramTypes, paramValues);
|
||||
}
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* This file ("FuelHandler.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.recipe;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.IFuelHandler;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FuelHandler implements IFuelHandler{
|
||||
|
||||
private static final List<Fuel> FUEL_LIST = new ArrayList<Fuel>();
|
||||
|
||||
public static void init(){
|
||||
ModUtil.LOGGER.info("Initializing Fuelstuffs...");
|
||||
|
||||
GameRegistry.registerFuelHandler(new FuelHandler());
|
||||
|
||||
addFuel(InitItems.itemMisc, TheMiscItems.TINY_CHAR.ordinal(), 200);
|
||||
addFuel(InitItems.itemMisc, TheMiscItems.TINY_COAL.ordinal(), 200);
|
||||
addFuel(InitBlocks.blockMisc, TheMiscBlocks.CHARCOAL_BLOCK.ordinal(), 16000);
|
||||
addFuel(InitItems.itemMisc, TheMiscItems.BIOCOAL.ordinal(), 80);
|
||||
}
|
||||
|
||||
private static void addFuel(Item item, int meta, int value){
|
||||
FUEL_LIST.add(new Fuel(new ItemStack(item, 1, meta), value));
|
||||
}
|
||||
|
||||
private static void addFuel(Block block, int meta, int value){
|
||||
addFuel(Item.getItemFromBlock(block), meta, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBurnTime(ItemStack stack){
|
||||
if(StackUtil.isValid(stack)){
|
||||
for(Fuel fuel : FUEL_LIST){
|
||||
if(stack.isItemEqual(fuel.fuel)){
|
||||
return fuel.burnTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static class Fuel{
|
||||
|
||||
public ItemStack fuel;
|
||||
public int burnTime;
|
||||
|
||||
public Fuel(ItemStack fuel, int burnTime){
|
||||
this.fuel = fuel;
|
||||
this.burnTime = burnTime;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -15,7 +15,6 @@ import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
|||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaForgeUnitsWrapper;
|
||||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
|
||||
|
@ -29,7 +28,6 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
@ -329,6 +327,7 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
|
|||
return this.getCapability(capability, facing) != null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing){
|
||||
if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY){
|
||||
|
|
|
@ -15,7 +15,6 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.BlockMagma;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
|
|
@ -133,6 +133,7 @@ public class TileEntityItemViewer extends TileEntityBase{
|
|||
return this.itemHandler.getNormalHandler();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing){
|
||||
if(ActuallyAdditions.commonCapsLoaded){
|
||||
|
|
|
@ -47,7 +47,7 @@ public final class CompatUtil{
|
|||
private static void registerBloodMagicPlant(Block block){
|
||||
if(Loader.isModLoaded("bloodmagic")){
|
||||
try{
|
||||
Class regClass = Class.forName("WayofTime.bloodmagic.api.registry.HarvestRegistry");
|
||||
Class<?> regClass = Class.forName("WayofTime.bloodmagic.api.registry.HarvestRegistry");
|
||||
Method regMethod = regClass.getDeclaredMethod("registerStandardCrop", Block.class, int.class);
|
||||
regMethod.invoke(null, block, ((BlockCrops)block).getMaxAge());
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.apache.commons.lang3.ArrayUtils;
|
|||
|
||||
public final class IMCHandler{
|
||||
|
||||
private static final Class<? extends Block>[] NO_CARRYING = new Class[]{
|
||||
private static final Class<?>[] NO_CARRYING = new Class<?>[]{
|
||||
BlockGiantChest.class,
|
||||
BlockWildPlant.class,
|
||||
BlockPlant.class,
|
||||
|
|
Loading…
Reference in a new issue