Implement a functioning Blood Tank (#969)
Added a search bar to the Upgrade Tomes Creative Tab Updated some Altar fluid code (remove deprecated stuff) Moved Rendering classes into appropriate package Fix the localization errors on the Demon Crystals A few cleanups here and there
This commit is contained in:
parent
d1f4e95a7e
commit
aac2623440
40 changed files with 929 additions and 249 deletions
|
@ -1,17 +1,22 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.tile.TileBloodTank;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
@ -19,15 +24,20 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.tile.TileBloodTank;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class BlockBloodTank extends BlockContainer
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockBloodTank extends BlockContainer implements IVariantProvider
|
||||
{
|
||||
public static final PropertyInteger TIER = PropertyInteger.create("tier", 0, TileBloodTank.capacities.length - 1);
|
||||
|
||||
public BlockBloodTank()
|
||||
{
|
||||
super(Material.IRON);
|
||||
|
@ -38,12 +48,22 @@ public class BlockBloodTank extends BlockContainer
|
|||
setSoundType(SoundType.GLASS);
|
||||
setHarvestLevel("pickaxe", 1);
|
||||
setCreativeTab(BloodMagic.tabBloodMagic);
|
||||
setLightOpacity(0);
|
||||
|
||||
setDefaultState(blockState.getBaseState().withProperty(TIER, 0));
|
||||
}
|
||||
|
||||
// This is important!!! - DON'T DELETE - idk why
|
||||
@Override
|
||||
public TileEntity createTileEntity(World worldIn, IBlockState blockState)
|
||||
{
|
||||
return new TileBloodTank(getMetaFromState(blockState));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta)
|
||||
{
|
||||
return new TileBloodTank();
|
||||
return new TileBloodTank(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,33 +72,71 @@ public class BlockBloodTank extends BlockContainer
|
|||
return EnumBlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockRenderLayer getBlockLayer()
|
||||
{
|
||||
return BlockRenderLayer.TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getDefaultState().withProperty(TIER, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return state.getValue(TIER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
if (world.getTileEntity(pos) == null)
|
||||
return state;
|
||||
return state.withProperty(TIER, world.getTileEntity(pos).getBlockMetadata());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockStateContainer(this, new IProperty[] { TIER });
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TileBloodTank fluidHandler = (TileBloodTank) world.getTileEntity(blockPos);
|
||||
if (Utils.fillHandlerWithContainer(world, fluidHandler, player))
|
||||
if (FluidUtil.interactWithFluidHandler(heldItem, fluidHandler.getTank(), player))
|
||||
{
|
||||
world.notifyBlockUpdate(blockPos, state, state, 3);
|
||||
return true;
|
||||
}
|
||||
if (Utils.fillContainerFromHandler(world, fluidHandler, player, fluidHandler.tank.getFluid()))
|
||||
{
|
||||
world.notifyBlockUpdate(blockPos, state, state, 3);
|
||||
return true;
|
||||
}
|
||||
if (FluidContainerRegistry.isContainer(heldItem))
|
||||
{
|
||||
world.notifyBlockUpdate(blockPos, state, state, 3);
|
||||
world.checkLight(blockPos);
|
||||
world.updateComparatorOutputLevel(blockPos, this);
|
||||
world.markAndNotifyBlock(blockPos, world.getChunkFromBlockCoords(blockPos), state, state, 3);
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onBlockActivated(world, blockPos, state, player, hand, heldItem, side, hitX, hitY, hitZ);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
|
||||
{
|
||||
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||
super.onBlockHarvested(worldIn, pos, state, player);
|
||||
}
|
||||
|
||||
|
@ -92,8 +150,9 @@ public class BlockBloodTank extends BlockContainer
|
|||
TileBloodTank bloodTank = (TileBloodTank) world.getTileEntity(blockPos);
|
||||
ItemStack drop = new ItemStack(this);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
bloodTank.writeToNBT(tag);
|
||||
bloodTank.serialize(tag);
|
||||
drop.setTagCompound(tag);
|
||||
drop.setItemDamage(getMetaFromState(blockState));
|
||||
list.add(drop);
|
||||
}
|
||||
|
||||
|
@ -108,26 +167,27 @@ public class BlockBloodTank extends BlockContainer
|
|||
NBTTagCompound tag = stack.getTagCompound();
|
||||
if (tag != null)
|
||||
{
|
||||
world.getTileEntity(blockPos).readFromNBT(tag);
|
||||
((TileBloodTank) world.getTileEntity(blockPos)).deserialize(tag);
|
||||
blockState.withProperty(TIER, stack.getMetadata());
|
||||
}
|
||||
}
|
||||
|
||||
world.checkLight(blockPos);
|
||||
world.updateComparatorOutputLevel(blockPos, this);
|
||||
world.markAndNotifyBlock(blockPos, world.getChunkFromBlockCoords(blockPos), blockState, blockState, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileBloodTank)
|
||||
{
|
||||
TileBloodTank tank = (TileBloodTank) tile;
|
||||
FluidStack fluid = tank.tank.getFluid();
|
||||
if (fluid != null)
|
||||
{
|
||||
return fluid.getFluid().getLuminosity(fluid);
|
||||
}
|
||||
FluidStack fluidStack = ((TileBloodTank) tile).getTank().getFluid();
|
||||
return fluidStack == null || fluidStack.amount <= 0 ? 0 : fluidStack.getFluid().getLuminosity(fluidStack);
|
||||
}
|
||||
return 0;
|
||||
|
||||
return super.getLightValue(state, world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -135,4 +195,29 @@ public class BlockBloodTank extends BlockContainer
|
|||
{
|
||||
return getDrops(world, pos, world.getBlockState(pos), 0).get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(IBlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(IBlockState state, World w, BlockPos pos)
|
||||
{
|
||||
TileEntity tile = w.getTileEntity(pos);
|
||||
if (tile instanceof TileBloodTank)
|
||||
return ((TileBloodTank) tile).getComparatorOutput();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
for (int i = 0; i < TileBloodTank.capacities.length; i++)
|
||||
ret.add(new ImmutablePair<Integer, String>(i, "inventory"));
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class BlockDemonCrystal extends BlockContainer
|
|||
super(Material.ROCK);
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, EnumDemonWillType.DEFAULT).withProperty(ATTACHED, EnumFacing.UP));
|
||||
|
||||
setUnlocalizedName(Constants.Mod.MODID + ".demonCrystal");
|
||||
setUnlocalizedName(Constants.Mod.MODID + ".demonCrystal.");
|
||||
setCreativeTab(BloodMagic.tabBloodMagic);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue