mirror of
https://github.com/GTNewHorizons/ThaumicTinkerer.git
synced 2026-11-28 16:06:07 +00:00
* BS + SA * Intellij Cleanups * Add missing overrides * Cleanup fire code * Less allocations * Get rid of BlockTuple -> Far fewer allocations (It was only used for Ordo Fire which isn't very useful for NH) Neuter Ordo fire (will be reworked once we figure out what it should do) Mixin to fix fire rendering on water -- call the subclass's canCatchFire instead of the base class Properly tether the fire spread to 15 blocks from the source, which never burns out. * rm * Spotless
155 lines
5.1 KiB
Java
155 lines
5.1 KiB
Java
/**
|
|
* This class was created by <Vazkii>. It's distributed as part of the ThaumicTinkerer Mod.
|
|
*
|
|
* ThaumicTinkerer is Open Source and distributed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0
|
|
* License (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
|
*
|
|
* ThaumicTinkerer is a Derivative Work on Thaumcraft 4. Thaumcraft 4 (c) Azanor 2012
|
|
* (http://www.minecraftforum.net/topic/1585216-)
|
|
*
|
|
* File Created @ [Dec 27, 2013, 6:25:36 PM (GMT)]
|
|
*/
|
|
package thaumic.tinkerer.common.block;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.BlockDirectional;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.init.Blocks;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemBlock;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.util.IIcon;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import thaumic.tinkerer.common.block.tile.TileCamo;
|
|
|
|
public abstract class BlockCamo extends BlockModContainer<TileCamo> {
|
|
|
|
static List<Integer> validRenderTypes = Arrays.asList(0, 31, 39);
|
|
|
|
protected BlockCamo(Material par2Material) {
|
|
super(par2Material);
|
|
}
|
|
|
|
@Override
|
|
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
|
TileEntity tile = world.getTileEntity(x, y, z);
|
|
int meta = world.getBlockMetadata(x, y, z);
|
|
|
|
if (tile instanceof TileCamo) {
|
|
TileCamo camo = (TileCamo) tile;
|
|
Block block = camo.camo;
|
|
if (block != null && isValidRenderType(block.getRenderType())) return block.getIcon(side, camo.camoMeta);
|
|
}
|
|
|
|
return getIconFromSideAfterCheck(tile, meta, side);
|
|
}
|
|
|
|
public boolean isValidRenderType(int type) {
|
|
return validRenderTypes.contains(type);
|
|
}
|
|
|
|
@Override
|
|
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer,
|
|
int par6, float par7, float par8, float par9) {
|
|
TileEntity tile = par1World.getTileEntity(par2, par3, par4);
|
|
|
|
if (tile instanceof TileCamo) {
|
|
TileCamo camo = (TileCamo) tile;
|
|
ItemStack currentStack = par5EntityPlayer.getCurrentEquippedItem();
|
|
|
|
boolean doChange = true;
|
|
Block block = null;
|
|
checkChange: {
|
|
if (currentStack != null) {
|
|
if (Item.getIdFromItem(currentStack.getItem()) == 0) {
|
|
doChange = false;
|
|
break checkChange;
|
|
}
|
|
|
|
block = Block.getBlockFromItem(currentStack.getItem());
|
|
if (block == null || !isValidRenderType(block.getRenderType())
|
|
|| block instanceof BlockCamo
|
|
|| block.getMaterial() == Material.air)
|
|
doChange = false;
|
|
}
|
|
}
|
|
|
|
if (doChange) {
|
|
int metadata = currentStack == null ? 0 : currentStack.getItemDamage();
|
|
if (block instanceof BlockDirectional) {
|
|
switch (par6) {
|
|
case 0:
|
|
case 1:
|
|
break;
|
|
case 2:
|
|
metadata = metadata & 12 | 2;
|
|
break;
|
|
case 3:
|
|
metadata = metadata & 12;
|
|
break;
|
|
case 4:
|
|
metadata = metadata & 12 | 1;
|
|
break;
|
|
case 5:
|
|
metadata = metadata & 12 | 3;
|
|
break;
|
|
}
|
|
}
|
|
camo.camo = currentStack == null ? Blocks.air : Block.getBlockFromItem(currentStack.getItem());
|
|
camo.camoMeta = metadata;
|
|
par1World.markBlockForUpdate(par2, par3, par4);
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean isOpaqueCube() {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean renderAsNormalBlock() {
|
|
return false;
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
@Override
|
|
public int colorMultiplier(IBlockAccess par1World, int par2, int par3, int par4) {
|
|
TileEntity tile = par1World.getTileEntity(par2, par3, par4);
|
|
if (tile instanceof TileCamo) {
|
|
TileCamo camo = (TileCamo) tile;
|
|
Block block = camo.camo;
|
|
if (block != null)
|
|
return block instanceof BlockCamo ? 0xFFFFFF : block.colorMultiplier(par1World, par2, par3, par4);
|
|
}
|
|
return 0xFFFFFF;
|
|
}
|
|
|
|
public IIcon getIconFromSideAfterCheck(TileEntity tile, int meta, int side) {
|
|
return blockIcon;
|
|
}
|
|
|
|
@Override
|
|
public Class<? extends ItemBlock> getItemBlock() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public Class<? extends TileEntity> getTileEntity() {
|
|
return null;
|
|
}
|
|
}
|