mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-20 20:22:36 +00:00
1.6.2 test - Finished liquids, added connected textures on glass
This commit is contained in:
1 parent
40c6f445a2
commit
a80fcbce86
704 files changed
+60909
No files matched your search
@@ -0,0 +1,155 @@
|
||||
package tconstruct;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.Detailing;
|
||||
import tconstruct.library.crafting.LiquidCasting;
|
||||
import tconstruct.library.util.TabTools;
|
||||
import tconstruct.skill.SkillRegistry;
|
||||
import tconstruct.util.PHConstruct;
|
||||
import tconstruct.util.TCraftingHandler;
|
||||
import tconstruct.util.TEventHandler;
|
||||
import tconstruct.util.player.TPlayerHandler;
|
||||
import tconstruct.worldgen.TBaseWorldGenerator;
|
||||
import tconstruct.worldgen.TerrainGenEventHandler;
|
||||
import tconstruct.worldgen.village.TVillageTrades;
|
||||
import tconstruct.worldgen.village.VillageSmelteryHandler;
|
||||
import tconstruct.worldgen.village.VillageToolStationHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.Mod.PostInit;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||
|
||||
/** TConstruct, the tool mod.
|
||||
* Craft your tools with style, then modify until the original is gone!
|
||||
* @author: mDiyo
|
||||
* @dependencies: IC2 API, MFR API
|
||||
*/
|
||||
|
||||
@Mod(modid = "TConstruct", name = "TConstruct", version = "1.6.2_1.4.3", dependencies = "required-after:Forge@[7.7.1.687,)")
|
||||
@NetworkMod(serverSideRequired = false, clientSideRequired = true, channels = { "TConstruct" }, packetHandler = tconstruct.util.network.TPacketHandler.class)
|
||||
public class TConstruct
|
||||
{
|
||||
/** The value of one ingot in millibuckets */
|
||||
public static final int ingotLiquidValue = 144;
|
||||
public static final int liquidUpdateAmount = 6;
|
||||
|
||||
/* Instance of this mod, used for grabbing prototype fields */
|
||||
@Instance("TConstruct")
|
||||
public static TConstruct instance;
|
||||
/* Proxies for sides, used for graphics processing */
|
||||
@SidedProxy(clientSide = "tconstruct.client.TProxyClient", serverSide = "tconstruct.common.TProxyCommon")
|
||||
public static TProxyCommon proxy;
|
||||
|
||||
public TConstruct()
|
||||
{
|
||||
if (Loader.isModLoaded("Natura"))
|
||||
{
|
||||
System.out.println("[TConstruct] Natura, what are we going to do tomorrow night?");
|
||||
System.out.println("[Natura] TConstruct, we're going to take over the world!");
|
||||
/*System.out.println("[TConstruct] They're Pinky, they're Pinky and");
|
||||
System.out.println("[Natura] the Brain Brain Brain Brain Brain~");*/
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("[TConstruct] Preparing to take over the world");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preInit (FMLPreInitializationEvent event)
|
||||
{
|
||||
PHConstruct.initProps(event.getModConfigurationDirectory());
|
||||
TConstructRegistry.materialTab = new TabTools("TConstructMaterials");
|
||||
TConstructRegistry.toolTab = new TabTools("TConstructTools");
|
||||
TConstructRegistry.blockTab = new TabTools("TConstructBlocks");
|
||||
|
||||
tableCasting = new LiquidCasting();
|
||||
basinCasting = new LiquidCasting();
|
||||
chiselDetailing = new Detailing();
|
||||
|
||||
content = new TContent();
|
||||
|
||||
events = new TEventHandler();
|
||||
events.unfuxOreDictionary();
|
||||
MinecraftForge.EVENT_BUS.register(events);
|
||||
content.oreRegistry();
|
||||
|
||||
proxy.registerRenderer();
|
||||
proxy.registerTickHandler();
|
||||
proxy.addNames();
|
||||
proxy.readManuals();
|
||||
proxy.registerKeys();
|
||||
|
||||
GameRegistry.registerWorldGenerator(new TBaseWorldGenerator());
|
||||
MinecraftForge.TERRAIN_GEN_BUS.register(new TerrainGenEventHandler());
|
||||
GameRegistry.registerFuelHandler(content);
|
||||
GameRegistry.registerCraftingHandler(new TCraftingHandler());
|
||||
NetworkRegistry.instance().registerGuiHandler(instance, proxy);
|
||||
|
||||
VillagerRegistry.instance().registerVillagerSkin(78943, new ResourceLocation("/mods/tinker/textures/mob/villagertools.png"));
|
||||
VillagerRegistry.instance().registerVillageTradeHandler(78943, new TVillageTrades());
|
||||
if (PHConstruct.addToVillages)
|
||||
{
|
||||
VillagerRegistry.instance().registerVillageCreationHandler(new VillageToolStationHandler());
|
||||
VillagerRegistry.instance().registerVillageCreationHandler(new VillageSmelteryHandler());
|
||||
}
|
||||
|
||||
/*DimensionManager.registerProviderType(-7, TinkerWorldProvider.class, true);
|
||||
DimensionManager.registerDimension(-7, -7);*/
|
||||
playerTracker = new TPlayerHandler();
|
||||
GameRegistry.registerPlayerTracker(playerTracker);
|
||||
MinecraftForge.EVENT_BUS.register(playerTracker);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init (FMLInitializationEvent event)
|
||||
{
|
||||
content.intermodCommunication();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit (FMLPostInitializationEvent evt)
|
||||
{
|
||||
content.modIntegration();
|
||||
content.createEntities();
|
||||
/*SkillRegistry.registerSkill("Wall Building", new WallBuilding());
|
||||
SkillRegistry.registerSkill("Jump", new Jump());*/
|
||||
}
|
||||
|
||||
public static LiquidCasting getTableCasting ()
|
||||
{
|
||||
return tableCasting;
|
||||
}
|
||||
|
||||
public static LiquidCasting getBasinCasting ()
|
||||
{
|
||||
return basinCasting;
|
||||
}
|
||||
|
||||
public static Detailing getChiselDetailing ()
|
||||
{
|
||||
return chiselDetailing;
|
||||
}
|
||||
|
||||
public static TContent content;
|
||||
public static TEventHandler events;
|
||||
public static TPlayerHandler playerTracker;
|
||||
public static LiquidCasting tableCasting;
|
||||
public static LiquidCasting basinCasting;
|
||||
public static Detailing chiselDetailing;
|
||||
public static SkillRegistry skillRegistry;
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.GlowstoneAggregator;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.crystal.TheftValueTracker;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class Aggregator extends InventoryBlock
|
||||
{
|
||||
public String[] textureNames = { "glowstone_top", "glowstone_top_inactive", "glowstone_side", "glowstone_bottom" };
|
||||
public Icon[] icons;
|
||||
|
||||
public Aggregator(int id)
|
||||
{
|
||||
super(id, Material.iron);
|
||||
setHardness(2.0f);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
setLightValue(1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped (int meta)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
this.icons = new Icon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:machines/aggregator_" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getBlockTexture (IBlockAccess iblockaccess, int x, int y, int z, int side)
|
||||
{
|
||||
if (side == 1)
|
||||
{
|
||||
GlowstoneAggregator logic = (GlowstoneAggregator) iblockaccess.getBlockTileEntity(x, y, z);
|
||||
if (logic.getActive())
|
||||
return icons[0];
|
||||
else
|
||||
return icons[1];
|
||||
}
|
||||
return this.getIcon(side, iblockaccess.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
if (side == 0)
|
||||
return icons[3];
|
||||
if (side == 1)
|
||||
return icons[1];
|
||||
return icons[2];
|
||||
//return icons[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack)
|
||||
{
|
||||
super.onBlockPlacedBy(world, x, y, z, entityliving, stack);
|
||||
if (!world.isRemote)
|
||||
TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock (World world, int x, int y, int z, int par5, int par6)
|
||||
{
|
||||
super.breakBlock(world, x, y, z, par5, par6);
|
||||
TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, -4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, 0));
|
||||
/*for (int iter = 0; iter < icons.length; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
return new GlowstoneAggregator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
return TProxyCommon.glowstoneAggregatorGui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
public void updateCrystalValue (World world, int x, int y, int z)
|
||||
{
|
||||
GlowstoneAggregator logic = (GlowstoneAggregator) world.getBlockTileEntity(x, y, z);
|
||||
logic.updateCrystalValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,363 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.DryingRackLogic;
|
||||
import tconstruct.client.block.DryingRackRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class DryingRack extends InventoryBlock
|
||||
{
|
||||
|
||||
public DryingRack(int id)
|
||||
{
|
||||
super(id, Material.rock);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
setHardness(12);
|
||||
setStepSound(soundMetalFootstep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
/*switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
return new FaucetLogic();
|
||||
case 2:
|
||||
return new CastingBasinLogic();
|
||||
default:
|
||||
return null;
|
||||
}*/
|
||||
return new DryingRackLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
public int onBlockPlaced (World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta)
|
||||
{
|
||||
if (side > 1)
|
||||
return side;
|
||||
return meta;
|
||||
}
|
||||
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLiving living, ItemStack stack)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 0)
|
||||
{
|
||||
int l = MathHelper.floor_double((double) (living.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
int direction = l % 2;
|
||||
if (direction == 1)
|
||||
world.setBlockMetadataWithNotify(x, y, z, 1, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/* Activation */
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ)
|
||||
{
|
||||
return activateDryingRack(world, x, y, z, player);
|
||||
}
|
||||
|
||||
boolean activateDryingRack (World world, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
DryingRackLogic logic = (DryingRackLogic) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (!logic.isStackInSlot(0))
|
||||
{
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack != null)
|
||||
{
|
||||
stack = player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
logic.setInventorySlotContents(0, stack);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logic.isStackInSlot(0))
|
||||
{
|
||||
ItemStack decrStack = logic.decrStackSize(0, 1);
|
||||
if (decrStack != null)
|
||||
addItemToInventory(player, world, x, y, z, decrStack);
|
||||
}
|
||||
}
|
||||
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addItemToInventory (EntityPlayer player, World world, int x, int y, int z, ItemStack stack)
|
||||
{
|
||||
AbilityHelper.spawnItemAtPlayer(player, stack);
|
||||
}
|
||||
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
float xMin = 0F;
|
||||
float yMin = 0F;
|
||||
float zMin = 0F;
|
||||
float xMax = 1F;
|
||||
float yMax = 1F;
|
||||
float zMax = 1F;
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
zMin = 0.375F;
|
||||
yMax = 0.25F;
|
||||
zMax = 0.625F;
|
||||
break;
|
||||
case 1:
|
||||
xMin = 0.375F;
|
||||
yMax = 0.25F;
|
||||
xMax = 0.625F;
|
||||
break;
|
||||
case 2:
|
||||
zMin = 0.75F;
|
||||
yMin = 0.75F;
|
||||
break;
|
||||
case 3:
|
||||
zMax = 0.25F;
|
||||
yMin = 0.75F;
|
||||
break;
|
||||
case 4:
|
||||
xMin = 0.75F;
|
||||
yMin = 0.75F;
|
||||
break;
|
||||
case 5:
|
||||
xMax = 0.25F;
|
||||
yMin = 0.75F;
|
||||
break;
|
||||
}
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double) x + xMin, (double) y + yMin, (double) z + zMin, (double) x + xMax, (double) y + yMax, (double) z + zMax);
|
||||
}
|
||||
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
float xMin = 0F;
|
||||
float yMin = 0F;
|
||||
float zMin = 0F;
|
||||
float xMax = 1F;
|
||||
float yMax = 1F;
|
||||
float zMax = 1F;
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
zMin = 0.375F;
|
||||
yMax = 0.25F;
|
||||
zMax = 0.625F;
|
||||
break;
|
||||
case 1:
|
||||
xMin = 0.375F;
|
||||
yMax = 0.25F;
|
||||
xMax = 0.625F;
|
||||
break;
|
||||
case 2:
|
||||
zMin = 0.75F;
|
||||
yMin = 0.75F;
|
||||
break;
|
||||
case 3:
|
||||
zMax = 0.25F;
|
||||
yMin = 0.75F;
|
||||
break;
|
||||
case 4:
|
||||
xMin = 0.75F;
|
||||
yMin = 0.75F;
|
||||
break;
|
||||
case 5:
|
||||
xMax = 0.25F;
|
||||
yMin = 0.75F;
|
||||
break;
|
||||
}
|
||||
this.setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax);
|
||||
}
|
||||
|
||||
public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity)
|
||||
{
|
||||
this.setBlockBoundsBasedOnState(world, x, y, z);
|
||||
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
|
||||
}
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return DryingRackRender.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "castingtable_top", "castingtable_side", "castingtable_bottom", "faucet", "blockcast_top", "blockcast_side", "blockcast_bottom" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
return Block.planks.getIcon(side, 0);
|
||||
}
|
||||
|
||||
public int getTextureIndex (int side)
|
||||
{
|
||||
if (side == 0)
|
||||
return 2;
|
||||
if (side == 1)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}*/
|
||||
|
||||
/*@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 3; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}*/
|
||||
|
||||
/*@Override
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta != 1)
|
||||
{
|
||||
this.setBlockBounds(0, 0, 0, 1, 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
FaucetLogic logic = (FaucetLogic) world.getBlockTileEntity(x, y, z);
|
||||
float xMin = 0.25F;
|
||||
float xMax = 0.75F;
|
||||
float zMin = 0.25F;
|
||||
float zMax = 0.75F;
|
||||
|
||||
switch (logic.getRenderDirection())
|
||||
{
|
||||
case 2:
|
||||
zMin = 0.625F;
|
||||
zMax = 1.0F;
|
||||
break;
|
||||
case 3:
|
||||
zMax = 0.375F;
|
||||
zMin = 0F;
|
||||
break;
|
||||
case 4:
|
||||
xMin = 0.625F;
|
||||
xMax = 1.0F;
|
||||
break;
|
||||
case 5:
|
||||
xMax = 0.375F;
|
||||
xMin = 0F;
|
||||
break;
|
||||
}
|
||||
|
||||
this.setBlockBounds(xMin, 0.25F, zMin, xMax, 0.625F, zMax);
|
||||
}
|
||||
}*/
|
||||
|
||||
/*@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta != 1)
|
||||
{
|
||||
return AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 1, z + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
FaucetLogic logic = (FaucetLogic) world.getBlockTileEntity(x, y, z);
|
||||
if (logic != null)
|
||||
{
|
||||
float xMin = 0.25F;
|
||||
float xMax = 0.75F;
|
||||
float zMin = 0.25F;
|
||||
float zMax = 0.75F;
|
||||
|
||||
switch (logic.getRenderDirection())
|
||||
{
|
||||
case 2:
|
||||
zMin = 0.625F;
|
||||
zMax = 1.0F;
|
||||
break;
|
||||
case 3:
|
||||
zMax = 0.375F;
|
||||
zMin = 0F;
|
||||
break;
|
||||
case 4:
|
||||
xMin = 0.625F;
|
||||
xMax = 1.0F;
|
||||
break;
|
||||
case 5:
|
||||
xMax = 0.375F;
|
||||
xMin = 0F;
|
||||
break;
|
||||
}
|
||||
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double) ((float) x + xMin), (double) y + 0.25, (double) ((float) z + zMin), (double) ((float) x + xMax), (double) y + 0.625, (double) ((float) z + zMax));
|
||||
}
|
||||
}
|
||||
|
||||
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
}*/
|
||||
|
||||
/* Redstone */
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.FrypanLogic;
|
||||
import tconstruct.client.block.FrypanRender;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class EquipBlock extends InventoryBlock
|
||||
{
|
||||
|
||||
public EquipBlock(int id, Material material)
|
||||
{
|
||||
super(id, material);
|
||||
this.setHardness(0.3f);
|
||||
this.setBlockBounds(0, 0, 0, 1, 0.25f, 1);
|
||||
//this.setCreativeTab(ToolConstruct.materialTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
return new String[] { "toolstation_top" };
|
||||
}
|
||||
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
return Block.blockIron.getIcon(side, meta);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister par1IconRegister)
|
||||
{
|
||||
//this.blockIcon = par1iconRegister.registerIcon(Block.blockIron.getUnlocalizedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return FrypanRender.frypanModelID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int idDropped (int par1, Random par2Random, int par3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
return new FrypanLogic();
|
||||
}
|
||||
|
||||
public void randomDisplayTick (World world, int x, int y, int z, Random random)
|
||||
{
|
||||
if (isActive(world, x, y, z))
|
||||
{
|
||||
float f = (float) x + 0.5F;
|
||||
float f1 = (float) y + 0.25F + (random.nextFloat() * 6F) / 16F;
|
||||
float f2 = (float) z + 0.5F;
|
||||
float f4 = random.nextFloat() * 0.6F - 0.3F;
|
||||
world.spawnParticle("smoke", f, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
public int getLightValue (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return !isActive(world, x, y, z) ? 0 : 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
return TConstruct.proxy.frypanGuiID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class GlassBlock extends TConstructBlock
|
||||
{
|
||||
static String blockTextures[] = { "glass_clear", "soulglass", "soulglass_clear" };
|
||||
|
||||
public GlassBlock(int id)
|
||||
{
|
||||
super(id, Material.glass, 3f, blockTextures);
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int i1 = par1IBlockAccess.getBlockId(par2, par3, par4);
|
||||
return i1 == this.blockID ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return 0.3F;
|
||||
case 1:
|
||||
return 50.0F;
|
||||
case 2:
|
||||
return 50.0F;
|
||||
default:
|
||||
return blockHardness;
|
||||
}
|
||||
}
|
||||
|
||||
public float getExplosionResistance (Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return 1.5F;
|
||||
case 1:
|
||||
return 2000F;
|
||||
case 2:
|
||||
return 2000F;
|
||||
default:
|
||||
return getExplosionResistance(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
this.icons = new Icon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:glass/" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,619 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/** @author fuj1n
|
||||
*
|
||||
*/
|
||||
|
||||
public class GlassBlockConnected extends Block
|
||||
{
|
||||
private Icon[] icons = new Icon[16];
|
||||
private boolean shouldRenderSelectionBox = true;
|
||||
protected String folder;
|
||||
private int renderPass;
|
||||
|
||||
public GlassBlockConnected(int par1, String location, boolean hasAlpha)
|
||||
{
|
||||
super(par1, Material.glass);
|
||||
this.setStepSound(soundGlassFootstep);
|
||||
folder = location;
|
||||
renderPass = hasAlpha ? 1 : 0;
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return renderPass;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is checked to see if the texture should connect to this block
|
||||
* @param par2 x
|
||||
* @param par3 y
|
||||
* @param par4 z
|
||||
* @param par5 ID this block is asking to connect to (may be 0 if there is no block)
|
||||
* @param par6 Metadata of the block this block is trying to connect to
|
||||
* @return true if should connect
|
||||
*/
|
||||
public boolean shouldConnectToBlock (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
return par5 == this.blockID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getBlockTexture (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return getConnectedBlockTexture(par1IBlockAccess, par2, par3, par4, par5, icons);
|
||||
}
|
||||
|
||||
public Icon getConnectedBlockTexture (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5, Icon[] icons)
|
||||
{
|
||||
boolean isOpenUp = false, isOpenDown = false, isOpenLeft = false, isOpenRight = false;
|
||||
|
||||
switch (par5)
|
||||
{
|
||||
case 0:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 + 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 + 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 + 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 + 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int i1 = par1IBlockAccess.getBlockId(par2, par3, par4);
|
||||
return i1 == this.blockID ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (int par1, int par2)
|
||||
{
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (shouldRenderSelectionBox)
|
||||
{
|
||||
return super.getSelectedBoundingBoxFromPool(par1World, par2, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
return AxisAlignedBB.getAABBPool().getAABB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons (IconRegister par1IconRegister)
|
||||
{
|
||||
icons[0] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass");
|
||||
icons[1] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_1_d");
|
||||
icons[2] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_1_u");
|
||||
icons[3] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_1_l");
|
||||
icons[4] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_1_r");
|
||||
icons[5] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_h");
|
||||
icons[6] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_v");
|
||||
icons[7] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_dl");
|
||||
icons[8] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_dr");
|
||||
icons[9] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_ul");
|
||||
icons[10] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_ur");
|
||||
icons[11] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_3_d");
|
||||
icons[12] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_3_u");
|
||||
icons[13] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_3_l");
|
||||
icons[14] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_3_r");
|
||||
icons[15] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_4");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
/** @author fuj1n
|
||||
*
|
||||
*/
|
||||
|
||||
public class GlassBlockConnectedMeta extends GlassBlockConnected
|
||||
{
|
||||
public String[] textures;
|
||||
public Icon[][] icons;
|
||||
boolean ignoreMetaForConnectedGlass = true;
|
||||
|
||||
public GlassBlockConnectedMeta(int par1, String location, boolean hasAlpha, String... textures)
|
||||
{
|
||||
super(par1, location, hasAlpha);
|
||||
this.textures = textures;
|
||||
this.icons = new Icon[textures.length][16];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getBlockTexture (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int meta = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
|
||||
if (meta < icons.length)
|
||||
{
|
||||
return getConnectedBlockTexture(par1IBlockAccess, par2, par3, par4, par5, icons[meta]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return getConnectedBlockTexture(par1IBlockAccess, par2, par3, par4, par5, icons[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldConnectToBlock (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
return par5 == this.blockID && (par6 == par1IBlockAccess.getBlockMetadata(par2, par3, par4) || ignoreMetaForConnectedGlass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (int par1, int par2)
|
||||
{
|
||||
return icons[par2][0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for (int i = 0; i < textures.length; i++)
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons (IconRegister par1IconRegister)
|
||||
{
|
||||
for (int i = 0; i < textures.length; i++)
|
||||
{
|
||||
icons[i][0] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass");
|
||||
icons[i][1] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_1_d");
|
||||
icons[i][2] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_1_u");
|
||||
icons[i][3] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_1_l");
|
||||
icons[i][4] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_1_r");
|
||||
icons[i][5] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_h");
|
||||
icons[i][6] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_v");
|
||||
icons[i][7] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_dl");
|
||||
icons[i][8] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_dr");
|
||||
icons[i][9] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_ul");
|
||||
icons[i][10] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_ur");
|
||||
icons[i][11] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_3_d");
|
||||
icons[i][12] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_3_u");
|
||||
icons[i][13] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_3_l");
|
||||
icons[i][14] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_3_r");
|
||||
icons[i][15] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_4");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped (int par1)
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class GlassBlockStained extends TConstructBlock
|
||||
{
|
||||
static String blockTextures[] = { "white", "orange", "magenta", "lightblue", "yellow", "lime", "pink", "gray", "lightgray", "cyan", "purple", "blue", "brown", "green", "red", "black" };
|
||||
String textureName;
|
||||
|
||||
public GlassBlockStained(int id, String tex)
|
||||
{
|
||||
super(id, Material.glass, 3f, blockTextures);
|
||||
this.textureName = tex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
int blockID = world.getBlockId(x, y, z);
|
||||
return blockID == this.blockID ? false : super.shouldSideBeRendered(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
this.icons = new Icon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:glass/" + textureName + textureNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
public class GlassPane extends PaneBase
|
||||
{
|
||||
static String blockTextures[] = { "glass_clear", "soulglass", "soulglass_clear" };
|
||||
|
||||
public GlassPane(int id)
|
||||
{
|
||||
super(id, Material.glass, "glass/", blockTextures);
|
||||
this.setHardness(0.3F);
|
||||
this.setStepSound(soundGlassFootstep);
|
||||
this.setUnlocalizedName("tconstruct.glasspane");
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.client.block.PaneConnectedRender;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class GlassPaneConnected extends GlassBlockConnected
|
||||
{
|
||||
|
||||
private Icon theIcon;
|
||||
|
||||
public GlassPaneConnected(int par1, String location, boolean hasAlpha)
|
||||
{
|
||||
super(par1, location, hasAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return PaneConnectedRender.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxesToList (World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
|
||||
{
|
||||
Block.thinGlass.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsForItemRender ()
|
||||
{
|
||||
Block.thinGlass.setBlockBoundsForItemRender();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
Block.thinGlass.setBlockBoundsBasedOnState(par1IBlockAccess, par2, par3, par4);
|
||||
}
|
||||
|
||||
public Icon getSideTextureIndex ()
|
||||
{
|
||||
return this.theIcon;
|
||||
}
|
||||
|
||||
public final boolean canThisPaneConnectToThisBlockID (int par1)
|
||||
{
|
||||
return Block.opaqueCubeLookup[par1] || par1 == this.blockID || par1 == Block.glass.blockID;
|
||||
}
|
||||
|
||||
public void registerIcons (IconRegister par1IconRegister)
|
||||
{
|
||||
super.registerIcons(par1IconRegister);
|
||||
this.theIcon = par1IconRegister.registerIcon("tinkersconstruct:glass/" + folder + "/glass_side");
|
||||
}
|
||||
|
||||
public boolean canPaneConnectTo (IBlockAccess access, int x, int y, int z, ForgeDirection dir)
|
||||
{
|
||||
return canThisPaneConnectToThisBlockID(access.getBlockId(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ))
|
||||
|| access.isBlockSolidOnSide(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
public class GlassPaneStained extends PaneBase
|
||||
{
|
||||
static String blockTextures[] = { "white", "orange", "magenta", "lightblue", "yellow", "lime", "pink", "gray", "lightgray", "cyan", "purple", "blue", "brown", "green", "red", "black" };
|
||||
|
||||
public GlassPaneStained(int id)
|
||||
{
|
||||
super(id, Material.glass, "glass/", assembleBlockTextures());
|
||||
this.setHardness(0.3F);
|
||||
this.setStepSound(soundGlassFootstep);
|
||||
this.setUnlocalizedName("tconstruct.glasspanestained");
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
private static String[] assembleBlockTextures ()
|
||||
{
|
||||
String[] textures = new String[blockTextures.length];
|
||||
for (int i = 0; i < blockTextures.length; i++)
|
||||
{
|
||||
textures[i] = "stainedglass_" + blockTextures[i];
|
||||
}
|
||||
return textures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.GolemCoreLogic;
|
||||
import tconstruct.client.block.GolemCoreRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GolemCoreBlock extends InventoryBlock
|
||||
{
|
||||
public GolemCoreBlock(int id)
|
||||
{
|
||||
super(id, Material.rock);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRenderType ()
|
||||
{
|
||||
return GolemCoreRender.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
GolemCoreLogic logic = (GolemCoreLogic) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (!logic.isStackInSlot(0))
|
||||
{
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
stack = player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
logic.setInventorySlotContents(0, stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack stack = logic.decrStackSize(0, 1);
|
||||
if (stack != null)
|
||||
addItemToInventory(player, world, x, y, z, stack);
|
||||
}
|
||||
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void addItemToInventory (EntityPlayer player, World world, int x, int y, int z, ItemStack stack)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
EntityItem entityitem = new EntityItem(world, (double) x + 0.5D, (double) y + 0.9325D, (double) z + 0.5D, stack);
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
entityitem.onCollideWithPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
public int damageDropped (int meta)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
return new GolemCoreLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
return null; //Not sure if gui block or not, probably not
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
return new String[] { "golemcore" };
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,146 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import tconstruct.blocks.logic.GolemPedestalLogic;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GolemPedestalBlock extends InventoryBlock
|
||||
{
|
||||
/*public static int texTop;
|
||||
public static int texTopp;
|
||||
public static int texSide;
|
||||
public static int texBottom;*/
|
||||
|
||||
public GolemPedestalBlock(int i)
|
||||
{
|
||||
super(i, Material.wood);
|
||||
/*texTop = ModLoader.addOverride("/terrain.png", "/GGE/pedestaltop.png");
|
||||
texTopp = ModLoader.addOverride("/terrain.png", "/GGE/pedestaltopp.png");
|
||||
texSide = ModLoader.addOverride("/terrain.png", "/GGE/pedestalside.png");
|
||||
texBottom = ModLoader.addOverride("/terrain.png", "/GGE/pedestalbottom.png");*/
|
||||
}
|
||||
|
||||
/*public int getIcon(int i, int j)
|
||||
{
|
||||
if (i == 1)
|
||||
{
|
||||
return j == 0 ? texTop : texTopp;
|
||||
}
|
||||
if (i == 0)
|
||||
{
|
||||
return texBottom;
|
||||
}
|
||||
if (i == 2 || i == 4)
|
||||
{
|
||||
return texSide;
|
||||
}
|
||||
else
|
||||
{
|
||||
return texSide;
|
||||
}
|
||||
}*/
|
||||
|
||||
/*public int idDropped(int i, Random random, int j)
|
||||
{
|
||||
return super.idDropped(i, random, j);
|
||||
}*/
|
||||
|
||||
/*public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)
|
||||
{
|
||||
super.onBlockPlacedBy(world, i, j, k, entityliving);
|
||||
ItemStack itemstack = ((EntityPlayer)entityliving).getCurrentEquippedItem();
|
||||
world.setBlockMetadata(i, j, k, itemstack.getItemDamage());
|
||||
}*/
|
||||
|
||||
public void onBlockRemoval (World world, int i, int j, int k)
|
||||
{
|
||||
Random random = new Random();
|
||||
GolemPedestalLogic tileentitygolempedestal = (GolemPedestalLogic) world.getBlockTileEntity(i, j, k);
|
||||
if (tileentitygolempedestal != null)
|
||||
{
|
||||
label0: for (int l = 0; l < tileentitygolempedestal.getSizeInventory(); l++)
|
||||
{
|
||||
ItemStack itemstack = tileentitygolempedestal.getStackInSlot(l);
|
||||
if (itemstack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float f = random.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = random.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = random.nextFloat() * 0.8F + 0.1F;
|
||||
do
|
||||
{
|
||||
if (itemstack.stackSize <= 0)
|
||||
{
|
||||
continue label0;
|
||||
}
|
||||
int i1 = random.nextInt(21) + 10;
|
||||
if (i1 > itemstack.stackSize)
|
||||
{
|
||||
i1 = itemstack.stackSize;
|
||||
}
|
||||
itemstack.stackSize -= i1;
|
||||
EntityItem entityitem = new EntityItem(world, (float) i + f, (float) j + f1, (float) k + f2, new ItemStack(itemstack.itemID, i1, itemstack.getItemDamage()));
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = (float) random.nextGaussian() * f3;
|
||||
entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F;
|
||||
entityitem.motionZ = (float) random.nextGaussian() * f3;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
//super.onBlockRemoval(world, i, j, k);
|
||||
}
|
||||
|
||||
public boolean blockActivated (World world, int i, int j, int k, EntityPlayer entityplayer)
|
||||
{
|
||||
/*ItemStack itemstack = entityplayer.getCurrentEquippedItem();
|
||||
if (world.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (itemstack == null || itemstack != null && (itemstack.itemID >= 256 || itemstack.itemID == 0 || itemstack.itemID == Block.slowSand.blockID))
|
||||
{
|
||||
ModLoader.openGUI(entityplayer, new GuiGolemPedestal(entityplayer.inventory, world, i, j, k));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}*/
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
return new GolemPedestalLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
|
||||
import net.minecraft.block.BlockSand;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GravelOre extends BlockSand
|
||||
{
|
||||
public String[] textureNames = new String[] { "iron", "gold", "copper", "tin", "aluminum", "cobalt" };
|
||||
public Icon[] icons;
|
||||
|
||||
public GravelOre(int id)
|
||||
{
|
||||
super(id, Material.craftedSnow);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setStepSound(soundGravelFootstep);
|
||||
}
|
||||
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
this.icons = new Icon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:ore_" + textureNames[i] + "_gravel");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[meta];
|
||||
}
|
||||
|
||||
public float getBlockHardness (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 5)
|
||||
return 10f;
|
||||
else
|
||||
return 3f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped (int meta)
|
||||
{
|
||||
/*if (meta == 1)
|
||||
return 0;*/
|
||||
return meta;
|
||||
}
|
||||
|
||||
public int idDropped (int par1, Random par2Random, int par3)
|
||||
{
|
||||
/*if (par1 == 1)
|
||||
return Item.goldNugget.itemID;*/
|
||||
return this.blockID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 6; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.blocks.logic.LavaTankLogic;
|
||||
import tconstruct.client.block.TankRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
public class LavaTankBlock extends BlockContainer
|
||||
{
|
||||
public Icon[] icons;
|
||||
|
||||
public LavaTankBlock(int id)
|
||||
{
|
||||
super(id, Material.rock);
|
||||
setHardness(12);
|
||||
setCreativeTab(TConstructRegistry.blockTab);
|
||||
setUnlocalizedName("TConstruct.LavaTank");
|
||||
setStepSound(Block.soundGlassFootstep);
|
||||
}
|
||||
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "lavatank_side", "lavatank_top", "searedgague_top", "searedgague_side", "searedgague_bottom", "searedwindow_top", "searedwindow_side", "searedwindow_bottom" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
String[] textureNames = getTextureNames();
|
||||
this.icons = new Icon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
//if (side == 0 && world.getBlockMetadata(x, y, z) == 0)
|
||||
//return super.shouldSideBeRendered(world, x, y, z, side);
|
||||
int bID = world.getBlockId(x, y, z);
|
||||
return bID == this.blockID ? false : super.shouldSideBeRendered(world, x, y, z, side);
|
||||
//return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
TileEntity logic = world.getBlockTileEntity(x, y, z);
|
||||
if (logic != null && logic instanceof LavaTankLogic)
|
||||
return ((LavaTankLogic) logic).getBrightness();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public int getRenderBlockPass()
|
||||
{
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return TankRender.tankModelID;
|
||||
}
|
||||
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
if (meta == 0)
|
||||
{
|
||||
if (side == 0 || side == 1)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
return icons[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return icons[meta * 3 + getTextureIndex(side) - 1];
|
||||
}
|
||||
}
|
||||
|
||||
public int getTextureIndex (int side)
|
||||
{
|
||||
if (side == 0)
|
||||
return 2;
|
||||
if (side == 1)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
return new LavaTankLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ)
|
||||
{
|
||||
ItemStack heldItem = player.inventory.getCurrentItem();
|
||||
if (heldItem != null)
|
||||
{
|
||||
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(player.getCurrentEquippedItem());
|
||||
LavaTankLogic logic = (LavaTankLogic) world.getBlockTileEntity(x, y, z);
|
||||
if (liquid != null)
|
||||
{
|
||||
int amount = logic.fill(ForgeDirection.UNKNOWN, liquid, false);
|
||||
if (amount == liquid.amount)
|
||||
{
|
||||
logic.fill(ForgeDirection.UNKNOWN, liquid, true);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, consumeItem(heldItem));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
else if (FluidContainerRegistry.isBucket(heldItem))
|
||||
{
|
||||
FluidTankInfo[] tanks = logic.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
FluidStack fillFluid = tanks[0].fluid;//getFluid();
|
||||
ItemStack fillStack = FluidContainerRegistry.fillFluidContainer(fillFluid, heldItem);
|
||||
if (fillStack != null)
|
||||
{
|
||||
logic.drain(ForgeDirection.UNKNOWN, FluidContainerRegistry.getFluidForFilledItem(fillStack).amount, true);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
if (heldItem.stackSize == 1)
|
||||
{
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, fillStack);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, consumeItem(heldItem));
|
||||
|
||||
if (!player.inventory.addItemStackToInventory(fillStack))
|
||||
{
|
||||
player.dropPlayerItem(fillStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack consumeItem (ItemStack stack)
|
||||
{
|
||||
if (stack.stackSize == 1)
|
||||
{
|
||||
if (stack.getItem().hasContainerItem())
|
||||
return stack.getItem().getContainerItemStack(stack);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.splitStack(1);
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world)
|
||||
{
|
||||
return createTileEntity(world, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 3; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
/* Data */
|
||||
public int damageDropped (int meta)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
/* Updates */
|
||||
public void onNeighborBlockChange (World world, int x, int y, int z, int nBlockID)
|
||||
{
|
||||
TileEntity logic = world.getBlockTileEntity(x, y, z);
|
||||
if (logic instanceof IServantLogic)
|
||||
{
|
||||
((IServantLogic) logic).notifyMasterOfChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.client.block.CrystalBlockRender;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.crystal.TheftValueTracker;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class LightCrystalBase extends Block
|
||||
{
|
||||
String[] textureNames = { "amber_crystal" };
|
||||
Icon[] icons;
|
||||
|
||||
public LightCrystalBase(int id)
|
||||
{
|
||||
super(id, Material.glass);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
if (meta < 5)
|
||||
return Block.glowStone.getIcon(side, meta);
|
||||
if (meta < 10)
|
||||
return Block.blockNetherQuartz.getIcon(side, 1);
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return CrystalBlockRender.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 15; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
this.icons = new Icon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock (World world, int x, int y, int z, int par5, int meta)
|
||||
{
|
||||
switch (meta % 5)
|
||||
{
|
||||
case 0:
|
||||
case 4:
|
||||
TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, -10);
|
||||
break;
|
||||
case 1:
|
||||
TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, -20);
|
||||
break;
|
||||
case 2:
|
||||
TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, -35);
|
||||
break;
|
||||
case 3:
|
||||
TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, -60);
|
||||
break;
|
||||
}
|
||||
|
||||
Block block = Block.blocksList[world.getBlockId(x, y - 1, z)];
|
||||
if (block == TContent.aggregator)
|
||||
{
|
||||
((Aggregator) block).updateCrystalValue(world, x, y - 1, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.BlockFluidFinite;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
public class LiquidMetalFinite extends BlockFluidFinite
|
||||
{
|
||||
String texture;
|
||||
public Icon stillIcon;
|
||||
public Icon flowIcon;
|
||||
|
||||
public LiquidMetalFinite(int id, Fluid fluid, String texture)
|
||||
{
|
||||
super(id, fluid, TContent.liquidMetal);
|
||||
this.texture = texture;
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
stillIcon = iconRegister.registerIcon("tinker:" + texture);
|
||||
flowIcon = iconRegister.registerIcon("tinker:" + texture + "_flow");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
if (side == 0 || side == 1)
|
||||
return stillIcon;
|
||||
return flowIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World par1World, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
entity.motionX *= 0.4D;
|
||||
entity.motionZ *= 0.4D;
|
||||
}
|
||||
if (!(entity instanceof EntityItem) && !entity.isImmuneToFire())
|
||||
{
|
||||
entity.attackEntityFrom(DamageSource.lava, 4);
|
||||
entity.setFire(15);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class MetalOre extends TConstructBlock
|
||||
{
|
||||
public MetalOre(int id, Material material, float hardness, String[] tex)
|
||||
{
|
||||
super(id, material, hardness, tex);
|
||||
}
|
||||
|
||||
public float getBlockHardness (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta <= 2)
|
||||
return 10f;
|
||||
else
|
||||
return 3f;
|
||||
//return this.blockHardness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 1; iter < 6; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class MultiBrick extends TConstructBlock
|
||||
{
|
||||
static String blockTextures[] = { "brick_obsidian", "brick_sandstone", "brick_netherrack", "brick_stone_refined", "brick_iron", "brick_gold", "brick_lapis", "brick_diamond", "brick_redstone",
|
||||
"brick_bone", "brick_slime", "brick_blueslime", "brick_endstone", "brick_obsidian_ingot" };
|
||||
|
||||
public MultiBrick(int id)
|
||||
{
|
||||
super(id, Material.rock, 3f, blockTextures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return Block.obsidian.getBlockHardness(world, x, y, z);
|
||||
case 1:
|
||||
return Block.sandStone.getBlockHardness(world, x, y, z);
|
||||
case 2:
|
||||
return Block.netherrack.getBlockHardness(world, x, y, z);
|
||||
case 3:
|
||||
return Block.stone.getBlockHardness(world, x, y, z);
|
||||
case 4:
|
||||
return Block.blockIron.getBlockHardness(world, x, y, z);
|
||||
case 5:
|
||||
return Block.blockGold.getBlockHardness(world, x, y, z);
|
||||
case 6:
|
||||
return Block.blockLapis.getBlockHardness(world, x, y, z);
|
||||
case 7:
|
||||
return Block.blockDiamond.getBlockHardness(world, x, y, z);
|
||||
case 8:
|
||||
return Block.blockRedstone.getBlockHardness(world, x, y, z);
|
||||
case 9:
|
||||
return 1.0F;
|
||||
case 10:
|
||||
return 1.5F;
|
||||
case 11:
|
||||
return 1.5F;
|
||||
case 12:
|
||||
return Block.whiteStone.getBlockHardness(world, x, y, z);
|
||||
case 13:
|
||||
return Block.obsidian.getBlockHardness(world, x, y, z);
|
||||
default:
|
||||
return blockHardness;
|
||||
}
|
||||
}
|
||||
|
||||
public float getExplosionResistance (Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return Block.obsidian.getExplosionResistance(entity);
|
||||
case 1:
|
||||
return Block.sandStone.getExplosionResistance(entity);
|
||||
case 2:
|
||||
return Block.netherrack.getExplosionResistance(entity);
|
||||
case 3:
|
||||
return Block.stone.getExplosionResistance(entity);
|
||||
case 4:
|
||||
return Block.blockIron.getExplosionResistance(entity);
|
||||
case 5:
|
||||
return Block.blockGold.getExplosionResistance(entity);
|
||||
case 6:
|
||||
return Block.blockLapis.getExplosionResistance(entity);
|
||||
case 7:
|
||||
return Block.blockDiamond.getExplosionResistance(entity);
|
||||
case 8:
|
||||
return Block.blockRedstone.getExplosionResistance(entity);
|
||||
case 9:
|
||||
return 1.0F;
|
||||
case 10:
|
||||
return 1.5F;
|
||||
case 11:
|
||||
return 1.5F;
|
||||
case 12:
|
||||
return Block.whiteStone.getExplosionResistance(entity);
|
||||
case 13:
|
||||
return Block.obsidian.getExplosionResistance(entity);
|
||||
default:
|
||||
return getExplosionResistance(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 10 || meta == 11)
|
||||
{
|
||||
if (entity.motionY < 0)
|
||||
entity.motionY *= -1.2F;
|
||||
entity.fallDistance = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 10 || meta == 11)
|
||||
return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 0.625D, (double) z + 1.0D);
|
||||
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return BrickRender.model;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public boolean isBlockNormalCube (World world, int x, int y, int z)
|
||||
{
|
||||
return world.getBlockMetadata(x, y, z) != 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
if (world.getBlockMetadata(x, y, z) == 8)
|
||||
return 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
this.icons = new Icon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:bricks/" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class MultiBrickFancy extends TConstructBlock
|
||||
{
|
||||
static String blockTextures[] = { "fancybrick_obsidian", "fancybrick_sandstone", "fancybrick_netherrack", "fancybrick_stone_refined", "fancybrick_iron", "fancybrick_gold", "fancybrick_lapis",
|
||||
"fancybrick_diamond", "fancybrick_redstone", "fancybrick_bone", "fancybrick_slime", "fancybrick_blueslime", "fancybrick_endstone", "fancybrick_obsidian_ingot", "fancybrick_stone",
|
||||
"road_stone" };
|
||||
|
||||
public MultiBrickFancy(int id)
|
||||
{
|
||||
super(id, Material.rock, 3f, blockTextures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return Block.obsidian.getBlockHardness(world, x, y, z);
|
||||
case 1:
|
||||
return Block.sandStone.getBlockHardness(world, x, y, z);
|
||||
case 2:
|
||||
return Block.netherrack.getBlockHardness(world, x, y, z);
|
||||
case 4:
|
||||
return Block.blockIron.getBlockHardness(world, x, y, z);
|
||||
case 5:
|
||||
return Block.blockGold.getBlockHardness(world, x, y, z);
|
||||
case 6:
|
||||
return Block.blockLapis.getBlockHardness(world, x, y, z);
|
||||
case 7:
|
||||
return Block.blockDiamond.getBlockHardness(world, x, y, z);
|
||||
case 8:
|
||||
return Block.blockRedstone.getBlockHardness(world, x, y, z);
|
||||
case 9:
|
||||
return 1.0F;
|
||||
case 10:
|
||||
return 1.5F;
|
||||
case 11:
|
||||
return 1.5F;
|
||||
case 12:
|
||||
return Block.whiteStone.getBlockHardness(world, x, y, z);
|
||||
case 13:
|
||||
return Block.obsidian.getBlockHardness(world, x, y, z);
|
||||
case 3:
|
||||
case 14:
|
||||
case 15:
|
||||
return Block.stone.getBlockHardness(world, x, y, z);
|
||||
default:
|
||||
return blockHardness;
|
||||
}
|
||||
}
|
||||
|
||||
public float getExplosionResistance (Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return Block.obsidian.getExplosionResistance(entity);
|
||||
case 1:
|
||||
return Block.sandStone.getExplosionResistance(entity);
|
||||
case 2:
|
||||
return Block.netherrack.getExplosionResistance(entity);
|
||||
case 4:
|
||||
return Block.blockIron.getExplosionResistance(entity);
|
||||
case 5:
|
||||
return Block.blockGold.getExplosionResistance(entity);
|
||||
case 6:
|
||||
return Block.blockLapis.getExplosionResistance(entity);
|
||||
case 7:
|
||||
return Block.blockDiamond.getExplosionResistance(entity);
|
||||
case 8:
|
||||
return Block.blockRedstone.getExplosionResistance(entity);
|
||||
case 9:
|
||||
return 1.0F;
|
||||
case 10:
|
||||
return 1.5F;
|
||||
case 11:
|
||||
return 1.5F;
|
||||
case 12:
|
||||
return Block.whiteStone.getExplosionResistance(entity);
|
||||
case 13:
|
||||
return Block.obsidian.getExplosionResistance(entity);
|
||||
case 3:
|
||||
case 14:
|
||||
case 15:
|
||||
return Block.stone.getExplosionResistance(entity);
|
||||
default:
|
||||
return getExplosionResistance(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 10 || meta == 11)
|
||||
{
|
||||
if (entity.motionY < 0)
|
||||
entity.motionY *= -1.2F;
|
||||
entity.fallDistance = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 10 || meta == 11)
|
||||
return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 0.625D, (double) z + 1.0D);
|
||||
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return BrickRender.model;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public boolean isBlockNormalCube (World world, int x, int y, int z)
|
||||
{
|
||||
return world.getBlockMetadata(x, y, z) != 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
if (world.getBlockMetadata(x, y, z) == 8)
|
||||
return 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
this.icons = new Icon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:bricks/" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,350 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import tconstruct.client.block.OreberryRender;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLeavesBase;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class OreberryBush extends BlockLeavesBase implements IPlantable
|
||||
{
|
||||
Random random;
|
||||
public Icon[] fastIcons;
|
||||
public Icon[] fancyIcons;
|
||||
public String[] textureNames;
|
||||
public String[] oreTypes;
|
||||
public int itemMeat;
|
||||
private int subitems;
|
||||
|
||||
public OreberryBush(int id, String[] textureNames, int meta, int sub, String[] oreTypes)
|
||||
{
|
||||
super(id, Material.leaves, false);
|
||||
this.textureNames = textureNames;
|
||||
this.itemMeat = meta;
|
||||
this.subitems = sub;
|
||||
this.oreTypes = oreTypes;
|
||||
this.setTickRandomly(true);
|
||||
random = new Random();
|
||||
this.setHardness(0.3F);
|
||||
this.setStepSound(Block.soundMetalFootstep);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
/* Berries show up at meta 12-15 */
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
this.fastIcons = new Icon[textureNames.length];
|
||||
this.fancyIcons = new Icon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.fastIcons.length; i++)
|
||||
{
|
||||
if (textureNames[i] != "")
|
||||
{
|
||||
this.fastIcons[i] = iconRegister.registerIcon("tinker:crops/" + textureNames[i] + "_fast");
|
||||
this.fancyIcons[i] = iconRegister.registerIcon("tinker:crops/" + textureNames[i] + "_fancy");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (int side, int metadata)
|
||||
{
|
||||
if (graphicsLevel)
|
||||
{
|
||||
if (metadata < 12)
|
||||
{
|
||||
return fancyIcons[metadata % 4];
|
||||
}
|
||||
else
|
||||
{
|
||||
return fancyIcons[metadata % 4 + 4];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (metadata < 12)
|
||||
{
|
||||
return fastIcons[metadata % 4];
|
||||
}
|
||||
else
|
||||
{
|
||||
return fastIcons[metadata % 4 + 4];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Bushes are stored by size then type */
|
||||
@Override
|
||||
public int damageDropped (int metadata)
|
||||
{
|
||||
return metadata % 4;
|
||||
}
|
||||
|
||||
/* The following methods define a berry bush's size depending on metadata */
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
int l = world.getBlockMetadata(x, y, z);
|
||||
if (l < 4)
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox((double) x + 0.25D, y, (double) z + 0.25D, (double) x + 0.75D, (double) y + 0.5D, (double) z + 0.75D);
|
||||
}
|
||||
else if (l < 8)
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y, (double) z + 0.125D, (double) x + 0.875D, (double) y + 0.75D, (double) z + 0.875D);
|
||||
}
|
||||
else
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox(x + 0.0625, y, z + 0.0625, (double) x + 0.9375D, (double) y + 0.9375D, (double) z + 0.9375D);
|
||||
}
|
||||
}
|
||||
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
int l = world.getBlockMetadata(x, y, z);
|
||||
if (l < 4)
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox((double) x + 0.25D, y, (double) z + 0.25D, (double) x + 0.75D, (double) y + 0.5D, (double) z + 0.75D);
|
||||
}
|
||||
else if (l < 8)
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y, (double) z + 0.125D, (double) x + 0.875D, (double) y + 0.75D, (double) z + 0.875D);
|
||||
}
|
||||
else
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 1.0D, (double) z + 1.0D);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess iblockaccess, int x, int y, int z)
|
||||
{
|
||||
int md = iblockaccess.getBlockMetadata(x, y, z);
|
||||
|
||||
float minX;
|
||||
float minY = 0F;
|
||||
float minZ;
|
||||
float maxX;
|
||||
float maxY;
|
||||
float maxZ;
|
||||
|
||||
if (md < 4)
|
||||
{
|
||||
minX = minZ = 0.25F;
|
||||
maxX = maxZ = 0.75F;
|
||||
maxY = 0.5F;
|
||||
}
|
||||
else
|
||||
|
||||
if (md < 8)
|
||||
{
|
||||
minX = minZ = 0.125F;
|
||||
maxX = maxZ = 0.875F;
|
||||
maxY = 0.75F;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
minX = minZ = 0.0F;
|
||||
maxX = maxZ = 1.0F;
|
||||
maxY = 1.0F;
|
||||
}
|
||||
setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
/* Left-click harvests berries */
|
||||
@Override
|
||||
public void onBlockClicked (World world, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta >= 12)
|
||||
{
|
||||
world.setBlock(x, y, z, blockID, meta - 4, 3);
|
||||
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TContent.oreBerries, 1, meta % 4 + itemMeat));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Right-click harvests berries */
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
/*if (world.isRemote)
|
||||
return false;*/
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta >= 12)
|
||||
{
|
||||
if (world.isRemote)
|
||||
return true;
|
||||
|
||||
world.setBlock(x, y, z, blockID, meta - 4, 3);
|
||||
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TContent.oreBerries, 1, meta % 4 + itemMeat));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Render logic */
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setGraphicsLevel (boolean flag)
|
||||
{
|
||||
graphicsLevel = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRenderType ()
|
||||
{
|
||||
return OreberryRender.model;
|
||||
}
|
||||
|
||||
public boolean shouldSideBeRendered (IBlockAccess iblockaccess, int x, int y, int z, int meta)
|
||||
{
|
||||
if (meta > 7 || graphicsLevel)
|
||||
{
|
||||
return super.shouldSideBeRendered(iblockaccess, x, y, z, meta);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Bush growth */
|
||||
|
||||
@Override
|
||||
public void updateTick (World world, int x, int y, int z, Random random1)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (random1.nextInt(20) == 0)// && world.getBlockLightValue(x, y, z) <= 8)
|
||||
{
|
||||
if (world.getFullBlockLightValue(x, y, z) < 10)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta < 12)
|
||||
{
|
||||
world.setBlock(x, y, z, blockID, meta + 4, 3);
|
||||
}
|
||||
}
|
||||
/*else if (meta < 8)
|
||||
{
|
||||
world.setBlock(x, y, z, blockID, meta + 4, 3);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canSustainPlant (World world, int x, int y, int z, ForgeDirection direction, IPlantable plant)
|
||||
{
|
||||
if (plant instanceof OreberryBush)
|
||||
return (world.getBlockMetadata(x, y, z) > 7);
|
||||
return super.canSustainPlant(world, x, y, z, direction, plant);
|
||||
}
|
||||
|
||||
public boolean canPlaceBlockAt (World world, int x, int y, int z)
|
||||
{
|
||||
if (world.getFullBlockLightValue(x, y, z) < 13)
|
||||
return super.canPlaceBlockAt(world, x, y, z);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Resistance to fire */
|
||||
|
||||
@Override
|
||||
public int getFlammability (IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlammable (IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireSpreadSpeed (World world, int x, int y, int z, int metadata, ForgeDirection face)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubBlocks (int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for (int var4 = 8; var4 < 8 + subitems; ++var4)
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, var4));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPlantType getPlantType (World world, int x, int y, int z)
|
||||
{
|
||||
return EnumPlantType.Cave;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlantID (World world, int x, int y, int z)
|
||||
{
|
||||
return this.blockID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlantMetadata (World world, int x, int y, int z)
|
||||
{
|
||||
return world.getBlockMetadata(x, y, z) - 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (!(entity instanceof EntityItem))
|
||||
entity.attackEntityFrom(DamageSource.cactus, 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
public class OreberryBushEssence extends OreberryBush implements IPlantable
|
||||
{
|
||||
public OreberryBushEssence(int id, String[] textureNames, int meta, int sub, String[] oreTypes)
|
||||
{
|
||||
super(id, textureNames, meta, sub, oreTypes);
|
||||
}
|
||||
|
||||
/* Bush growth */
|
||||
|
||||
@Override
|
||||
public void updateTick (World world, int x, int y, int z, Random random1)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (random1.nextInt(20) == 0)// && world.getBlockLightValue(x, y, z) <= 8)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (world.getFullBlockLightValue(x, y, z) < 10 || meta % 4 == 1)
|
||||
{
|
||||
if (meta < 12)
|
||||
{
|
||||
world.setBlock(x, y, z, blockID, meta + 4, 3);
|
||||
}
|
||||
}
|
||||
/*else if (meta < 8)
|
||||
{
|
||||
world.setBlock(x, y, z, blockID, meta + 4, 3);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canPlaceBlockAt (World world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
/*if (world.getFullBlockLightValue(x, y, z) < 13)
|
||||
return super.canPlaceBlockAt(world, x, y, z);
|
||||
return false;*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.client.block.PaneRender;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockPane;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PaneBase extends Block
|
||||
{
|
||||
public String[] textureNames;
|
||||
public String folder;
|
||||
public Icon[] icons;
|
||||
public Icon[] sideIcons;
|
||||
|
||||
public PaneBase(int id, Material material, String folder, String[] blockTextures)
|
||||
{
|
||||
super(id, material);
|
||||
textureNames = blockTextures;
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
public boolean canConnectTo (int blockID)
|
||||
{
|
||||
Block block = Block.blocksList[blockID];
|
||||
return Block.opaqueCubeLookup[blockID] || block instanceof PaneBase || block instanceof BlockPane || blockID == Block.glass.blockID;
|
||||
}
|
||||
|
||||
public Icon getSideTextureIndex (int meta)
|
||||
{
|
||||
return sideIcons[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
this.icons = new Icon[textureNames.length];
|
||||
this.sideIcons = new Icon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i]);
|
||||
this.sideIcons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i] + "_side");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < textureNames.length; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRenderType ()
|
||||
{
|
||||
return PaneRender.model;
|
||||
}
|
||||
|
||||
public boolean shouldSideBeRendered (IBlockAccess iblockaccess, int i, int j, int k, int l)
|
||||
{
|
||||
int bID = iblockaccess.getBlockId(i, j, k);
|
||||
if (Block.blocksList[bID] instanceof PaneBase || Block.blocksList[bID] instanceof BlockPane)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.shouldSideBeRendered(iblockaccess, i, j, k, l);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List arraylist, Entity entity)
|
||||
{
|
||||
boolean south = canConnectTo(world.getBlockId(x, y, z - 1));
|
||||
boolean north = canConnectTo(world.getBlockId(x, y, z + 1));
|
||||
boolean east = canConnectTo(world.getBlockId(x - 1, y, z));
|
||||
boolean west = canConnectTo(world.getBlockId(x + 1, y, z));
|
||||
if (east && west || !east && !west && !south && !north)
|
||||
{
|
||||
setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
|
||||
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
|
||||
}
|
||||
else if (east && !west)
|
||||
{
|
||||
setBlockBounds(0.0F, 0.0F, 0.4375F, 0.5F, 1.0F, 0.5625F);
|
||||
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
|
||||
}
|
||||
else if (!east && west)
|
||||
{
|
||||
setBlockBounds(0.5F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
|
||||
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
|
||||
}
|
||||
if (south && north || !east && !west && !south && !north)
|
||||
{
|
||||
setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F);
|
||||
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
|
||||
}
|
||||
else if (south && !north)
|
||||
{
|
||||
setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 0.5F);
|
||||
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
|
||||
}
|
||||
else if (!south && north)
|
||||
{
|
||||
setBlockBounds(0.4375F, 0.0F, 0.5F, 0.5625F, 1.0F, 1.0F);
|
||||
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
|
||||
}
|
||||
}
|
||||
|
||||
public void setBlockBoundsForItemRender ()
|
||||
{
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess iblockaccess, int i, int j, int k)
|
||||
{
|
||||
float f = 0.4375F;
|
||||
float f1 = 0.5625F;
|
||||
float f2 = 0.4375F;
|
||||
float f3 = 0.5625F;
|
||||
boolean flag = canConnectTo(iblockaccess.getBlockId(i, j, k - 1));
|
||||
boolean flag1 = canConnectTo(iblockaccess.getBlockId(i, j, k + 1));
|
||||
boolean flag2 = canConnectTo(iblockaccess.getBlockId(i - 1, j, k));
|
||||
boolean flag3 = canConnectTo(iblockaccess.getBlockId(i + 1, j, k));
|
||||
if (flag2 && flag3 || !flag2 && !flag3 && !flag && !flag1)
|
||||
{
|
||||
f = 0.0F;
|
||||
f1 = 1.0F;
|
||||
}
|
||||
else if (flag2 && !flag3)
|
||||
{
|
||||
f = 0.0F;
|
||||
}
|
||||
else if (!flag2 && flag3)
|
||||
{
|
||||
f1 = 1.0F;
|
||||
}
|
||||
if (flag && flag1 || !flag2 && !flag3 && !flag && !flag1)
|
||||
{
|
||||
f2 = 0.0F;
|
||||
f3 = 1.0F;
|
||||
}
|
||||
else if (flag && !flag1)
|
||||
{
|
||||
f2 = 0.0F;
|
||||
}
|
||||
else if (!flag && flag1)
|
||||
{
|
||||
f3 = 1.0F;
|
||||
}
|
||||
setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import tconstruct.client.block.BallRepeaterRender;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRedstoneLogic;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class RedstoneBallRepeater extends BlockRedstoneLogic
|
||||
{
|
||||
/** The offsets for the two torches in redstone repeater blocks. */
|
||||
public static final double[] repeaterTorchOffset = new double[] { -0.0625D, 0.0625D, 0.1875D, 0.3125D };
|
||||
|
||||
/** The states in which the redstone repeater blocks can be. */
|
||||
public static final int[] repeaterState = new int[] { 1, 2, 3, 4 };
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static Icon field_94413_c;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static Icon field_94410_cO;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static Icon field_94411_cP;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static Icon field_94412_cQ;
|
||||
|
||||
public RedstoneBallRepeater(int par1, boolean par2)
|
||||
{
|
||||
super(par1, par2);
|
||||
//this.setCreativeTab(CreativeTabs.tabRedstone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called upon block activation (right click on the block.)
|
||||
*/
|
||||
public boolean onBlockActivated (World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
int i1 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
int j1 = (i1 & 12) >> 2;
|
||||
j1 = j1 + 1 << 2 & 12;
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, j1 | i1 & 3, 3);
|
||||
return true;
|
||||
}
|
||||
|
||||
public int func_94481_j_ (int par1)
|
||||
{
|
||||
return repeaterState[(par1 & 12) >> 2] * 2;
|
||||
}
|
||||
|
||||
public BlockRedstoneLogic func_94485_e ()
|
||||
{
|
||||
return Block.redstoneRepeaterActive;
|
||||
}
|
||||
|
||||
public BlockRedstoneLogic func_94484_i ()
|
||||
{
|
||||
return Block.redstoneRepeaterIdle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped (int par1, Random par2Random, int par3)
|
||||
{
|
||||
return this.blockID;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
/**
|
||||
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
|
||||
*/
|
||||
/*public int idPicked(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return Item.redstoneRepeater.itemID;
|
||||
}*/
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType ()
|
||||
{
|
||||
return BallRepeaterRender.model;
|
||||
}
|
||||
|
||||
public boolean func_94476_e (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return this.func_94482_f(par1IBlockAccess, par2, par3, par4, par5) > 0;
|
||||
}
|
||||
|
||||
public boolean func_94477_d (int par1)
|
||||
{
|
||||
return isRedstoneRepeaterBlockID(par1);
|
||||
}
|
||||
|
||||
public static boolean isPowerProviderOrWire (IBlockAccess par0IBlockAccess, int par1, int par2, int par3, int par4)
|
||||
{
|
||||
int i1 = par0IBlockAccess.getBlockId(par1, par2, par3);
|
||||
|
||||
if (i1 == Block.redstoneWire.blockID)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (i1 == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!Block.redstoneRepeaterIdle.func_94487_f(i1))
|
||||
{
|
||||
return (Block.blocksList[i1] != null && Block.blocksList[i1].canConnectRedstone(par0IBlockAccess, par1, par2, par3, par4));
|
||||
}
|
||||
else
|
||||
{
|
||||
int j1 = par0IBlockAccess.getBlockMetadata(par1, par2, par3);
|
||||
return par4 == (j1 & 3) || par4 == Direction.rotateOpposite[j1 & 3];
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
/**
|
||||
* A randomly called display update to be able to add particles or other items for display
|
||||
*/
|
||||
public void randomDisplayTick (World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
if (this.isRepeaterPowered)
|
||||
{
|
||||
int l = par1World.getBlockMetadata(par2, par3, par4);
|
||||
int i1 = getDirection(l);
|
||||
double d0 = (double) ((float) par2 + 0.5F) + (double) (par5Random.nextFloat() - 0.5F) * 0.2D;
|
||||
double d1 = (double) ((float) par3 + 0.4F) + (double) (par5Random.nextFloat() - 0.5F) * 0.2D;
|
||||
double d2 = (double) ((float) par4 + 0.5F) + (double) (par5Random.nextFloat() - 0.5F) * 0.2D;
|
||||
double d3 = 0.0D;
|
||||
double d4 = 0.0D;
|
||||
|
||||
if (par5Random.nextInt(2) == 0)
|
||||
{
|
||||
switch (i1)
|
||||
{
|
||||
case 0:
|
||||
d4 = -0.3125D;
|
||||
break;
|
||||
case 1:
|
||||
d3 = 0.3125D;
|
||||
break;
|
||||
case 2:
|
||||
d4 = 0.3125D;
|
||||
break;
|
||||
case 3:
|
||||
d3 = -0.3125D;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int j1 = (l & 12) >> 2;
|
||||
|
||||
switch (i1)
|
||||
{
|
||||
case 0:
|
||||
d4 = repeaterTorchOffset[j1];
|
||||
break;
|
||||
case 1:
|
||||
d3 = -repeaterTorchOffset[j1];
|
||||
break;
|
||||
case 2:
|
||||
d4 = -repeaterTorchOffset[j1];
|
||||
break;
|
||||
case 3:
|
||||
d3 = repeaterTorchOffset[j1];
|
||||
}
|
||||
}
|
||||
|
||||
par1World.spawnParticle("reddust", d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canPlaceBlockAt (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) || par1World.getBlockId(par2, par3 - 1, par4) == Block.glowStone.blockID;
|
||||
}
|
||||
|
||||
/**
|
||||
* ejects contained items into the world, and notifies neighbours of an update, as appropriate
|
||||
*/
|
||||
public void breakBlock (World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
this.func_94483_i_(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int colorMultiplier (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
return 8388608;
|
||||
}
|
||||
|
||||
public void registerIcons (IconRegister par1IconRegister)
|
||||
{
|
||||
this.field_94413_c = par1IconRegister.registerIcon("tinker:repeaterDust_cross");
|
||||
this.field_94410_cO = par1IconRegister.registerIcon("tinker:repeaterDust_line");
|
||||
this.field_94411_cP = par1IconRegister.registerIcon("tinker:repeaterDust_cross_overlay");
|
||||
this.field_94412_cQ = par1IconRegister.registerIcon("tinker:repeaterDust_line_overlay");
|
||||
this.blockIcon = this.field_94413_c;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static Icon func_94409_b (String par0Str)
|
||||
{
|
||||
return par0Str == "repeaterDust_cross" ? field_94413_c : (par0Str == "repeaterDust_line" ? field_94410_cO : (par0Str == "repeaterDust_cross_overlay" ? field_94411_cP
|
||||
: (par0Str == "repeaterDust_line_overlay" ? field_94412_cQ : null)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import static net.minecraftforge.common.ForgeDirection.UP;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.DrawbridgeLogic;
|
||||
import tconstruct.blocks.logic.FirestarterLogic;
|
||||
import tconstruct.client.block.MachineRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
import tconstruct.library.util.IActiveLogic;
|
||||
import tconstruct.library.util.IFacingLogic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class RedstoneMachine extends InventoryBlock
|
||||
{
|
||||
public RedstoneMachine(int id)
|
||||
{
|
||||
super(id, Material.iron);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
setHardness(12);
|
||||
setStepSound(soundMetalFootstep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
if (world.getBlockMetadata(x, y, z) == 0)
|
||||
{
|
||||
TileEntity logic = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (logic != null && logic instanceof IInventory)
|
||||
{
|
||||
if (((IInventory) logic).getStackInSlot(1) != null)
|
||||
{
|
||||
return lightValue[((IInventory) logic).getStackInSlot(1).itemID];
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getLightValue(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
return new DrawbridgeLogic();
|
||||
case 1:
|
||||
return new FirestarterLogic();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return TConstruct.proxy.drawbridgeGui;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
/* Rendering */
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "drawbridge_top", "drawbridge_side", "drawbridge_bottom", "drawbridge_top_face", "drawbridge_side_face", "drawbridge_bottom_face", "firestarter_top",
|
||||
"firestarter_side", "firestarter_bottom" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
String[] textureNames = getTextureNames();
|
||||
this.icons = new Icon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:machines/" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
if (meta == 0)
|
||||
{
|
||||
if (side == 5)
|
||||
return icons[5];
|
||||
return icons[getTextureIndex(side)];
|
||||
}
|
||||
if (meta == 1)
|
||||
{
|
||||
return icons[getTextureIndex(side) + 6];
|
||||
}
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
public Icon getBlockTexture (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
TileEntity logic = world.getBlockTileEntity(x, y, z);
|
||||
short direction = (logic instanceof IFacingLogic) ? ((IFacingLogic) logic).getRenderDirection() : 0;
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 0)
|
||||
{
|
||||
DrawbridgeLogic drawbridge = (DrawbridgeLogic) logic;
|
||||
ItemStack stack = drawbridge.getStackInSlot(1);
|
||||
if (stack != null && stack.itemID < 4096)
|
||||
{
|
||||
Block block = Block.blocksList[stack.itemID];
|
||||
if (block != null && block.renderAsNormalBlock())
|
||||
return block.getIcon(side, stack.getItemDamage());
|
||||
}
|
||||
if (side == direction)
|
||||
{
|
||||
return icons[getTextureIndex(side) + 3];
|
||||
}
|
||||
else
|
||||
{
|
||||
return icons[getTextureIndex(side)];
|
||||
}
|
||||
}
|
||||
|
||||
if (meta == 1)
|
||||
{
|
||||
if (side == direction)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (side / 2 == direction / 2)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
return icons[7];
|
||||
}
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
public int getTextureIndex (int side)
|
||||
{
|
||||
if (side == 0)
|
||||
return 2;
|
||||
if (side == 1)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int getRenderType ()
|
||||
{
|
||||
return MachineRender.model;
|
||||
}
|
||||
|
||||
public boolean isFireSource (World world, int x, int y, int z, int metadata, ForgeDirection side)
|
||||
{
|
||||
if (metadata == 1)
|
||||
return side == UP;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 2; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
/* Redstone */
|
||||
public void onNeighborBlockChange (World world, int x, int y, int z, int neighborBlockID)
|
||||
{
|
||||
IActiveLogic logic = (IActiveLogic) world.getBlockTileEntity(x, y, z);
|
||||
logic.setActive(world.isBlockIndirectlyGettingPowered(x, y, z));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.CastingBasinLogic;
|
||||
import tconstruct.blocks.logic.CastingTableLogic;
|
||||
import tconstruct.blocks.logic.FaucetLogic;
|
||||
import tconstruct.client.block.SearedRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SearedBlock extends InventoryBlock
|
||||
{
|
||||
|
||||
public SearedBlock(int id)
|
||||
{
|
||||
super(id, Material.rock);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
setHardness(12);
|
||||
setStepSound(soundMetalFootstep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
return new CastingTableLogic();
|
||||
case 1:
|
||||
return new FaucetLogic();
|
||||
case 2:
|
||||
return new CastingBasinLogic();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
/* Activation */
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ)
|
||||
{
|
||||
int md = world.getBlockMetadata(x, y, z);
|
||||
if (md == 0)
|
||||
{
|
||||
return activateCastingTable(world, x, y, z, player);
|
||||
}
|
||||
if (md == 2)
|
||||
{
|
||||
return activateCastingBasin(world, x, y, z, player);
|
||||
}
|
||||
else if (md == 1)
|
||||
{
|
||||
if (player.isSneaking())
|
||||
return false;
|
||||
|
||||
FaucetLogic logic = (FaucetLogic) world.getBlockTileEntity(x, y, z);
|
||||
logic.setActive(true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return super.onBlockActivated(world, x, y, z, player, side, clickX, clickY, clickZ);
|
||||
}
|
||||
|
||||
boolean activateCastingTable (World world, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
CastingTableLogic logic = (CastingTableLogic) world.getBlockTileEntity(x, y, z);
|
||||
if (logic.liquid != null)
|
||||
return true;
|
||||
|
||||
if (!logic.isStackInSlot(0) && !logic.isStackInSlot(1))
|
||||
{
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
stack = player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
logic.setInventorySlotContents(0, stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logic.isStackInSlot(1))
|
||||
{
|
||||
ItemStack stack = logic.decrStackSize(1, 1);
|
||||
if (stack != null)
|
||||
addItemToInventory(player, world, x, y, z, stack);
|
||||
}
|
||||
else if (logic.isStackInSlot(0))
|
||||
{
|
||||
ItemStack stack = logic.decrStackSize(0, 1);
|
||||
if (stack != null)
|
||||
addItemToInventory(player, world, x, y, z, stack);
|
||||
}
|
||||
}
|
||||
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean activateCastingBasin (World world, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
CastingBasinLogic logic = (CastingBasinLogic) world.getBlockTileEntity(x, y, z);
|
||||
if (logic.liquid != null)
|
||||
return true;
|
||||
|
||||
if (!logic.isStackInSlot(0) && !logic.isStackInSlot(1))
|
||||
{
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
stack = player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
logic.setInventorySlotContents(0, stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logic.isStackInSlot(1))
|
||||
{
|
||||
ItemStack stack = logic.decrStackSize(1, 1);
|
||||
if (stack != null)
|
||||
addItemToInventory(player, world, x, y, z, stack);
|
||||
}
|
||||
else if (logic.isStackInSlot(0))
|
||||
{
|
||||
ItemStack stack = logic.decrStackSize(0, 1);
|
||||
if (stack != null)
|
||||
addItemToInventory(player, world, x, y, z, stack);
|
||||
}
|
||||
}
|
||||
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addItemToInventory (EntityPlayer player, World world, int x, int y, int z, ItemStack stack)
|
||||
{
|
||||
AbilityHelper.spawnItemAtPlayer(player, stack);
|
||||
/*if (!world.isRemote)
|
||||
{
|
||||
EntityItem entityitem = new EntityItem(world, (double) x + 0.5D, (double) y + 0.9325D, (double) z + 0.5D, stack);
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
entityitem.onCollideWithPlayer(player);
|
||||
}*/
|
||||
}
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return SearedRender.searedModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "castingtable_top", "castingtable_side", "castingtable_bottom", "faucet", "blockcast_top", "blockcast_side", "blockcast_bottom" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
if (meta == 0)
|
||||
return icons[getTextureIndex(side)];
|
||||
else if (meta == 2)
|
||||
return icons[getTextureIndex(side) + 4];
|
||||
else
|
||||
return icons[3];
|
||||
}
|
||||
|
||||
public int getTextureIndex (int side)
|
||||
{
|
||||
if (side == 0)
|
||||
return 2;
|
||||
if (side == 1)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 3; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta != 1)
|
||||
{
|
||||
this.setBlockBounds(0, 0, 0, 1, 1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
FaucetLogic logic = (FaucetLogic) world.getBlockTileEntity(x, y, z);
|
||||
float xMin = 0.25F;
|
||||
float xMax = 0.75F;
|
||||
float zMin = 0.25F;
|
||||
float zMax = 0.75F;
|
||||
|
||||
switch (logic.getRenderDirection())
|
||||
{
|
||||
case 2:
|
||||
zMin = 0.625F;
|
||||
zMax = 1.0F;
|
||||
break;
|
||||
case 3:
|
||||
zMax = 0.375F;
|
||||
zMin = 0F;
|
||||
break;
|
||||
case 4:
|
||||
xMin = 0.625F;
|
||||
xMax = 1.0F;
|
||||
break;
|
||||
case 5:
|
||||
xMax = 0.375F;
|
||||
xMin = 0F;
|
||||
break;
|
||||
}
|
||||
|
||||
this.setBlockBounds(xMin, 0.25F, zMin, xMax, 0.625F, zMax);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta != 1)
|
||||
{
|
||||
return AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 1, z + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
FaucetLogic logic = (FaucetLogic) world.getBlockTileEntity(x, y, z);
|
||||
if (logic != null)
|
||||
{
|
||||
float xMin = 0.25F;
|
||||
float xMax = 0.75F;
|
||||
float zMin = 0.25F;
|
||||
float zMax = 0.75F;
|
||||
|
||||
switch (logic.getRenderDirection())
|
||||
{
|
||||
case 2:
|
||||
zMin = 0.625F;
|
||||
zMax = 1.0F;
|
||||
break;
|
||||
case 3:
|
||||
zMax = 0.375F;
|
||||
zMin = 0F;
|
||||
break;
|
||||
case 4:
|
||||
xMin = 0.625F;
|
||||
xMax = 1.0F;
|
||||
break;
|
||||
case 5:
|
||||
xMax = 0.375F;
|
||||
xMin = 0F;
|
||||
break;
|
||||
}
|
||||
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double) ((float) x + xMin), (double) y + 0.25, (double) ((float) z + zMin), (double) ((float) x + xMax), (double) y + 0.625,
|
||||
(double) ((float) z + zMax));
|
||||
}
|
||||
}
|
||||
|
||||
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
}
|
||||
|
||||
/* Redstone */
|
||||
public boolean canConnectRedstone (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
return world.getBlockMetadata(x, y, z) == 1;
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange (World world, int x, int y, int z, int neighborBlockID)
|
||||
{
|
||||
if (world.isBlockIndirectlyGettingPowered(x, y, z) && world.getBlockMetadata(x, y, z) == 1)
|
||||
{
|
||||
FaucetLogic logic = (FaucetLogic) world.getBlockTileEntity(x, y, z);
|
||||
logic.setActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SearedSlab extends SlabBase
|
||||
{
|
||||
public SearedSlab(int id)
|
||||
{
|
||||
super(id, Material.rock);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
setHardness(12F);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
meta = meta % 8;
|
||||
if (meta == 0)
|
||||
return TContent.smeltery.getIcon(side, 2);
|
||||
if (meta <= 3)
|
||||
return TContent.smeltery.getIcon(side, meta + 3);
|
||||
|
||||
return TContent.smeltery.getIcon(side, meta + 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 8; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SlabBase extends Block
|
||||
{
|
||||
public SlabBase(int id, Material material)
|
||||
{
|
||||
super(id, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List arraylist, Entity entity)
|
||||
{
|
||||
setBlockBoundsBasedOnState(world, x, y, z);
|
||||
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
|
||||
}
|
||||
|
||||
public void setBlockBoundsForItemRender ()
|
||||
{
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
|
||||
}
|
||||
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z) / 8;
|
||||
float minY = meta == 1 ? 0.5F : 0.0F;
|
||||
float maxY = meta == 1 ? 1.0F : 0.5F;
|
||||
setBlockBounds(0.0F, minY, 0F, 1.0F, maxY, 1.0F);
|
||||
}
|
||||
|
||||
public int onBlockPlaced (World par1World, int blockX, int blockY, int blockZ, int side, float clickX, float clickY, float clickZ, int metadata)
|
||||
{
|
||||
if (side == 1)
|
||||
return metadata;
|
||||
if (side == 0 || clickY >= 0.5F)
|
||||
return metadata | 8;
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.MultiServantLogic;
|
||||
import tconstruct.blocks.logic.SmelteryDrainLogic;
|
||||
import tconstruct.blocks.logic.SmelteryLogic;
|
||||
import tconstruct.client.block.SmelteryRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
import tconstruct.library.util.IFacingLogic;
|
||||
import tconstruct.library.util.IMasterLogic;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SmelteryBlock extends InventoryBlock
|
||||
{
|
||||
Random rand;
|
||||
|
||||
public SmelteryBlock(int id)
|
||||
{
|
||||
super(id, Material.rock);
|
||||
setHardness(12F);
|
||||
setStepSound(soundMetalFootstep);
|
||||
rand = new Random();
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setUnlocalizedName("tconstruct.Smeltery");
|
||||
}
|
||||
|
||||
/* Rendering */
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return SmelteryRender.smelteryModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "smeltery_side", "smeltery_inactive", "smeltery_active", "drain_side", "drain_out", "drain_basin", "searedbrick", "searedstone", "searedcobble", "searedpaver",
|
||||
"searedbrickcracked", "searedroad", "searedbrickfancy", "searedbricksquare", "searedcreeper" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
if (meta < 2)
|
||||
{
|
||||
int sideTex = side == 3 ? 1 : 0;
|
||||
return icons[sideTex + meta * 3];
|
||||
}
|
||||
else if (meta == 2)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (meta == 11)
|
||||
{
|
||||
if (side == 0 || side == 1)
|
||||
return icons[9];
|
||||
}
|
||||
|
||||
return icons[3 + meta];
|
||||
}
|
||||
|
||||
public Icon getBlockTexture (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
TileEntity logic = world.getBlockTileEntity(x, y, z);
|
||||
short direction = (logic instanceof IFacingLogic) ? ((IFacingLogic) logic).getRenderDirection() : 0;
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 0) //Smeltery
|
||||
{
|
||||
if (side == direction)
|
||||
{
|
||||
if (isActive(world, x, y, z))
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return icons[0];
|
||||
}
|
||||
}
|
||||
if (meta == 1) //Drain
|
||||
{
|
||||
if (side == direction)
|
||||
return icons[5];
|
||||
else if (side / 2 == direction / 2)
|
||||
return icons[4];
|
||||
else
|
||||
return icons[3];
|
||||
}
|
||||
else if (meta == 2)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (meta == 11)
|
||||
{
|
||||
if (side == 0 || side == 1)
|
||||
return icons[9];
|
||||
}
|
||||
return icons[3 + meta];
|
||||
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public int getRenderBlockPass()
|
||||
{
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
public int damageDropped (int meta)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
public int quantityDropped (Random random)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
return TConstruct.proxy.smelteryGuiID;
|
||||
}
|
||||
|
||||
public void randomDisplayTick (World world, int x, int y, int z, Random random)
|
||||
{
|
||||
if (isActive(world, x, y, z))
|
||||
{
|
||||
TileEntity logic = world.getBlockTileEntity(x, y, z);
|
||||
byte face = 0;
|
||||
if (logic instanceof IFacingLogic)
|
||||
face = ((IFacingLogic) logic).getRenderDirection();
|
||||
float f = (float) x + 0.5F;
|
||||
float f1 = (float) y + 0.5F + (random.nextFloat() * 6F) / 16F;
|
||||
float f2 = (float) z + 0.5F;
|
||||
float f3 = 0.52F;
|
||||
float f4 = random.nextFloat() * 0.6F - 0.3F;
|
||||
switch (face)
|
||||
{
|
||||
case 4:
|
||||
world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getLightValue (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return !isActive(world, x, y, z) ? 0 : 9;
|
||||
}
|
||||
|
||||
//@Override
|
||||
/*public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 9; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ)
|
||||
{
|
||||
if (player.isSneaking() || world.getBlockMetadata(x, y, z) != 0)
|
||||
return false;
|
||||
|
||||
Integer integer = getGui(world, x, y, z, player);
|
||||
if (integer == null || integer == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.openGui(getModInstance(), integer, world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
return new SmelteryLogic();
|
||||
case 1:
|
||||
return new SmelteryDrainLogic();
|
||||
case 3:
|
||||
return null; //Furnace
|
||||
}
|
||||
return new MultiServantLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack)
|
||||
{
|
||||
super.onBlockPlacedBy(world, x, y, z, entityliving, stack);
|
||||
if (world.getBlockMetadata(x, y, z) == 0)
|
||||
onBlockPlacedElsewhere(world, x, y, z, entityliving);
|
||||
}
|
||||
|
||||
public void onBlockPlacedElsewhere (World world, int x, int y, int z, EntityLivingBase entityliving)
|
||||
{
|
||||
SmelteryLogic logic = (SmelteryLogic) world.getBlockTileEntity(x, y, z);
|
||||
logic.checkValidPlacement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock (World world, int x, int y, int z, int par5, int par6) //Don't drop inventory
|
||||
{
|
||||
world.removeBlockTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 12; iter++)
|
||||
{
|
||||
if (iter != 3)
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
/* Updating */
|
||||
public void onNeighborBlockChange (World world, int x, int y, int z, int nBlockID)
|
||||
{
|
||||
TileEntity logic = world.getBlockTileEntity(x, y, z);
|
||||
if (logic instanceof IServantLogic)
|
||||
{
|
||||
((IServantLogic) logic).notifyMasterOfChange();
|
||||
}
|
||||
else if (logic instanceof IMasterLogic)
|
||||
{
|
||||
((IMasterLogic) logic).notifyChange(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EnumCreatureAttribute;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SoilBlock extends TConstructBlock
|
||||
{
|
||||
static String[] soilTypes = new String[] { "slimesand", "grout", "slimesandblue", "graveyardsoil", "consecratedsoil" };
|
||||
|
||||
public SoilBlock(int id)
|
||||
{
|
||||
super(id, Material.ground, 3.0F, soilTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityWalking (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (entity instanceof EntityLiving)
|
||||
{
|
||||
EntityLiving living = ((EntityLiving) entity);
|
||||
if (living.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
if (metadata == 3)
|
||||
{
|
||||
living.heal(1);
|
||||
}
|
||||
else if (metadata == 4)
|
||||
{
|
||||
living.attackEntityFrom(DamageSource.magic, 1);
|
||||
living.setFire(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
if (world.getBlockMetadata(x, y, z) >= 3)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.875F, 1.0F);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.ColorizerGrass;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SoilSlab extends SlabBase
|
||||
{
|
||||
public SoilSlab(int id)
|
||||
{
|
||||
super(id, Material.ground);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
this.blockIcon = iconRegister.registerIcon("tinker:grass_top");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
switch (meta % 8)
|
||||
{
|
||||
case 0:
|
||||
return this.blockIcon;//Block.grass.getIcon(1, 0);
|
||||
case 1:
|
||||
return Block.dirt.getIcon(side, 0);
|
||||
case 2:
|
||||
return Block.mycelium.getIcon(1, 0);
|
||||
default:
|
||||
return TContent.craftedSoil.getIcon(side, meta - 3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 8; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getBlockColor ()
|
||||
{
|
||||
double d0 = 0.5D;
|
||||
double d1 = 1.0D;
|
||||
return ColorizerGrass.getGrassColor(d0, d1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderColor (int par1)
|
||||
{
|
||||
//if (par1 % 8 == 0)
|
||||
return this.getBlockColor();
|
||||
//return 0xFFFFFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int colorMultiplier (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
int l = 0;
|
||||
int i1 = 0;
|
||||
int j1 = 0;
|
||||
|
||||
for (int k1 = -1; k1 <= 1; ++k1)
|
||||
{
|
||||
for (int l1 = -1; l1 <= 1; ++l1)
|
||||
{
|
||||
int i2 = world.getBiomeGenForCoords(x + l1, z + k1).getBiomeGrassColor();
|
||||
l += (i2 & 16711680) >> 16;
|
||||
i1 += (i2 & 65280) >> 8;
|
||||
j1 += i2 & 255;
|
||||
}
|
||||
}
|
||||
return (l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SpeedBlock extends TConstructBlock
|
||||
{
|
||||
public static String[] textureNames = new String[] { "brownstone_rough", "brownstone_rough_road", "brownstone_smooth", "brownstone_smooth_brick", "brownstone_smooth_road",
|
||||
"brownstone_smooth_fancy", "brownstone_smooth_chiseled" };
|
||||
|
||||
public SpeedBlock(int id)
|
||||
{
|
||||
super(id, Material.rock, 3.0f, textureNames);
|
||||
//this.setBlockBounds(0f, 0f, 0f, 1.0f, 0.5f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityWalking (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
double boost = 2.2D;
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
if (metadata == 1 || metadata == 4)
|
||||
boost = 2.7D;
|
||||
|
||||
double mX = Math.abs(entity.motionX);
|
||||
double mZ = Math.abs(entity.motionZ);
|
||||
if (mX < 0.5D)
|
||||
{
|
||||
entity.motionX *= boost;
|
||||
}
|
||||
if (mZ < 0.5D)
|
||||
{
|
||||
entity.motionZ *= boost;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped (int meta)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < textureNames.length; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SpeedSlab extends SlabBase
|
||||
{
|
||||
public SpeedSlab(int id)
|
||||
{
|
||||
super(id, Material.rock);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
setHardness(3F);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
meta = meta % 8;
|
||||
return TContent.speedBlock.getIcon(side, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 7; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityWalking (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
double boost = 2.2D;
|
||||
int metadata = world.getBlockMetadata(x, y, z) % 8;
|
||||
if (metadata == 1 || metadata == 4)
|
||||
boost = 2.7D;
|
||||
|
||||
double mX = Math.abs(entity.motionX);
|
||||
double mZ = Math.abs(entity.motionZ);
|
||||
if (mX < 0.5D)
|
||||
{
|
||||
entity.motionX *= boost;
|
||||
}
|
||||
if (mZ < 0.5D)
|
||||
{
|
||||
entity.motionZ *= boost;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,308 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import static net.minecraftforge.common.ForgeDirection.EAST;
|
||||
import static net.minecraftforge.common.ForgeDirection.NORTH;
|
||||
import static net.minecraftforge.common.ForgeDirection.SOUTH;
|
||||
import static net.minecraftforge.common.ForgeDirection.WEST;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class StoneTorch extends Block
|
||||
{
|
||||
public StoneTorch(int id)
|
||||
{
|
||||
super(id, Material.circuits);
|
||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||
setLightValue(0.9375F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
|
||||
* cleared to be reused)
|
||||
*/
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
public int getRenderType ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if we can place a torch on a block.
|
||||
*/
|
||||
private boolean canPlaceTorchOn (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (par1World.doesBlockHaveSolidTopSurface(par2, par3, par4))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int l = par1World.getBlockId(par2, par3, par4);
|
||||
return (Block.blocksList[l] != null && Block.blocksList[l].canPlaceTorchOnTop(par1World, par2, par3, par4));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
|
||||
*/
|
||||
public boolean canPlaceBlockAt (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true) || par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true)
|
||||
|| par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true) || par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH, true)
|
||||
|| canPlaceTorchOn(par1World, par2, par3 - 1, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
|
||||
*/
|
||||
public int onBlockPlaced (World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
|
||||
{
|
||||
int j1 = par9;
|
||||
|
||||
if (par5 == 0)
|
||||
{
|
||||
if (this.canPlaceTorchOn(par1World, par2, par3 - 1, par4))
|
||||
{
|
||||
j1 = 5;
|
||||
}
|
||||
else if (par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH, true))
|
||||
{
|
||||
j1 = 4;
|
||||
}
|
||||
else if (par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true))
|
||||
{
|
||||
j1 = 3;
|
||||
}
|
||||
else if (par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true))
|
||||
{
|
||||
j1 = 2;
|
||||
}
|
||||
else if (par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true))
|
||||
{
|
||||
j1 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (par5 == 1 && this.canPlaceTorchOn(par1World, par2, par3 - 1, par4))
|
||||
{
|
||||
j1 = 5;
|
||||
}
|
||||
|
||||
if (par5 == 2 && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH, true))
|
||||
{
|
||||
j1 = 4;
|
||||
}
|
||||
|
||||
if (par5 == 3 && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true))
|
||||
{
|
||||
j1 = 3;
|
||||
}
|
||||
|
||||
if (par5 == 4 && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true))
|
||||
{
|
||||
j1 = 2;
|
||||
}
|
||||
|
||||
if (par5 == 5 && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true))
|
||||
{
|
||||
j1 = 1;
|
||||
}
|
||||
|
||||
return j1;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon("tinker:torch_stone");
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange (World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
this.func_94397_d(par1World, par2, par3, par4, par5);
|
||||
}
|
||||
|
||||
protected boolean func_94397_d (World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (this.dropTorchIfCantStay(par1World, par2, par3, par4))
|
||||
{
|
||||
int i1 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
boolean flag = false;
|
||||
|
||||
if (!par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true) && i1 == 1)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true) && i1 == 2)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true) && i1 == 3)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH, true) && i1 == 4)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!this.canPlaceTorchOn(par1World, par2, par3 - 1, par4) && i1 == 5)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the block can remain at its current location and will drop as an item if it is unable to stay. Returns
|
||||
* True if it can stay and False if it drops. Args: world, x, y, z
|
||||
*/
|
||||
protected boolean dropTorchIfCantStay (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (!this.canPlaceBlockAt(par1World, par2, par3, par4))
|
||||
{
|
||||
if (par1World.getBlockId(par2, par3, par4) == this.blockID)
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ray traces through the blocks collision from start vector to end vector returning a ray trace hit. Args: world,
|
||||
* x, y, z, startVec, endVec
|
||||
*/
|
||||
public MovingObjectPosition collisionRayTrace (World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
|
||||
{
|
||||
int l = par1World.getBlockMetadata(par2, par3, par4) & 7;
|
||||
float f = 0.15F;
|
||||
|
||||
if (l == 1)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f);
|
||||
}
|
||||
else if (l == 2)
|
||||
{
|
||||
this.setBlockBounds(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f);
|
||||
}
|
||||
else if (l == 3)
|
||||
{
|
||||
this.setBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F);
|
||||
}
|
||||
else if (l == 4)
|
||||
{
|
||||
this.setBlockBounds(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
f = 0.1F;
|
||||
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f);
|
||||
}
|
||||
|
||||
return super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
/**
|
||||
* A randomly called display update to be able to add particles or other items for display
|
||||
*/
|
||||
public void randomDisplayTick (World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
int meta = par1World.getBlockMetadata(par2, par3, par4);
|
||||
double d0 = (double) ((float) par2 + 0.5F);
|
||||
double d1 = (double) ((float) par3 + 0.7F);
|
||||
double d2 = (double) ((float) par4 + 0.5F);
|
||||
double d3 = 0.2199999988079071D;
|
||||
double d4 = 0.27000001072883606D;
|
||||
|
||||
if (meta == 1)
|
||||
{
|
||||
par1World.spawnParticle("smoke", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
||||
par1World.spawnParticle("flame", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if (meta == 2)
|
||||
{
|
||||
par1World.spawnParticle("smoke", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
||||
par1World.spawnParticle("flame", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if (meta == 3)
|
||||
{
|
||||
par1World.spawnParticle("smoke", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
|
||||
par1World.spawnParticle("flame", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if (meta == 4)
|
||||
{
|
||||
par1World.spawnParticle("smoke", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
par1World.spawnParticle("flame", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
||||
par1World.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TConstructBlock extends Block
|
||||
{
|
||||
public String[] textureNames;
|
||||
public Icon[] icons;
|
||||
|
||||
public TConstructBlock(int id, Material material, float hardness, String[] tex)
|
||||
{
|
||||
super(id, material);
|
||||
setHardness(hardness);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
textureNames = tex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped (int meta)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
this.icons = new Icon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < icons.length; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TMetalBlock extends TConstructBlock
|
||||
{
|
||||
|
||||
static String[] metalTypes = new String[] { "compressed_cobalt", "compressed_ardite", "compressed_manyullyn", "compressed_copper", "compressed_bronze", "compressed_tin", "compressed_aluminum",
|
||||
"compressed_alubrass", "compressed_alumite", "compressed_steel" };
|
||||
|
||||
public TMetalBlock(int id, Material material, float hardness)
|
||||
{
|
||||
super(id, material, hardness, metalTypes);
|
||||
this.setStepSound(Block.soundMetalFootstep);
|
||||
}
|
||||
|
||||
public boolean isBeaconBase (World worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.ToolForgeLogic;
|
||||
import tconstruct.client.block.TableForgeRender;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ToolForgeBlock extends InventoryBlock
|
||||
{
|
||||
public ToolForgeBlock(int id, Material material)
|
||||
{
|
||||
super(id, material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setHardness(2f);
|
||||
this.setStepSound(Block.soundWoodFootstep);
|
||||
}
|
||||
|
||||
//Block.hasComparatorInputOverride and Block.getComparatorInputOverride
|
||||
|
||||
String[] textureNames = { "toolforge_iron", "toolforge_gold", "toolforge_diamond", "toolforge_emerald", "toolforge_cobalt", "toolforge_ardite", "toolforge_manyullyn", "toolforge_copper",
|
||||
"toolforge_bronze", "toolforge_tin", "toolforge_aluminum", "toolforge_alubrass", "toolforge_alumite", "toolforge_steel" };
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
Icon textureTop;
|
||||
|
||||
@Override
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
super.registerIcons(iconRegister);
|
||||
textureTop = iconRegister.registerIcon("tinker:toolforge_top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
if (side == 1)
|
||||
{
|
||||
return textureTop;
|
||||
}
|
||||
if (side == 0)
|
||||
{
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return Block.blockIron.getIcon(side, 0);
|
||||
case 1:
|
||||
return Block.blockGold.getIcon(side, 0);
|
||||
case 2:
|
||||
return Block.blockDiamond.getIcon(side, 0);
|
||||
case 3:
|
||||
return Block.blockEmerald.getIcon(side, 0);
|
||||
default:
|
||||
return TContent.metalBlock.getIcon(side, meta - 4);
|
||||
}
|
||||
}
|
||||
|
||||
return this.icons[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return TableForgeRender.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
|
||||
return new ToolForgeLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
int md = world.getBlockMetadata(x, y, z);
|
||||
return TProxyCommon.toolForge;
|
||||
//return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < textureNames.length; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.PartCrafterLogic;
|
||||
import tconstruct.blocks.logic.PatternChestLogic;
|
||||
import tconstruct.blocks.logic.StencilTableLogic;
|
||||
import tconstruct.blocks.logic.ToolStationLogic;
|
||||
import tconstruct.client.block.TableRender;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
import tconstruct.util.PHConstruct;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ToolStationBlock extends InventoryBlock
|
||||
{
|
||||
public ToolStationBlock(int id, Material material)
|
||||
{
|
||||
super(id, material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setHardness(2f);
|
||||
this.setStepSound(Block.soundWoodFootstep);
|
||||
}
|
||||
|
||||
//Block.hasComparatorInputOverride and Block.getComparatorInputOverride
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "toolstation_top", "toolstation_side", "toolstation_bottom", "partbuilder_oak_top", "partbuilder_oak_side", "partbuilder_oak_bottom", "partbuilder_spruce_top",
|
||||
"partbuilder_spruce_side", "partbuilder_spruce_bottom", "partbuilder_birch_top", "partbuilder_birch_side", "partbuilder_birch_bottom", "partbuilder_jungle_top",
|
||||
"partbuilder_jungle_side", "partbuilder_jungle_bottom", "patternchest_top", "patternchest_side", "patternchest_bottom", "stenciltable_oak_top", "stenciltable_oak_side",
|
||||
"stenciltable_oak_bottom", "stenciltable_spruce_top", "stenciltable_spruce_side", "stenciltable_spruce_bottom", "stenciltable_birch_top", "stenciltable_birch_side",
|
||||
"stenciltable_birch_bottom", "stenciltable_jungle_top", "stenciltable_jungle_side", "stenciltable_jungle_bottom" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
if (meta <= 4)
|
||||
{
|
||||
return icons[meta * 3 + getTextureIndex(side)];
|
||||
}
|
||||
else if (meta <= 9)
|
||||
{
|
||||
return icons[15 + getTextureIndex(side)];
|
||||
}
|
||||
else
|
||||
{
|
||||
return icons[meta * 3 + getTextureIndex(side) - 12];
|
||||
}
|
||||
}
|
||||
|
||||
public int getTextureIndex (int side)
|
||||
{
|
||||
if (side == 0)
|
||||
return 2;
|
||||
if (side == 1)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return TableRender.tabelModelID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
if (metadata == 5)
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY - 0.125,
|
||||
(double) z + this.maxZ);
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY, (double) z + this.maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
return new ToolStationLogic();
|
||||
case 1:
|
||||
return new PartCrafterLogic();
|
||||
case 2:
|
||||
return new PartCrafterLogic();
|
||||
case 3:
|
||||
return new PartCrafterLogic();
|
||||
case 4:
|
||||
return new PartCrafterLogic();
|
||||
case 5:
|
||||
return new PatternChestLogic();
|
||||
case 6:
|
||||
return new PatternChestLogic();
|
||||
case 7:
|
||||
return new PatternChestLogic();
|
||||
case 8:
|
||||
return new PatternChestLogic();
|
||||
case 9:
|
||||
return new PatternChestLogic();
|
||||
case 10:
|
||||
return new StencilTableLogic();
|
||||
case 11:
|
||||
return new StencilTableLogic();
|
||||
case 12:
|
||||
return new StencilTableLogic();
|
||||
case 13:
|
||||
return new StencilTableLogic();
|
||||
/*case 14:
|
||||
return new CastingTableLogic();*/
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
int md = world.getBlockMetadata(x, y, z);
|
||||
if (md == 0)
|
||||
return 0;
|
||||
else if (md < 5)
|
||||
return 1;
|
||||
else if (md < 10)
|
||||
return 2;
|
||||
else
|
||||
return 3;
|
||||
|
||||
//return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 6; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
|
||||
for (int iter = 10; iter < 14; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack)
|
||||
{
|
||||
if (PHConstruct.freePatterns)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 5)
|
||||
{
|
||||
PatternChestLogic logic = (PatternChestLogic) world.getBlockTileEntity(x, y, z);
|
||||
for (int i = 1; i <= 13; i++)
|
||||
{
|
||||
logic.setInventorySlotContents(i - 1, new ItemStack(TContent.woodPattern, 1, i));
|
||||
}
|
||||
logic.setInventorySlotContents(13, new ItemStack(TContent.woodPattern, 1, 22));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
|
||||
public abstract class AggregatorLogic extends InventoryLogic
|
||||
{
|
||||
public AggregatorLogic(int invSize)
|
||||
{
|
||||
super(invSize);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class AqueductLogic extends TileEntity //implements ITankContainer
|
||||
{
|
||||
|
||||
/*@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (int tankIndex, FluidStack resource, boolean doFill)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (int tankIndex, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank[] getTanks (ForgeDirection direction)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank getTank (ForgeDirection direction, FluidStack type)
|
||||
{
|
||||
return null;
|
||||
}*/
|
||||
|
||||
}
|
||||
@@ -0,0 +1,429 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import tconstruct.library.crafting.CastingRecipe;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidEvent;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
public class CastingBasinLogic extends InventoryLogic implements IFluidTank, IFluidHandler, ISidedInventory
|
||||
{
|
||||
public FluidStack liquid;
|
||||
int castingDelay = 0;
|
||||
int renderOffset = 0;
|
||||
int capacity = 0;
|
||||
boolean needsUpdate;
|
||||
boolean init = true;
|
||||
int tick;
|
||||
|
||||
public CastingBasinLogic()
|
||||
{
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName () //Not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultName () //Still not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) //Definitely not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* Tank */
|
||||
|
||||
@Override
|
||||
public int getCapacity ()
|
||||
{
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
public int updateCapacity () //Only used to initialize
|
||||
{
|
||||
int ret = TConstruct.ingotLiquidValue;
|
||||
|
||||
ItemStack inv = inventory[0];
|
||||
|
||||
if (inv != null && inv.getItem() instanceof IPattern)
|
||||
{
|
||||
int cost = ((IPattern) inv.getItem()).getPatternCost(inv);
|
||||
if (cost > 0)
|
||||
ret *= ((IPattern) inv.getItem()).getPatternCost(inv) * 0.5;
|
||||
else
|
||||
ret = TConstruct.basinCasting.getCastingAmount(this.liquid, inv);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
ret = TConstruct.basinCasting.getCastingAmount(this.liquid, inv);
|
||||
}
|
||||
|
||||
System.out.println("Ret: " + ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int updateCapacity (int capacity)
|
||||
{
|
||||
int ret = TConstruct.ingotLiquidValue;
|
||||
|
||||
ItemStack inv = inventory[0];
|
||||
|
||||
if (inv != null && inv.getItem() instanceof IPattern)
|
||||
{
|
||||
int cost = ((IPattern) inv.getItem()).getPatternCost(inv);
|
||||
if (cost > 0)
|
||||
ret *= ((IPattern) inv.getItem()).getPatternCost(inv) * 0.5;
|
||||
else
|
||||
ret = capacity;
|
||||
}
|
||||
|
||||
else
|
||||
ret = capacity;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (resource == null)
|
||||
return 0;
|
||||
|
||||
if (this.liquid == null)
|
||||
{
|
||||
CastingRecipe recipe = TConstruct.basinCasting.getCastingRecipe(resource, inventory[0]);
|
||||
if (recipe == null)
|
||||
return 0;
|
||||
this.capacity = updateCapacity(recipe.castingMetal.amount);
|
||||
|
||||
if (inventory[1] == null)
|
||||
{
|
||||
FluidStack copyLiquid = resource.copy();
|
||||
|
||||
if (copyLiquid.amount > this.capacity)
|
||||
{
|
||||
copyLiquid.amount = this.capacity;
|
||||
}
|
||||
|
||||
if (doFill)
|
||||
{
|
||||
if (copyLiquid.amount == this.capacity)
|
||||
{
|
||||
castingDelay = recipe.coolTime;
|
||||
}
|
||||
renderOffset = copyLiquid.amount;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
this.liquid = copyLiquid;
|
||||
needsUpdate = true;
|
||||
}
|
||||
return copyLiquid.amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
else if (resource.isFluidEqual(this.liquid))
|
||||
{
|
||||
if (resource.amount + this.liquid.amount >= this.capacity) //Start timer here
|
||||
{
|
||||
int roomInTank = this.capacity - liquid.amount;
|
||||
if (doFill && roomInTank > 0)
|
||||
{
|
||||
renderOffset = roomInTank;
|
||||
castingDelay = TConstruct.basinCasting.getCastingDelay(this.liquid, inventory[0]);
|
||||
this.liquid.amount = this.capacity;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
return roomInTank;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (doFill)
|
||||
{
|
||||
this.liquid.amount += resource.amount;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
return resource.amount;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryChanged () //Isn't actually called?
|
||||
{
|
||||
super.onInventoryChanged();
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
ItemStack stack = super.decrStackSize(slot, quantity);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (liquid == null || liquid.fluidID <= 0 || castingDelay > 0)
|
||||
return null;
|
||||
if (liquid.amount <= 0)
|
||||
return null;
|
||||
|
||||
int used = maxDrain;
|
||||
if (liquid.amount < used)
|
||||
used = liquid.amount;
|
||||
|
||||
if (doDrain)
|
||||
{
|
||||
liquid.amount -= used;
|
||||
}
|
||||
|
||||
FluidStack drained = liquid.copy();//new FluidStack(liquid.itemID, used, liquid.itemMeta);
|
||||
drained.amount = used;
|
||||
|
||||
// Reset liquid if emptied
|
||||
if (liquid.amount <= 0)
|
||||
liquid = null;
|
||||
|
||||
if (doDrain)
|
||||
FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(drained, this.worldObj, this.xCoord, this.yCoord, this.zCoord, this));
|
||||
|
||||
return drained;
|
||||
}
|
||||
|
||||
/* Tank Container */
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
//if (from == ForgeDirection.UP)
|
||||
return fill(resource, doFill);
|
||||
//return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo (ForgeDirection from)
|
||||
{
|
||||
return new FluidTankInfo[] {getInfo()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluid ()
|
||||
{
|
||||
return liquid.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidAmount ()
|
||||
{
|
||||
return liquid != null ? liquid.amount : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo getInfo ()
|
||||
{
|
||||
FluidTankInfo info = new FluidTankInfo(this);
|
||||
return info;
|
||||
}
|
||||
|
||||
public int getLiquidAmount ()
|
||||
{
|
||||
return liquid.amount - renderOffset;
|
||||
}
|
||||
|
||||
/* Updating */
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (castingDelay > 0)
|
||||
{
|
||||
//System.out.println("Casting");
|
||||
castingDelay--;
|
||||
if (castingDelay == 0)
|
||||
castLiquid();
|
||||
}
|
||||
if (renderOffset > 0)
|
||||
{
|
||||
renderOffset -= 6;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
tick++;
|
||||
if (tick % 20 == 0)
|
||||
{
|
||||
tick = 0;
|
||||
if (needsUpdate)
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public void castLiquid ()
|
||||
{
|
||||
CastingRecipe recipe = TConstruct.basinCasting.getCastingRecipe(liquid, inventory[0]);
|
||||
if (recipe != null)
|
||||
{
|
||||
inventory[1] = recipe.getResult();
|
||||
if (recipe.consumeCast)
|
||||
inventory[0] = null;
|
||||
liquid = null;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
if (tags.getBoolean("hasLiquid"))
|
||||
{
|
||||
this.liquid = FluidStack.loadFluidStackFromNBT(tags.getCompoundTag("Fluid"));
|
||||
}
|
||||
//FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbt);
|
||||
//this.liquid = new FluidStack(tags.getInteger("itemID"), tags.getInteger("amount"), tags.getInteger("itemMeta"));
|
||||
else
|
||||
this.liquid = null;
|
||||
|
||||
if (tags.getBoolean("Initialized"))
|
||||
this.capacity = tags.getInteger("Capacity");
|
||||
else
|
||||
this.capacity = updateCapacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setBoolean("hasLiquid", liquid != null);
|
||||
if (liquid != null)
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
liquid.writeToNBT(nbt);
|
||||
tags.setCompoundTag("Fluid", nbt);
|
||||
}
|
||||
tags.setBoolean("Initialized", init);
|
||||
tags.setInteger("Capacity", capacity);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readFromNBT(packet.customParam1);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
return new int[] { 0, 1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int slot, ItemStack itemstack, int side)
|
||||
{
|
||||
if (liquid != null)
|
||||
return false;
|
||||
|
||||
if (slot == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int slot, ItemStack itemstack, int side)
|
||||
{
|
||||
if (slot == 1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,429 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import tconstruct.library.crafting.CastingRecipe;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidEvent;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
public class CastingTableLogic extends InventoryLogic implements IFluidTank, IFluidHandler, ISidedInventory
|
||||
{
|
||||
public FluidStack liquid;
|
||||
int castingDelay = 0;
|
||||
int renderOffset = 0;
|
||||
int capacity = 0;
|
||||
boolean needsUpdate;
|
||||
boolean init = true;
|
||||
int tick;
|
||||
|
||||
public CastingTableLogic()
|
||||
{
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName () //Not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultName () //Still not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) //Definitely not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* Tank */
|
||||
|
||||
@Override
|
||||
public int getCapacity ()
|
||||
{
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
public int updateCapacity () //Only used to initialize
|
||||
{
|
||||
int ret = TConstruct.ingotLiquidValue;
|
||||
|
||||
ItemStack inv = inventory[0];
|
||||
|
||||
if (inv != null && inv.getItem() instanceof IPattern)
|
||||
{
|
||||
int cost = ((IPattern) inv.getItem()).getPatternCost(inv);
|
||||
if (cost > 0)
|
||||
ret *= ((IPattern) inv.getItem()).getPatternCost(inv) * 0.5;
|
||||
else
|
||||
ret = TConstruct.tableCasting.getCastingAmount(this.liquid, inv);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
ret = TConstruct.tableCasting.getCastingAmount(this.liquid, inv);
|
||||
}
|
||||
|
||||
System.out.println("Ret: " + ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int updateCapacity (int capacity)
|
||||
{
|
||||
int ret = TConstruct.ingotLiquidValue;
|
||||
|
||||
ItemStack inv = inventory[0];
|
||||
|
||||
if (inv != null && inv.getItem() instanceof IPattern)
|
||||
{
|
||||
int cost = ((IPattern) inv.getItem()).getPatternCost(inv);
|
||||
if (cost > 0)
|
||||
ret *= ((IPattern) inv.getItem()).getPatternCost(inv) * 0.5;
|
||||
else
|
||||
ret = capacity;
|
||||
}
|
||||
|
||||
else
|
||||
ret = capacity;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (resource == null)
|
||||
return 0;
|
||||
|
||||
if (this.liquid == null)
|
||||
{
|
||||
CastingRecipe recipe = TConstruct.tableCasting.getCastingRecipe(resource, inventory[0]);
|
||||
if (recipe == null)
|
||||
return 0;
|
||||
this.capacity = updateCapacity(recipe.castingMetal.amount);
|
||||
|
||||
if (inventory[1] == null)
|
||||
{
|
||||
FluidStack copyLiquid = resource.copy();
|
||||
|
||||
if (copyLiquid.amount > this.capacity)
|
||||
{
|
||||
copyLiquid.amount = this.capacity;
|
||||
}
|
||||
|
||||
if (doFill)
|
||||
{
|
||||
if (copyLiquid.amount == this.capacity)
|
||||
{
|
||||
castingDelay = recipe.coolTime;
|
||||
}
|
||||
renderOffset = copyLiquid.amount;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
this.liquid = copyLiquid;
|
||||
needsUpdate = true;
|
||||
}
|
||||
return copyLiquid.amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
else if (resource.isFluidEqual(this.liquid))
|
||||
{
|
||||
if (resource.amount + this.liquid.amount >= this.capacity) //Start timer here
|
||||
{
|
||||
int roomInTank = this.capacity - liquid.amount;
|
||||
if (doFill && roomInTank > 0)
|
||||
{
|
||||
renderOffset = roomInTank;
|
||||
castingDelay = TConstruct.tableCasting.getCastingDelay(this.liquid, inventory[0]);
|
||||
this.liquid.amount = this.capacity;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
return roomInTank;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (doFill)
|
||||
{
|
||||
this.liquid.amount += resource.amount;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
return resource.amount;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryChanged () //Isn't actually called?
|
||||
{
|
||||
super.onInventoryChanged();
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
ItemStack stack = super.decrStackSize(slot, quantity);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (liquid == null || liquid.fluidID <= 0 || castingDelay > 0)
|
||||
return null;
|
||||
if (liquid.amount <= 0)
|
||||
return null;
|
||||
|
||||
int used = maxDrain;
|
||||
if (liquid.amount < used)
|
||||
used = liquid.amount;
|
||||
|
||||
if (doDrain)
|
||||
{
|
||||
liquid.amount -= used;
|
||||
}
|
||||
|
||||
FluidStack drained = liquid.copy();//new FluidStack(liquid.itemID, used, liquid.itemMeta);
|
||||
drained.amount = used;
|
||||
|
||||
// Reset liquid if emptied
|
||||
if (liquid.amount <= 0)
|
||||
liquid = null;
|
||||
|
||||
if (doDrain)
|
||||
FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(drained, this.worldObj, this.xCoord, this.yCoord, this.zCoord, this));
|
||||
|
||||
return drained;
|
||||
}
|
||||
|
||||
/* Tank Container */
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
//if (from == ForgeDirection.UP)
|
||||
return fill(resource, doFill);
|
||||
//return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo (ForgeDirection from)
|
||||
{
|
||||
return new FluidTankInfo[] {getInfo()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluid ()
|
||||
{
|
||||
return liquid.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidAmount ()
|
||||
{
|
||||
return liquid != null ? liquid.amount : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo getInfo ()
|
||||
{
|
||||
FluidTankInfo info = new FluidTankInfo(this);
|
||||
return info;
|
||||
}
|
||||
|
||||
public int getLiquidAmount ()
|
||||
{
|
||||
return liquid.amount - renderOffset;
|
||||
}
|
||||
|
||||
/* Updating */
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (castingDelay > 0)
|
||||
{
|
||||
//System.out.println("Casting");
|
||||
castingDelay--;
|
||||
if (castingDelay == 0)
|
||||
castLiquid();
|
||||
}
|
||||
if (renderOffset > 0)
|
||||
{
|
||||
renderOffset -= 6;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
tick++;
|
||||
if (tick % 20 == 0)
|
||||
{
|
||||
tick = 0;
|
||||
if (needsUpdate)
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public void castLiquid ()
|
||||
{
|
||||
CastingRecipe recipe = TConstruct.tableCasting.getCastingRecipe(liquid, inventory[0]);
|
||||
if (recipe != null)
|
||||
{
|
||||
inventory[1] = recipe.getResult();
|
||||
if (recipe.consumeCast)
|
||||
inventory[0] = null;
|
||||
liquid = null;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
if (tags.getBoolean("hasLiquid"))
|
||||
{
|
||||
this.liquid = FluidStack.loadFluidStackFromNBT(tags.getCompoundTag("Fluid"));
|
||||
}
|
||||
//FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbt);
|
||||
//this.liquid = new FluidStack(tags.getInteger("itemID"), tags.getInteger("amount"), tags.getInteger("itemMeta"));
|
||||
else
|
||||
this.liquid = null;
|
||||
|
||||
if (tags.getBoolean("Initialized"))
|
||||
this.capacity = tags.getInteger("Capacity");
|
||||
else
|
||||
this.capacity = updateCapacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setBoolean("hasLiquid", liquid != null);
|
||||
if (liquid != null)
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
liquid.writeToNBT(nbt);
|
||||
tags.setCompoundTag("Fluid", nbt);
|
||||
}
|
||||
tags.setBoolean("Initialized", init);
|
||||
tags.setInteger("Capacity", capacity);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readFromNBT(packet.customParam1);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
return new int[] { 0, 1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int slot, ItemStack itemstack, int side)
|
||||
{
|
||||
if (liquid != null)
|
||||
return false;
|
||||
|
||||
if (slot == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int slot, ItemStack itemstack, int side)
|
||||
{
|
||||
if (slot == 1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,358 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.inventory.DrawbridgeContainer;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import tconstruct.library.util.IActiveLogic;
|
||||
import tconstruct.library.util.IFacingLogic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class DrawbridgeLogic extends InventoryLogic implements IFacingLogic, IActiveLogic
|
||||
{
|
||||
boolean active;
|
||||
boolean working;
|
||||
int ticks;
|
||||
byte extension;
|
||||
byte direction;
|
||||
|
||||
public DrawbridgeLogic()
|
||||
{
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive ()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive (boolean flag)
|
||||
{
|
||||
active = flag;
|
||||
working = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getRenderDirection ()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getForgeDirection ()
|
||||
{
|
||||
return ForgeDirection.VALID_DIRECTIONS[direction];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (int side)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (float yaw, float pitch, EntityLivingBase player)
|
||||
{
|
||||
if (pitch > 45)
|
||||
{
|
||||
direction = 1;
|
||||
}
|
||||
else if (pitch < -45)
|
||||
{
|
||||
direction = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3;
|
||||
switch (facing)
|
||||
{
|
||||
case 0:
|
||||
direction = 2;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
direction = 5;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
direction = 3;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
direction = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new DrawbridgeContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultName ()
|
||||
{
|
||||
return "tinker.drawbridge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
super.setInventorySlotContents(slot, itemstack);
|
||||
if (slot == 1)
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
ItemStack stack = super.decrStackSize(slot, quantity);
|
||||
if (slot == 1)
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
return stack;
|
||||
}
|
||||
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (working)
|
||||
{
|
||||
ticks++;
|
||||
if (ticks == 5)
|
||||
{
|
||||
ticks = 0;
|
||||
if (active) //Placement
|
||||
{
|
||||
if (inventory[0] != null && inventory[0].stackSize > 1 && extension < 15)
|
||||
{
|
||||
extension++;
|
||||
int xPos = xCoord;
|
||||
int yPos = yCoord;
|
||||
int zPos = zCoord;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case 0:
|
||||
yPos -= extension;
|
||||
break;
|
||||
case 1:
|
||||
yPos += extension;
|
||||
break;
|
||||
case 2:
|
||||
zPos -= extension;
|
||||
break;
|
||||
case 3:
|
||||
zPos += extension;
|
||||
break;
|
||||
case 4:
|
||||
xPos -= extension;
|
||||
break;
|
||||
case 5:
|
||||
xPos += extension;
|
||||
break;
|
||||
}
|
||||
|
||||
Block block = Block.blocksList[worldObj.getBlockId(xPos, yPos, zPos)];
|
||||
if (block == null || block.isAirBlock(worldObj, xPos, yPos, zPos) || block.isBlockReplaceable(worldObj, xPos, yPos, zPos))
|
||||
{
|
||||
//tryExtend(worldObj, xPos, yPos, zPos, direction);
|
||||
int blockToItem = TConstructRegistry.blockToItemMapping[inventory[0].itemID];
|
||||
if (blockToItem == 0)
|
||||
{
|
||||
if (inventory[0].itemID >= 4096 || Block.blocksList[inventory[0].itemID] == null)
|
||||
return;
|
||||
|
||||
worldObj.setBlock(xPos, yPos, zPos, inventory[0].itemID, inventory[0].getItemDamage(), 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
worldObj.setBlock(xPos, yPos, zPos, blockToItem, inventory[0].getItemDamage(), 3);
|
||||
}
|
||||
worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "tile.piston.out", 0.25F, worldObj.rand.nextFloat() * 0.25F + 0.6F);
|
||||
inventory[0].stackSize--;
|
||||
}
|
||||
else
|
||||
{
|
||||
extension--;
|
||||
working = false;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
working = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
//Retraction
|
||||
{
|
||||
if ((inventory[0] == null || inventory[0].stackSize < inventory[0].getMaxStackSize()) && extension > 0)
|
||||
{
|
||||
int xPos = xCoord;
|
||||
int yPos = yCoord;
|
||||
int zPos = zCoord;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case 0:
|
||||
yPos -= extension;
|
||||
break;
|
||||
case 1:
|
||||
yPos += extension;
|
||||
break;
|
||||
case 2:
|
||||
zPos -= extension;
|
||||
break;
|
||||
case 3:
|
||||
zPos += extension;
|
||||
break;
|
||||
case 4:
|
||||
xPos -= extension;
|
||||
break;
|
||||
case 5:
|
||||
xPos += extension;
|
||||
break;
|
||||
}
|
||||
|
||||
Block block = Block.blocksList[worldObj.getBlockId(xPos, yPos, zPos)];
|
||||
if (block != null)
|
||||
{
|
||||
int meta = worldObj.getBlockMetadata(xPos, yPos, zPos);
|
||||
if (inventory[0] != null && validBlock(block) && validMetadata(block.blockID, meta))
|
||||
{
|
||||
worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "tile.piston.in", 0.25F, worldObj.rand.nextFloat() * 0.15F + 0.6F);
|
||||
worldObj.setBlock(xPos, yPos, zPos, 0);
|
||||
inventory[0].stackSize++;
|
||||
}
|
||||
else
|
||||
{
|
||||
working = false;
|
||||
}
|
||||
}
|
||||
extension--;
|
||||
}
|
||||
else
|
||||
{
|
||||
working = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean validBlock (Block block)
|
||||
{
|
||||
int type = TConstructRegistry.interchangableBlockMapping[block.blockID];
|
||||
if (type != 0)
|
||||
{
|
||||
if (type == inventory[0].itemID)
|
||||
return true;
|
||||
}
|
||||
int blockToItem = TConstructRegistry.blockToItemMapping[block.blockID];
|
||||
if (blockToItem != 0)
|
||||
{
|
||||
if (blockToItem == inventory[0].itemID)
|
||||
return true;
|
||||
}
|
||||
return block.blockID == inventory[0].itemID;
|
||||
}
|
||||
|
||||
boolean validMetadata (int blockID, int metadata)
|
||||
{
|
||||
int type = TConstructRegistry.drawbridgeState[blockID];
|
||||
if (type == 0)
|
||||
{
|
||||
return metadata == inventory[0].getItemDamage();
|
||||
}
|
||||
if (type == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (type == 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (type == 3)
|
||||
{
|
||||
return true; //TODO: rotational metadata
|
||||
}
|
||||
if (type == 4)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (type == 5)
|
||||
{
|
||||
return metadata == inventory[0].getItemDamage();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
active = tags.getBoolean("Active");
|
||||
working = tags.getBoolean("Working");
|
||||
extension = tags.getByte("Extension");
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
tags.setBoolean("Active", active);
|
||||
tags.setBoolean("Working", working);
|
||||
tags.setByte("Extension", extension);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
direction = tags.getByte("Direction");
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setByte("Direction", direction);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readFromNBT(packet.customParam1);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public boolean hasExtended ()
|
||||
{
|
||||
return extension != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryChanged() {
|
||||
super.onInventoryChanged();
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import tconstruct.library.crafting.DryingRackRecipes;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class DryingRackLogic extends InventoryLogic
|
||||
{
|
||||
int currentTime;
|
||||
int maxTime;
|
||||
|
||||
public DryingRackLogic()
|
||||
{
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultName ()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (maxTime > 0 && currentTime < maxTime)
|
||||
{
|
||||
currentTime++;
|
||||
if (currentTime >= maxTime)
|
||||
{
|
||||
inventory[0] = DryingRackRecipes.getDryingResult(inventory[0]);
|
||||
updateDryingTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
super.setInventorySlotContents(slot, itemstack);
|
||||
updateDryingTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
ItemStack stack = super.decrStackSize(slot, quantity);
|
||||
maxTime = 0;
|
||||
currentTime = 0;
|
||||
return stack;
|
||||
}
|
||||
|
||||
public void updateDryingTime ()
|
||||
{
|
||||
currentTime = 0;
|
||||
if (inventory[0] != null)
|
||||
maxTime = DryingRackRecipes.getDryingTime(inventory[0]);
|
||||
else
|
||||
maxTime = 0;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setInteger("Time", currentTime);
|
||||
tags.setInteger("MaxTime", maxTime);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
currentTime = tags.getInteger("Time");
|
||||
maxTime = tags.getInteger("MaxTime");
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readCustomNBT(packet.customParam1);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox ()
|
||||
{
|
||||
AxisAlignedBB cbb = AxisAlignedBB.getAABBPool().getAABB(xCoord, yCoord - 1, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
|
||||
return cbb;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/* Slots
|
||||
* 0: Frying pan item
|
||||
* 1: Fuel
|
||||
* 2-9: Food
|
||||
*/
|
||||
|
||||
public abstract class EquipLogic extends InventoryLogic
|
||||
{
|
||||
|
||||
public EquipLogic(int invSize)
|
||||
{
|
||||
super(invSize);
|
||||
}
|
||||
|
||||
public void setEquipmentItem (ItemStack stack)
|
||||
{
|
||||
inventory[0] = stack.copy();
|
||||
}
|
||||
|
||||
public boolean hasEquipmentItem ()
|
||||
{
|
||||
return inventory[0] != null;
|
||||
}
|
||||
|
||||
public ItemStack getEquipmentItem ()
|
||||
{
|
||||
return inventory[0];
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public ItemStack getStackInSlot(int slot)
|
||||
{
|
||||
return inventory[slot +1];
|
||||
}
|
||||
|
||||
public boolean isStackInSlot(int slot)
|
||||
{
|
||||
return inventory[slot +1] != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return inventory.length - 1;
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.util.IActiveLogic;
|
||||
import tconstruct.library.util.IFacingLogic;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class FaucetLogic extends TileEntity implements IFacingLogic, IActiveLogic, IFluidHandler
|
||||
{
|
||||
byte direction;
|
||||
boolean active;
|
||||
public FluidStack liquid;
|
||||
|
||||
public boolean activateFaucet ()
|
||||
{
|
||||
if (liquid == null && active)
|
||||
{
|
||||
int x = xCoord, z = zCoord;
|
||||
switch (getRenderDirection())
|
||||
{
|
||||
case 2:
|
||||
z++;
|
||||
break;
|
||||
case 3:
|
||||
z--;
|
||||
break;
|
||||
case 4:
|
||||
x++;
|
||||
break;
|
||||
case 5:
|
||||
x--;
|
||||
break;
|
||||
}
|
||||
|
||||
TileEntity drainte = worldObj.getBlockTileEntity(x, yCoord, z);
|
||||
TileEntity tankte = worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord);
|
||||
|
||||
if (drainte != null && drainte instanceof IFluidHandler && tankte != null && tankte instanceof IFluidHandler)
|
||||
{
|
||||
FluidStack templiquid = ((IFluidHandler) drainte).drain(getForgeDirection(), TConstruct.ingotLiquidValue, false);
|
||||
if (templiquid != null)
|
||||
{
|
||||
int drained = ((IFluidHandler) tankte).fill(ForgeDirection.UP, templiquid, false);
|
||||
if (drained > 0)
|
||||
{
|
||||
liquid = ((IFluidHandler) drainte).drain(getForgeDirection(), drained, true);
|
||||
((IFluidHandler) tankte).fill(ForgeDirection.UP, liquid, true);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (liquid != null)
|
||||
{
|
||||
liquid.amount -= TConstruct.liquidUpdateAmount;
|
||||
if (liquid.amount <= 0)
|
||||
{
|
||||
liquid = null;
|
||||
if (!activateFaucet())
|
||||
{
|
||||
active = false;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getRenderDirection ()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getForgeDirection ()
|
||||
{
|
||||
return ForgeDirection.VALID_DIRECTIONS[direction];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (int side)
|
||||
{
|
||||
//direction = (byte) side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (float yaw, float pitch, EntityLivingBase player)
|
||||
{
|
||||
int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3;
|
||||
switch (facing)
|
||||
{
|
||||
case 0:
|
||||
direction = 2;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
direction = 5;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
direction = 3;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
direction = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
direction = tags.getByte("Direction");
|
||||
if (tags.getBoolean("hasLiquid"))
|
||||
{
|
||||
this.liquid = FluidStack.loadFluidStackFromNBT(tags.getCompoundTag("Fluid"));
|
||||
}
|
||||
else
|
||||
this.liquid = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setByte("Direction", direction);
|
||||
tags.setBoolean("hasLiquid", liquid != null);
|
||||
if (liquid != null)
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
liquid.writeToNBT(nbt);
|
||||
tags.setCompoundTag("Fluid", nbt);
|
||||
}
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readCustomNBT(packet.customParam1);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive ()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive (boolean flag)
|
||||
{
|
||||
if (!active)
|
||||
{
|
||||
active = true;
|
||||
activateFaucet();
|
||||
}
|
||||
else
|
||||
{
|
||||
active = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo (ForgeDirection from)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.util.IActiveLogic;
|
||||
import tconstruct.library.util.IFacingLogic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class FirestarterLogic extends TileEntity implements IFacingLogic, IActiveLogic
|
||||
{
|
||||
boolean active;
|
||||
//boolean putOut;
|
||||
boolean shouldActivate;
|
||||
byte direction;
|
||||
|
||||
@Override
|
||||
public boolean getActive ()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive (boolean flag)
|
||||
{
|
||||
/*if (active && !flag)
|
||||
{
|
||||
putOut = true;
|
||||
}*/
|
||||
|
||||
active = flag;
|
||||
shouldActivate = true;
|
||||
//setFire();
|
||||
}
|
||||
|
||||
void setFire ()
|
||||
{
|
||||
int xPos = xCoord;
|
||||
int yPos = yCoord;
|
||||
int zPos = zCoord;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case 0:
|
||||
yPos -= 1;
|
||||
break;
|
||||
case 1:
|
||||
yPos += 1;
|
||||
break;
|
||||
case 2:
|
||||
zPos -= 1;
|
||||
break;
|
||||
case 3:
|
||||
zPos += 1;
|
||||
break;
|
||||
case 4:
|
||||
xPos -= 1;
|
||||
break;
|
||||
case 5:
|
||||
xPos += 1;
|
||||
break;
|
||||
}
|
||||
|
||||
Block block = Block.blocksList[worldObj.getBlockId(xPos, yPos, zPos)];
|
||||
if (active)
|
||||
{
|
||||
System.out.println("Setting fire");
|
||||
if (block == null || block.isAirBlock(worldObj, xPos, yPos, zPos))
|
||||
{
|
||||
worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "fire.ignite", 1.0F, AbilityHelper.random.nextFloat() * 0.4F + 0.8F);
|
||||
worldObj.setBlock(xPos, yPos, zPos, Block.fire.blockID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//System.out.println("Stopping fire "+putOut);
|
||||
if (block == Block.fire)
|
||||
{
|
||||
//worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "random.fizz", 1.0F, AbilityHelper.random.nextFloat() * 0.4F + 0.8F);
|
||||
worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "fire.ignite", 1.0F, AbilityHelper.random.nextFloat() * 0.4F + 0.8F);
|
||||
worldObj.setBlock(xPos, yPos, zPos, 0, 0, 3);
|
||||
//putOut = false;
|
||||
shouldActivate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (shouldActivate)
|
||||
{
|
||||
shouldActivate = false;
|
||||
setFire();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getRenderDirection ()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getForgeDirection ()
|
||||
{
|
||||
return ForgeDirection.VALID_DIRECTIONS[direction];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (int side)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (float yaw, float pitch, EntityLivingBase player)
|
||||
{
|
||||
if (pitch > 45)
|
||||
{
|
||||
direction = 1;
|
||||
}
|
||||
else if (pitch < -45)
|
||||
{
|
||||
direction = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3;
|
||||
switch (facing)
|
||||
{
|
||||
case 0:
|
||||
direction = 2;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
direction = 5;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
direction = 3;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
direction = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
tags.setBoolean("Active", active);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
active = tags.getBoolean("Active");
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
direction = tags.getByte("Direction");
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setByte("Direction", direction);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readCustomNBT(packet.customParam1);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.inventory.FrypanContainer;
|
||||
import tconstruct.library.util.IActiveLogic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.item.ItemTool;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
/* Slots
|
||||
* 0: Frying pan item
|
||||
* 1: Fuel
|
||||
* 2-9: Food
|
||||
*/
|
||||
|
||||
public class FrypanLogic extends EquipLogic implements IActiveLogic
|
||||
{
|
||||
boolean active;
|
||||
public int fuel;
|
||||
public int fuelGague;
|
||||
public int progress;
|
||||
|
||||
public FrypanLogic()
|
||||
{
|
||||
super(10);
|
||||
active = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "crafters.frypan";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive ()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive (boolean flag)
|
||||
{
|
||||
active = flag;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/* Fuel gauge */
|
||||
public int gaugeProgressScaled (int scale)
|
||||
{
|
||||
return (progress * scale) / 1000;
|
||||
}
|
||||
|
||||
public int gaugeFuelScaled (int scale)
|
||||
{
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
fuelGague = fuel;
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
fuelGague = 1000;
|
||||
}
|
||||
}
|
||||
return (fuel * scale) / fuelGague;
|
||||
}
|
||||
|
||||
/* Item cooking */
|
||||
public void updateEntity ()
|
||||
{
|
||||
boolean burning = isBurning();
|
||||
boolean updateInventory = false;
|
||||
if (fuel <= 0 && canCook())
|
||||
{
|
||||
fuel = fuelGague = (int) (getItemBurnTime(inventory[1]) * 2.5);
|
||||
if (fuel > 0)
|
||||
{
|
||||
if (inventory[1].getItem().hasContainerItem()) //Fuel slot
|
||||
{
|
||||
inventory[1] = new ItemStack(inventory[1].getItem().getContainerItem());
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory[1].stackSize--;
|
||||
}
|
||||
if (inventory[1].stackSize <= 0)
|
||||
{
|
||||
inventory[1] = null;
|
||||
}
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
if (isBurning() && canCook())
|
||||
{
|
||||
progress++;
|
||||
if (progress >= 1000)
|
||||
{
|
||||
progress = 0;
|
||||
cookItems();
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
progress = 0;
|
||||
}
|
||||
if (fuel > 0)
|
||||
{
|
||||
fuel--;
|
||||
}
|
||||
if (burning != isBurning())
|
||||
{
|
||||
setActive(isBurning());
|
||||
updateInventory = true;
|
||||
}
|
||||
if (updateInventory)
|
||||
{
|
||||
onInventoryChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void cookItems ()
|
||||
{
|
||||
if (!canCook())
|
||||
return;
|
||||
|
||||
for (int id = 2; id < 10; id++) //Check every slot
|
||||
{
|
||||
if (canCook())
|
||||
{
|
||||
ItemStack result = getResultFor(inventory[id]);
|
||||
if (result != null)
|
||||
{
|
||||
int ids = 2;
|
||||
boolean placed = false;
|
||||
while (ids < 10 && !placed) //Try to merge stacks first
|
||||
{
|
||||
if (inventory[ids] != null && inventory[ids].isItemEqual(result) && inventory[ids].stackSize < inventory[ids].getMaxStackSize())
|
||||
{
|
||||
if (inventory[ids].stackSize + result.stackSize <= inventory[ids].getMaxStackSize())
|
||||
{
|
||||
inventory[ids].stackSize += result.stackSize;
|
||||
placed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int decrement = inventory[ids].getMaxStackSize() - inventory[ids].stackSize;
|
||||
inventory[ids].stackSize = inventory[ids].getMaxStackSize();
|
||||
result.stackSize -= decrement;
|
||||
}
|
||||
}
|
||||
ids++;
|
||||
}
|
||||
|
||||
ids = 2;
|
||||
while (!placed && ids < 10) //Place remaining in slot
|
||||
{
|
||||
if (inventory[ids] == null)
|
||||
{
|
||||
inventory[ids] = result;
|
||||
placed = true;
|
||||
}
|
||||
ids++;
|
||||
}
|
||||
|
||||
if (placed)
|
||||
decrStackSize(id, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canCook ()
|
||||
{
|
||||
for (int id = 2; id < 10; id++)
|
||||
{
|
||||
if (inventory[id] == null) //Nothing here!
|
||||
continue;
|
||||
|
||||
ItemStack result = getResultFor(inventory[id]);
|
||||
if (result == null) //Doesn't cook into anything
|
||||
continue;
|
||||
|
||||
for (int slotid = 2; slotid < 10; slotid++)
|
||||
{
|
||||
if (inventory[slotid] == null)
|
||||
return true;
|
||||
|
||||
else if (inventory[slotid].isItemEqual(result) && inventory[slotid].stackSize + result.stackSize <= inventory[slotid].getMaxStackSize())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isBurning ()
|
||||
{
|
||||
return fuel > 0;
|
||||
}
|
||||
|
||||
public ItemStack getResultFor (ItemStack stack)
|
||||
{
|
||||
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
|
||||
if (result != null && result.getItem() instanceof ItemFood) //Only valid for food
|
||||
return result.copy();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getItemBurnTime (ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int itemID = stack.getItem().itemID;
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (stack.getItem() instanceof ItemBlock && Block.blocksList[itemID] != null)
|
||||
{
|
||||
Block block = Block.blocksList[itemID];
|
||||
|
||||
if (block == Block.woodSingleSlab)
|
||||
{
|
||||
return 150;
|
||||
}
|
||||
|
||||
if (block == Block.wood)
|
||||
{
|
||||
return 2400;
|
||||
}
|
||||
|
||||
if (block.blockMaterial == Material.wood)
|
||||
{
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item instanceof ItemHoe && ((ItemHoe) item).getMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (itemID == Item.stick.itemID)
|
||||
return 100;
|
||||
if (itemID == Item.coal.itemID)
|
||||
return 800;
|
||||
if (itemID == Item.bucketLava.itemID)
|
||||
return 20000;
|
||||
if (itemID == Block.sapling.blockID)
|
||||
return 100;
|
||||
if (itemID == Item.blazeRod.itemID)
|
||||
return 2400;
|
||||
return GameRegistry.getFuelValue(stack);
|
||||
}
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
active = tags.getBoolean("Active");
|
||||
fuel = tags.getInteger("Fuel");
|
||||
fuelGague = tags.getInteger("FuelGague");
|
||||
}
|
||||
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
tags.setBoolean("Active", active);
|
||||
tags.setInteger("Fuel", fuel);
|
||||
tags.setInteger("FuelGague", fuelGague);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new FrypanContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public boolean canDropInventorySlot(int slot)
|
||||
{
|
||||
if (slot == 0)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.crystal.TheftValueTracker;
|
||||
import tconstruct.inventory.AggregatorContainer;
|
||||
import tconstruct.library.util.IActiveLogic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GlowstoneAggregator extends AggregatorLogic implements IActiveLogic
|
||||
{
|
||||
short currentTime;
|
||||
short maxTime = 20 * 60 * 5;
|
||||
public int currentLightLevel;
|
||||
public boolean active;
|
||||
public byte crystalValue;
|
||||
|
||||
public GlowstoneAggregator()
|
||||
{
|
||||
super(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new AggregatorContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultName ()
|
||||
{
|
||||
return "aggregator.glowstone";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (worldObj.isRemote)
|
||||
return;
|
||||
|
||||
if (worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord) && crystalValue < 64)
|
||||
{
|
||||
Block block = Block.blocksList[worldObj.getBlockId(xCoord, yCoord + 1, zCoord)];
|
||||
if (block == null || validBlock(block) || block.isAirBlock(worldObj, xCoord, yCoord + 1, zCoord))
|
||||
{
|
||||
currentLightLevel = worldObj.getSavedLightValue(EnumSkyBlock.Sky, xCoord, yCoord, zCoord) - worldObj.skylightSubtracted;
|
||||
if (currentLightLevel > 12)
|
||||
{
|
||||
currentTime++;
|
||||
if (currentTime >= 180)
|
||||
{
|
||||
currentTime = 0;
|
||||
crystalValue++;
|
||||
if (block == TContent.lightCrystalBase)
|
||||
{
|
||||
int meta = worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord);
|
||||
if (crystalValue >= 64)
|
||||
{
|
||||
if (meta < 3)
|
||||
{
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord + 1, zCoord, 3, 3);
|
||||
TheftValueTracker.updateCrystallinity(worldObj.provider.dimensionId, xCoord, zCoord, 25); //Total 60
|
||||
}
|
||||
}
|
||||
else if (crystalValue >= 28)
|
||||
{
|
||||
if (meta < 2)
|
||||
{
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord + 1, zCoord, 2, 3);
|
||||
TheftValueTracker.updateCrystallinity(worldObj.provider.dimensionId, xCoord, zCoord, 15); //Total 35
|
||||
}
|
||||
}
|
||||
else if (crystalValue >= 8)
|
||||
{
|
||||
if (meta < 1)
|
||||
{
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord + 1, zCoord, 1, 3);
|
||||
TheftValueTracker.updateCrystallinity(worldObj.provider.dimensionId, xCoord, zCoord, 10); //Total 20
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
worldObj.setBlock(xCoord, yCoord + 1, zCoord, TContent.lightCrystalBase.blockID, 0, 3);
|
||||
TheftValueTracker.updateCrystallinity(worldObj.provider.dimensionId, xCoord, zCoord, 10); //Total 10
|
||||
}
|
||||
}
|
||||
if (active == false)
|
||||
{
|
||||
active = true;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (active == true)
|
||||
{
|
||||
active = false;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean validBlock (Block block)
|
||||
{
|
||||
return block == TContent.lightCrystalBase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive ()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive (boolean flag)
|
||||
{
|
||||
active = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
tags.setShort("Time", currentTime);
|
||||
tags.setByte("Value", crystalValue);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
currentTime = tags.getShort("Time");
|
||||
crystalValue = tags.getByte("Value");
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
active = tags.getBoolean("Active");
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setBoolean("Active", active);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readCustomNBT(packet.customParam1);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public void updateCrystalValue ()
|
||||
{
|
||||
if (crystalValue > 0)
|
||||
{
|
||||
Block block = Block.blocksList[worldObj.getBlockId(xCoord, yCoord + 1, zCoord)];
|
||||
if (block == TContent.lightCrystalBase)
|
||||
{
|
||||
int meta = worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord);
|
||||
if (meta == 3)
|
||||
crystalValue = 64;
|
||||
else if (meta == 2)
|
||||
crystalValue = 28;
|
||||
else if (meta == 1)
|
||||
crystalValue = 8;
|
||||
else
|
||||
crystalValue = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
crystalValue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GolemCoreLogic extends InventoryLogic implements IInventory
|
||||
{
|
||||
|
||||
public GolemCoreLogic()
|
||||
{
|
||||
super(1);
|
||||
}
|
||||
|
||||
public ItemStack getKey ()
|
||||
{
|
||||
return inventory[0];
|
||||
}
|
||||
|
||||
public void setKey (ItemStack itemstack)
|
||||
{
|
||||
inventory[0] = itemstack;
|
||||
onInventoryChanged();
|
||||
}
|
||||
|
||||
public void clear ()
|
||||
{
|
||||
inventory[0] = null;
|
||||
}
|
||||
|
||||
public int getSizeInventory ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlot (int slot)
|
||||
{
|
||||
return inventory[0];
|
||||
}
|
||||
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public boolean canInteractWith (EntityPlayer entityplayer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void openChest ()
|
||||
{
|
||||
}
|
||||
|
||||
public void closeChest ()
|
||||
{
|
||||
}
|
||||
|
||||
public boolean isUseableByPlayer (EntityPlayer entityplayer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing (int i)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot (int i, ItemStack itemstack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultName ()
|
||||
{
|
||||
return "golems.core";
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readFromNBT(packet.customParam1);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,360 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.src.ModLoader;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class GolemPedestalLogic extends TileEntity implements IInventory
|
||||
{
|
||||
public ItemStack supply;
|
||||
public static int cost[] = null;
|
||||
public static int souls[] = null;
|
||||
|
||||
public GolemPedestalLogic()
|
||||
{
|
||||
supply = null;
|
||||
if (cost == null)
|
||||
{
|
||||
cost = new int[512];
|
||||
souls = new int[512];
|
||||
cost[Block.planks.blockID] = 0;
|
||||
cost[Block.wood.blockID] = 32;
|
||||
cost[Block.cloth.blockID] = 8;
|
||||
cost[Block.cobblestoneMossy.blockID] = 16;
|
||||
cost[Block.obsidian.blockID] = 8;
|
||||
cost[Block.pumpkin.blockID] = 8;
|
||||
cost[Block.netherrack.blockID] = 64;
|
||||
cost[Block.slowSand.blockID] = 1;
|
||||
cost[Block.glowStone.blockID] = 1;
|
||||
cost[Block.pumpkinLantern.blockID] = 8;
|
||||
cost[Block.blockDiamond.blockID] = 1;
|
||||
cost[Block.blockGold.blockID] = 1;
|
||||
cost[Block.blockIron.blockID] = 1;
|
||||
cost[Block.blockLapis.blockID] = 1;
|
||||
cost[Block.jukebox.blockID] = 1;
|
||||
cost[Block.music.blockID] = 1;
|
||||
cost[Block.melon.blockID] = 8;
|
||||
cost[Block.torchRedstoneIdle.blockID] = 6;
|
||||
cost[Block.torchRedstoneActive.blockID] = cost[Block.torchRedstoneIdle.blockID];
|
||||
cost[Item.redstone.itemID] = 6;
|
||||
cost[Item.beefRaw.itemID] = 8;
|
||||
cost[Item.beefCooked.itemID] = cost[Item.beefRaw.itemID];
|
||||
cost[Item.porkRaw.itemID] = cost[Item.beefRaw.itemID];
|
||||
cost[Item.porkCooked.itemID] = cost[Item.beefRaw.itemID];
|
||||
cost[Item.enderPearl.itemID] = 1;
|
||||
cost[Item.eyeOfEnder.itemID] = 1;
|
||||
cost[Item.blazeRod.itemID] = 2;
|
||||
cost[Block.mushroomBrown.blockID] = 16;
|
||||
cost[Block.mushroomRed.blockID] = cost[Block.mushroomBrown.blockID];
|
||||
cost[Block.netherStalk.blockID] = 6;
|
||||
cost[Item.glowstone.itemID] = 4;
|
||||
cost[Item.diamond.itemID] = 1;
|
||||
cost[Item.ingotIron.itemID] = 8;
|
||||
cost[Item.ingotGold.itemID] = 2;
|
||||
cost[Item.reed.itemID] = 8;
|
||||
cost[Item.sugar.itemID] = cost[Item.reed.itemID];
|
||||
cost[Item.bucketLava.itemID] = 1;
|
||||
cost[Item.cake.itemID] = 1;
|
||||
cost[Item.bucketMilk.itemID] = 1;
|
||||
cost[Item.wheat.itemID] = 32;
|
||||
cost[Item.bread.itemID] = 8;
|
||||
cost[Block.plantYellow.blockID] = 32;
|
||||
cost[Block.plantRed.blockID] = cost[Block.plantYellow.blockID];
|
||||
cost[Block.dragonEgg.blockID] = 1;
|
||||
cost[Block.tallGrass.blockID] = 64;
|
||||
cost[Block.sapling.blockID] = 64;
|
||||
cost[Item.ghastTear.itemID] = 8;
|
||||
cost[Item.goldNugget.itemID] = 18;
|
||||
cost[Item.spiderEye.itemID] = 16;
|
||||
cost[Item.fermentedSpiderEye.itemID] = 6;
|
||||
cost[Item.bowlSoup.itemID] = 0;
|
||||
cost[Item.fishRaw.itemID] = 1;
|
||||
cost[Item.fishCooked.itemID] = cost[Item.fishRaw.itemID];
|
||||
cost[Item.magmaCream.itemID] = 2;
|
||||
cost[Item.blazePowder.itemID] = 4;
|
||||
cost[Item.speckledMelon.itemID] = 1;
|
||||
cost[Item.paper.itemID] = 8;
|
||||
cost[Item.book.itemID] = 2;
|
||||
cost[Item.egg.itemID] = 4;
|
||||
cost[Item.slimeBall.itemID] = 2;
|
||||
cost[Item.saddle.itemID] = 1;
|
||||
cost[Item.feather.itemID] = 48;
|
||||
cost[Item.gunpowder.itemID] = 16;
|
||||
cost[Item.appleRed.itemID] = 8;
|
||||
cost[Item.appleGold.itemID] = 1;
|
||||
cost[Item.dyePowder.itemID] = 64;
|
||||
cost[Item.bone.itemID] = 2;
|
||||
cost[Item.rottenFlesh.itemID] = 48;
|
||||
cost[Item.cookie.itemID] = 16;
|
||||
cost[Item.melon.itemID] = 32;
|
||||
cost[Item.chickenCooked.itemID] = 8;
|
||||
cost[Item.chickenRaw.itemID] = cost[Item.chickenCooked.itemID];
|
||||
cost[Item.silk.itemID] = 64;
|
||||
cost[Block.cactus.blockID] = 32;
|
||||
souls[Block.planks.blockID] = 0;
|
||||
souls[Block.wood.blockID] = 1;
|
||||
souls[Block.cloth.blockID] = 1;
|
||||
souls[Block.cobblestoneMossy.blockID] = 1;
|
||||
souls[Block.obsidian.blockID] = 1;
|
||||
souls[Block.pumpkin.blockID] = 1;
|
||||
souls[Block.netherrack.blockID] = 1;
|
||||
souls[Block.slowSand.blockID] = 1;
|
||||
souls[Block.glowStone.blockID] = 2;
|
||||
souls[Block.pumpkinLantern.blockID] = 1;
|
||||
souls[Block.blockDiamond.blockID] = 27;
|
||||
souls[Block.blockGold.blockID] = 2;
|
||||
souls[Block.blockIron.blockID] = 2;
|
||||
souls[Block.blockLapis.blockID] = 3;
|
||||
souls[Block.jukebox.blockID] = 3;
|
||||
souls[Block.music.blockID] = 1;
|
||||
souls[Block.melon.blockID] = 1;
|
||||
souls[Block.torchRedstoneIdle.blockID] = 1;
|
||||
souls[Block.torchRedstoneActive.blockID] = souls[Block.torchRedstoneIdle.blockID];
|
||||
souls[Item.redstone.itemID] = 1;
|
||||
souls[Item.beefRaw.itemID] = 1;
|
||||
souls[Item.beefCooked.itemID] = souls[Item.beefRaw.itemID];
|
||||
souls[Item.porkRaw.itemID] = souls[Item.beefRaw.itemID];
|
||||
souls[Item.porkCooked.itemID] = souls[Item.beefRaw.itemID];
|
||||
souls[Item.enderPearl.itemID] = 1;
|
||||
souls[Item.eyeOfEnder.itemID] = 2;
|
||||
souls[Item.blazeRod.itemID] = 2;
|
||||
souls[Block.mushroomBrown.blockID] = 1;
|
||||
souls[Block.mushroomRed.blockID] = souls[Block.mushroomBrown.blockID];
|
||||
souls[Block.netherStalk.blockID] = 1;
|
||||
souls[Item.glowstone.itemID] = 1;
|
||||
souls[Item.diamond.itemID] = 3;
|
||||
souls[Item.ingotIron.itemID] = 1;
|
||||
souls[Item.ingotGold.itemID] = 1;
|
||||
souls[Item.reed.itemID] = 1;
|
||||
souls[Item.sugar.itemID] = souls[Item.reed.itemID];
|
||||
souls[Item.bucketLava.itemID] = 1;
|
||||
souls[Item.cake.itemID] = 1;
|
||||
souls[Item.bucketMilk.itemID] = 1;
|
||||
souls[Item.wheat.itemID] = 1;
|
||||
souls[Item.bread.itemID] = 1;
|
||||
souls[Block.plantYellow.blockID] = 1;
|
||||
souls[Block.plantRed.blockID] = souls[Block.plantYellow.blockID];
|
||||
souls[Block.dragonEgg.blockID] = 1;
|
||||
souls[Block.tallGrass.blockID] = 1;
|
||||
souls[Block.sapling.blockID] = 1;
|
||||
souls[Item.ghastTear.itemID] = 1;
|
||||
souls[Item.goldNugget.itemID] = 1;
|
||||
souls[Item.spiderEye.itemID] = 1;
|
||||
souls[Item.fermentedSpiderEye.itemID] = 1;
|
||||
souls[Item.bowlSoup.itemID] = 1;
|
||||
souls[Item.fishRaw.itemID] = 1;
|
||||
souls[Item.fishCooked.itemID] = souls[Item.fishRaw.itemID];
|
||||
souls[Item.magmaCream.itemID] = 1;
|
||||
souls[Item.blazePowder.itemID] = 1;
|
||||
souls[Item.speckledMelon.itemID] = 1;
|
||||
souls[Item.paper.itemID] = 1;
|
||||
souls[Item.book.itemID] = 1;
|
||||
souls[Item.egg.itemID] = 1;
|
||||
souls[Item.slimeBall.itemID] = 1;
|
||||
souls[Item.saddle.itemID] = 1;
|
||||
souls[Item.feather.itemID] = 1;
|
||||
souls[Item.gunpowder.itemID] = 1;
|
||||
souls[Item.appleRed.itemID] = 1;
|
||||
souls[Item.appleGold.itemID] = 3;
|
||||
souls[Item.dyePowder.itemID] = 1;
|
||||
souls[Item.bone.itemID] = 1;
|
||||
souls[Item.rottenFlesh.itemID] = 1;
|
||||
souls[Item.cookie.itemID] = 1;
|
||||
souls[Item.melon.itemID] = 1;
|
||||
souls[Item.chickenCooked.itemID] = 1;
|
||||
souls[Item.chickenRaw.itemID] = souls[Item.chickenCooked.itemID];
|
||||
souls[Item.silk.itemID] = 1;
|
||||
souls[Block.cactus.blockID] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public int getSizeInventory ()
|
||||
{
|
||||
return 9;
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlot (int i)
|
||||
{
|
||||
if (supply != null && supply.getItem() == null)
|
||||
{
|
||||
supply = null;
|
||||
}
|
||||
return supply;
|
||||
}
|
||||
|
||||
public boolean subtractSoul (int i)
|
||||
{
|
||||
System.out.println("SUBTRACT WHY");
|
||||
if (supply == null || supply.itemID >= 512 || cost[supply.itemID] == 0)
|
||||
{
|
||||
worldObj.playSoundAtEntity(ModLoader.getMinecraftInstance().thePlayer, "mob.blaze.death", 1.0F, 0.5F);
|
||||
ModLoader.getMinecraftInstance().thePlayer.addChatMessage("I require more souls...");
|
||||
return false;
|
||||
}
|
||||
int j = cost[supply.itemID];
|
||||
int k = souls[supply.itemID];
|
||||
int l = (supply.stackSize / j) * k;
|
||||
System.out.println((new StringBuilder()).append("Subtracting amt").append(i).append(" s").append(k).append(" c").append(j).append(" ss").append(supply.stackSize).append(" id")
|
||||
.append(supply.itemID).append(" sa").append(l).append(" calc").append(Math.ceil((double) i / (double) k)).toString());
|
||||
if (l < i)
|
||||
{
|
||||
worldObj.playSoundAtEntity(ModLoader.getMinecraftInstance().thePlayer, "mob.blaze.death", 1.0F, 0.5F);
|
||||
ModLoader.getMinecraftInstance().thePlayer.addChatMessage("I need more souls...");
|
||||
return false;
|
||||
}
|
||||
supply.stackSize -= Math.ceil((double) i / (double) k) * (double) j;
|
||||
if (supply.stackSize == 0)
|
||||
{
|
||||
supply = null;
|
||||
}
|
||||
else if (supply.stackSize < 0)
|
||||
{
|
||||
throw new UnsupportedOperationException((new StringBuilder())
|
||||
.append("If you are getting this error then your golems mod has derped, \nplease contact billythegoat101 on the minecraftforums with the error code: LERN YO MATHS [i")
|
||||
.append(supply.itemID).append(",ss").append(supply.stackSize).append(",a").append(i).append("]").toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack decrStackSize (int i, int j)
|
||||
{
|
||||
if (supply != null && supply.getItem() == null)
|
||||
{
|
||||
supply = null;
|
||||
}
|
||||
if (supply != null)
|
||||
{
|
||||
if (supply.stackSize <= j)
|
||||
{
|
||||
ItemStack itemstack = supply;
|
||||
supply = null;
|
||||
onInventoryChanged();
|
||||
return itemstack;
|
||||
}
|
||||
ItemStack itemstack1 = supply.splitStack(j);
|
||||
if (supply.stackSize == 0)
|
||||
{
|
||||
supply = null;
|
||||
}
|
||||
onInventoryChanged();
|
||||
return itemstack1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setInventorySlotContents (int i, ItemStack itemstack)
|
||||
{
|
||||
supply = itemstack;
|
||||
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
itemstack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
if (supply != null && supply.getItem() == null)
|
||||
{
|
||||
supply = null;
|
||||
}
|
||||
onInventoryChanged();
|
||||
}
|
||||
|
||||
public void writeToNBT (NBTTagCompound nbttagcompound)
|
||||
{
|
||||
super.writeToNBT(nbttagcompound);
|
||||
if (supply == null)
|
||||
{
|
||||
supply = new ItemStack(0, 0, 0);
|
||||
}
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
if (supply != null)
|
||||
{
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("Slot", (byte) 0);
|
||||
supply.writeToNBT(nbttagcompound1);
|
||||
nbttaglist.appendTag(nbttagcompound1);
|
||||
}
|
||||
nbttagcompound.setTag("Items", nbttaglist);
|
||||
}
|
||||
|
||||
public void readFromNBT (NBTTagCompound nbttagcompound)
|
||||
{
|
||||
super.readFromNBT(nbttagcompound);
|
||||
supply = new ItemStack(0, 0, 0);
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
|
||||
for (int i = 0; i < nbttaglist.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
|
||||
int j = nbttagcompound1.getByte("Slot") & 0xff;
|
||||
if (j >= 0 && j < 1)
|
||||
{
|
||||
supply = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
if (supply != null && supply.getItem() == null)
|
||||
{
|
||||
supply = null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getInvName ()
|
||||
{
|
||||
return "golempedestalinv";
|
||||
}
|
||||
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
public boolean canInteractWith (EntityPlayer entityplayer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void openChest ()
|
||||
{
|
||||
}
|
||||
|
||||
public void closeChest ()
|
||||
{
|
||||
}
|
||||
|
||||
public void clear ()
|
||||
{
|
||||
supply = null;
|
||||
}
|
||||
|
||||
public boolean isUseableByPlayer (EntityPlayer entityplayer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing (int i)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized ()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot (int i, ItemStack itemstack)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
public class LavaTankLogic extends MultiServantLogic implements IFluidHandler
|
||||
{
|
||||
public FluidTank tank;
|
||||
public int renderOffset;
|
||||
|
||||
public LavaTankLogic()
|
||||
{
|
||||
tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
int amount = tank.fill(resource, doFill);
|
||||
if (amount > 0 && doFill)
|
||||
{
|
||||
renderOffset = resource.amount;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
FluidStack amount = tank.drain(maxDrain, doDrain);
|
||||
if (amount != null && doDrain)
|
||||
{
|
||||
renderOffset = -maxDrain;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
//return tank.fill(fluid, false) > 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo (ForgeDirection from)
|
||||
{
|
||||
FluidStack fluid = null;
|
||||
if (tank.getFluid() != null)
|
||||
fluid = tank.getFluid().copy();
|
||||
return new FluidTankInfo[] { new FluidTankInfo(fluid, tank.getCapacity())};
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public IFluidTank[] getTanks (ForgeDirection direction)
|
||||
{
|
||||
return new IFluidTank[] { tank };
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidTank getTank (ForgeDirection direction, FluidStack type)
|
||||
{
|
||||
return tank;
|
||||
}*/
|
||||
|
||||
public float getFluidAmountScaled ()
|
||||
{
|
||||
return (float) (tank.getFluid().amount - renderOffset) / (float) (tank.getCapacity() * 1.01F);
|
||||
}
|
||||
|
||||
public boolean containsFluid ()
|
||||
{
|
||||
return tank.getFluid() != null;
|
||||
}
|
||||
|
||||
public int getBrightness ()
|
||||
{
|
||||
if (containsFluid())
|
||||
{
|
||||
int id = tank.getFluid().fluidID;
|
||||
if (id < 4096)
|
||||
{
|
||||
return Block.lightValue[id];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
if (tags.getBoolean("hasFluid"))
|
||||
tank.setFluid(new FluidStack(tags.getInteger("itemID"), tags.getInteger("amount")));
|
||||
else
|
||||
tank.setFluid(null);
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
FluidStack liquid = tank.getFluid();
|
||||
tags.setBoolean("hasFluid", liquid != null);
|
||||
if (liquid != null)
|
||||
{
|
||||
tags.setInteger("itemID", liquid.fluidID);
|
||||
tags.setInteger("amount", liquid.amount);
|
||||
}
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readCustomNBT(packet.customParam1);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/* Updating */
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (renderOffset > 0)
|
||||
{
|
||||
renderOffset -= 6;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class LiquidTextureLogic extends TileEntity
|
||||
{
|
||||
int texturePos;
|
||||
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setLiquidType (int tex)
|
||||
{
|
||||
texturePos = tex;
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public int getLiquidType ()
|
||||
{
|
||||
return texturePos;
|
||||
}
|
||||
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
texturePos = tags.getInteger("Texture");
|
||||
}
|
||||
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setInteger("Texture", texturePos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readCustomNBT(packet.customParam1);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.library.util.CoordTuple;
|
||||
import tconstruct.library.util.IMasterLogic;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class MultiServantLogic extends TileEntity implements IServantLogic
|
||||
{
|
||||
boolean hasMaster;
|
||||
CoordTuple master;
|
||||
short masterID;
|
||||
byte masterMeat; //Typo, it stays!
|
||||
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasValidMaster ()
|
||||
{
|
||||
if (!hasMaster)
|
||||
return false;
|
||||
|
||||
if (worldObj.getBlockId(master.x, master.y, master.z) == masterID && worldObj.getBlockMetadata(master.x, master.y, master.z) == masterMeat)
|
||||
return true;
|
||||
else
|
||||
{
|
||||
hasMaster = false;
|
||||
master = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public CoordTuple getMasterPosition ()
|
||||
{
|
||||
return master;
|
||||
}
|
||||
|
||||
public void overrideMaster (int x, int y, int z)
|
||||
{
|
||||
hasMaster = true;
|
||||
master = new CoordTuple(x, y, z);
|
||||
masterID = (short) worldObj.getBlockId(x, y, z);
|
||||
masterMeat = (byte) worldObj.getBlockMetadata(x, y, z);
|
||||
}
|
||||
|
||||
public void removeMaster ()
|
||||
{
|
||||
hasMaster = false;
|
||||
master = null;
|
||||
masterID = 0;
|
||||
masterMeat = 0;
|
||||
}
|
||||
|
||||
public boolean verifyMaster (int x, int y, int z)
|
||||
{
|
||||
if (master.equalCoords(x, y, z) && worldObj.getBlockId(x, y, z) == masterID && worldObj.getBlockMetadata(x, y, z) == masterMeat)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setMaster (int x, int y, int z)
|
||||
{
|
||||
if (!hasMaster || worldObj.getBlockId(master.x, master.y, master.z) != masterID || (worldObj.getBlockMetadata(master.x, master.y, master.z) != masterMeat))
|
||||
{
|
||||
overrideMaster(x, y, z);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyMasterOfChange ()
|
||||
{
|
||||
if (hasValidMaster())
|
||||
{
|
||||
IMasterLogic logic = (IMasterLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
logic.notifyChange(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
hasMaster = tags.getBoolean("HasMaster");
|
||||
if (hasMaster)
|
||||
{
|
||||
int xCenter = tags.getInteger("xCenter");
|
||||
int yCenter = tags.getInteger("yCenter");
|
||||
int zCenter = tags.getInteger("zCenter");
|
||||
master = new CoordTuple(xCenter, yCenter, zCenter);
|
||||
masterID = tags.getShort("MasterID");
|
||||
masterMeat = tags.getByte("masterMeat");
|
||||
}
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setBoolean("HasMaster", hasMaster);
|
||||
if (hasMaster)
|
||||
{
|
||||
tags.setInteger("xCenter", master.x);
|
||||
tags.setInteger("yCenter", master.y);
|
||||
tags.setInteger("zCenter", master.z);
|
||||
tags.setShort("MasterID", masterID);
|
||||
tags.setByte("masterMeat", masterMeat);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readCustomNBT(packet.customParam1);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.inventory.PartCrafterChestContainer;
|
||||
import tconstruct.inventory.PartCrafterContainer;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PartCrafterLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
boolean craftedTop;
|
||||
boolean craftedBottom;
|
||||
|
||||
public PartCrafterLogic()
|
||||
{
|
||||
super(10);
|
||||
craftedTop = false;
|
||||
craftedBottom = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "toolstation.parts";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(xPos, y, zPos);
|
||||
if (tile != null && tile instanceof PatternChestLogic)
|
||||
return new PartCrafterChestContainer(inventoryplayer, this, (PatternChestLogic) tile);
|
||||
}
|
||||
}
|
||||
return new PartCrafterContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
//Called when emptying a slot, not when another item is placed in it
|
||||
public ItemStack decrStackSize (int slotID, int quantity)
|
||||
{
|
||||
ItemStack returnStack = super.decrStackSize(slotID, quantity);
|
||||
tryBuildPart(slotID);
|
||||
return returnStack;
|
||||
}
|
||||
|
||||
public void tryBuildPart (int slotID)
|
||||
{
|
||||
if (slotID == 4 || slotID == 5)
|
||||
{
|
||||
if (!craftedTop && inventory[0] != null)
|
||||
{
|
||||
int value = PatternBuilder.instance.getPartValue(inventory[2]);
|
||||
IPattern item = (IPattern) inventory[0].getItem();
|
||||
int cost = item != null ? item.getPatternCost(inventory[0]) : 0;
|
||||
if (value > 0 && cost > 0)
|
||||
{
|
||||
int decrease = cost / value;
|
||||
if (cost % value != 0)
|
||||
decrease++;
|
||||
super.decrStackSize(2, decrease); //Call super to avoid crafting again
|
||||
}
|
||||
}
|
||||
|
||||
if (inventory[4] != null || inventory[5] != null)
|
||||
craftedTop = true;
|
||||
else
|
||||
craftedTop = false;
|
||||
}
|
||||
|
||||
if (!craftedTop)
|
||||
buildTopPart();
|
||||
|
||||
if (slotID == 6 || slotID == 7)
|
||||
{
|
||||
if (!craftedBottom && inventory[1] != null)
|
||||
{
|
||||
int value = PatternBuilder.instance.getPartValue(inventory[3]);
|
||||
IPattern item = (IPattern) inventory[1].getItem();
|
||||
int cost = item != null ? item.getPatternCost(inventory[1]) : 0;
|
||||
if (value > 0 && cost > 0)
|
||||
{
|
||||
int decrease = cost / value;
|
||||
if (cost % value != 0)
|
||||
decrease++;
|
||||
super.decrStackSize(3, decrease); //Call super to avoid crafting again
|
||||
}
|
||||
}
|
||||
|
||||
if (inventory[6] != null || inventory[7] != null)
|
||||
craftedBottom = true;
|
||||
else
|
||||
craftedBottom = false;
|
||||
}
|
||||
|
||||
if (!craftedBottom)
|
||||
buildBottomPart();
|
||||
}
|
||||
|
||||
//Called when a slot has something placed into it.
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
super.setInventorySlotContents(slot, itemstack);
|
||||
if ((slot == 0 || slot == 2) && !craftedTop)
|
||||
buildTopPart();
|
||||
if ((slot == 1 || slot == 3) && !craftedBottom)
|
||||
buildBottomPart();
|
||||
}
|
||||
|
||||
void buildTopPart ()
|
||||
{
|
||||
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[2], inventory[0], inventory[1]);
|
||||
if (parts != null)
|
||||
{
|
||||
inventory[4] = parts[0];
|
||||
inventory[5] = parts[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory[4] = inventory[5] = null;
|
||||
}
|
||||
}
|
||||
|
||||
void buildBottomPart ()
|
||||
{
|
||||
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[3], inventory[1], inventory[0]);
|
||||
if (parts != null)
|
||||
{
|
||||
inventory[6] = parts[0];
|
||||
inventory[7] = parts[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory[6] = inventory[7] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
craftedTop = tags.getBoolean("CraftedTop");
|
||||
craftedBottom = tags.getBoolean("CraftedBottom");
|
||||
}
|
||||
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
tags.setBoolean("CraftedTop", craftedTop);
|
||||
tags.setBoolean("CraftedBottom", craftedBottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.inventory.PatternChestContainer;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PatternChestLogic extends InventoryLogic
|
||||
{
|
||||
public PatternChestLogic()
|
||||
{
|
||||
super(30);
|
||||
}
|
||||
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "toolstation.patternholder";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new PatternChestContainer(inventoryplayer, this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class RedwireLogic extends TileEntity
|
||||
{
|
||||
byte facesUsed;
|
||||
byte type;
|
||||
byte distanceTravelled;
|
||||
byte maxDistance;
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
/*hasMaster = tags.getBoolean("HasMaster");
|
||||
if (hasMaster)
|
||||
{
|
||||
int xCenter = tags.getInteger("xCenter");
|
||||
int yCenter = tags.getInteger("yCenter");
|
||||
int zCenter = tags.getInteger("zCenter");
|
||||
master = new CoordTuple(xCenter, yCenter, zCenter);
|
||||
masterID = tags.getShort("MasterID");
|
||||
masterMeat = tags.getByte("masterMeat");
|
||||
}*/
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
/*tags.setBoolean("HasMaster", hasMaster);
|
||||
if (hasMaster)
|
||||
{
|
||||
tags.setInteger("xCenter", master.x);
|
||||
tags.setInteger("yCenter", master.y);
|
||||
tags.setInteger("zCenter", master.z);
|
||||
tags.setShort("MasterID", masterID);
|
||||
tags.setByte("masterMeat", masterMeat);
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readCustomNBT(packet.customParam1);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.library.util.IFacingLogic;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet132TileEntityData;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class SmelteryDrainLogic extends MultiServantLogic implements IFluidHandler, IFacingLogic
|
||||
{
|
||||
byte direction;
|
||||
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public FluidStack getLiquid ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity ()
|
||||
{
|
||||
if (!hasMaster)
|
||||
return 0;
|
||||
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
return smeltery.getCapacity();
|
||||
}*/
|
||||
|
||||
/*@Override
|
||||
public int fill (FluidStack resource, boolean doFill)
|
||||
{
|
||||
|
||||
}*/
|
||||
|
||||
/*@Override
|
||||
public FluidStack drain (int maxDrain, boolean doDrain)
|
||||
{
|
||||
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (hasMaster && resource != null)
|
||||
{
|
||||
if (doFill)
|
||||
{
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
return smeltery.fill(resource, doFill);
|
||||
}
|
||||
else
|
||||
{
|
||||
return resource.amount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (hasValidMaster())
|
||||
{
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
return smeltery.drain(maxDrain, doDrain);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo (ForgeDirection from)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@Override
|
||||
public ILiquidTank[] getTanks (ForgeDirection direction)
|
||||
{
|
||||
if (hasValidMaster())
|
||||
{
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
return new ILiquidTank[] { smeltery };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank getTank (ForgeDirection direction, FluidStack type)
|
||||
{
|
||||
if (hasValidMaster())
|
||||
{
|
||||
return (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
}
|
||||
return null;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public byte getRenderDirection ()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getForgeDirection ()
|
||||
{
|
||||
return ForgeDirection.VALID_DIRECTIONS[direction];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (int side)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (float yaw, float pitch, EntityLivingBase player)
|
||||
{
|
||||
if (pitch > 45)
|
||||
direction = 1;
|
||||
else if (pitch < -45)
|
||||
direction = 0;
|
||||
else
|
||||
{
|
||||
int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3;
|
||||
switch (facing)
|
||||
{
|
||||
case 0:
|
||||
direction = 2;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
direction = 5;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
direction = 3;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
direction = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
direction = tags.getByte("Direction");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
tags.setByte("Direction", direction);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readFromNBT(packet.customParam1);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,122 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.inventory.PatternShaperContainer;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class StencilTableLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
public StencilTableLogic()
|
||||
{
|
||||
super(2);
|
||||
}
|
||||
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "toolstation.PatternShaper";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new PatternShaperContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void onInventoryChanged()
|
||||
{
|
||||
if (inventory[0] == null)
|
||||
inventory[1] = null;
|
||||
super.onInventoryChanged();
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
super.setInventorySlotContents(slot, itemstack);
|
||||
if (slot == 0 && itemstack != null && itemstack.getItem() instanceof tconstruct.items.Pattern)
|
||||
{
|
||||
if (itemstack.getItemDamage() == 0)
|
||||
setInventorySlotContents(1, new ItemStack(TContent.woodPattern, 1, 1));
|
||||
else if (itemstack.getItemDamage() == 1)
|
||||
setInventorySlotContents(1, new ItemStack(TContent.metalPattern, 1, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
if (slot == 1)
|
||||
{
|
||||
super.decrStackSize(0, 1);
|
||||
if (inventory[0] == null)
|
||||
return super.decrStackSize(slot, quantity);
|
||||
else
|
||||
return inventory[1].copy();
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack ret = super.decrStackSize(slot, quantity);
|
||||
if (inventory[0] == null)
|
||||
super.decrStackSize(1, 1);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public void altDecrStackSize (int slot, int quantity)
|
||||
{
|
||||
if (inventory[slot] != null)
|
||||
{
|
||||
if (inventory[slot].stackSize <= quantity)
|
||||
{
|
||||
ItemStack stack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return;
|
||||
}
|
||||
ItemStack split = inventory[slot].splitStack(quantity);
|
||||
if (inventory[slot].stackSize == 0)
|
||||
{
|
||||
inventory[slot] = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropInventorySlot (int slot)
|
||||
{
|
||||
if (slot == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.inventory.ToolForgeContainer;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/* Simple class for storing items in the block
|
||||
*/
|
||||
|
||||
public class ToolForgeLogic extends ToolStationLogic implements ISidedInventory
|
||||
{
|
||||
ItemStack previousTool;
|
||||
String toolName;
|
||||
|
||||
public ToolForgeLogic()
|
||||
{
|
||||
super(6);
|
||||
toolName = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "toolforge.crafting";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new ToolForgeContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
public void buildTool (String name)
|
||||
{
|
||||
toolName = name;
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], inventory[4], name);
|
||||
if (inventory[0] == null)
|
||||
inventory[0] = tool;
|
||||
else
|
||||
{
|
||||
NBTTagCompound tags = inventory[0].getTagCompound();
|
||||
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
|
||||
{
|
||||
inventory[0] = tool;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.inventory.ToolStationContainer;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/* Simple class for storing items in the block
|
||||
*/
|
||||
|
||||
public class ToolStationLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
public ItemStack previousTool;
|
||||
public String toolName;
|
||||
|
||||
public ToolStationLogic()
|
||||
{
|
||||
super(4);
|
||||
toolName = "";
|
||||
}
|
||||
|
||||
public ToolStationLogic(int slots)
|
||||
{
|
||||
super(slots);
|
||||
toolName = "";
|
||||
}
|
||||
|
||||
public boolean canDropInventorySlot (int slot)
|
||||
{
|
||||
if (slot == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing (int var1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "toolstation.crafting";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new ToolStationContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
public void onInventoryChanged ()
|
||||
{
|
||||
buildTool(toolName);
|
||||
if (this.worldObj != null)
|
||||
{
|
||||
this.blockMetadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
|
||||
this.worldObj.updateTileEntityChunkAndDoNothing(this.xCoord, this.yCoord, this.zCoord, this);
|
||||
}
|
||||
}
|
||||
|
||||
public void buildTool (String name)
|
||||
{
|
||||
toolName = name;
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], name);
|
||||
if (inventory[0] == null)
|
||||
inventory[0] = tool;
|
||||
else
|
||||
{
|
||||
NBTTagCompound tags = inventory[0].getTagCompound();
|
||||
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
|
||||
{
|
||||
inventory[0] = tool;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setToolname (String name)
|
||||
{
|
||||
toolName = name;
|
||||
buildTool(name);
|
||||
}
|
||||
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package tconstruct.blocks.traps;
|
||||
|
||||
import tconstruct.client.block.BarricadeRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BarricadeBlock extends Block
|
||||
{
|
||||
public BarricadeBlock(int blockID)//, String name, int texture)
|
||||
{
|
||||
super(blockID, Material.wood);
|
||||
setHardness(4.0F);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
//setUnlocalizedName("barricade" + name);
|
||||
//GameRegistry.addName(this, name + " Barricade");
|
||||
}
|
||||
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
return Block.wood.getIcon(2, meta % 4);
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRenderType ()
|
||||
{
|
||||
return BarricadeRender.model;
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World par1World, int x, int y, int z)
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1);
|
||||
}
|
||||
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int x, int y, int z)
|
||||
{
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
public void harvestBlock (World world, EntityPlayer player, int x, int y, int z, int meta)
|
||||
{
|
||||
if (meta % 4 > 0)
|
||||
{
|
||||
world.setBlock(x, y, z, this.blockID, meta - 1, 3);
|
||||
dropBlockAsItem_do(world, x, y, z, new ItemStack(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
dropBlockAsItem_do(world, x, y, z, new ItemStack(this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if ((stack != null) && (stack.itemID == this.blockID) && (!player.isSneaking()))
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta % 4 != 3)
|
||||
{
|
||||
world.setBlock(x, y, z, this.blockID, meta + 1, 3);
|
||||
Block.blocksList[this.blockID].onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
Block.blocksList[this.blockID].onPostBlockPlaced(world, x, y, z, meta);
|
||||
|
||||
Block var9 = Block.blocksList[this.blockID];
|
||||
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, var9.stepSound.getStepSound(), (var9.stepSound.getVolume() + 1.0F) / 2.0F, var9.stepSound.getPitch() * 0.8F);
|
||||
player.swingItem();
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
stack.stackSize -= 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
package tconstruct.blocks.traps;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFence;
|
||||
import net.minecraft.block.EnumMobType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Landmine extends Block
|
||||
{
|
||||
/** The mob type that can trigger this pressure plate. */
|
||||
private EnumMobType triggerMobType;
|
||||
|
||||
public Landmine(int par1, EnumMobType par3EnumMobType, Material par4Material)
|
||||
{
|
||||
super(par1, par4Material);
|
||||
this.triggerMobType = EnumMobType.mobs;
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setTickRandomly(true);
|
||||
float var5 = 0.0625F;
|
||||
this.setBlockBounds(var5, 0.0F, var5, 1.0F - var5, 0.03125F, 1.0F - var5);
|
||||
}
|
||||
|
||||
public Icon getBlockTexture (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
Block block = Block.blocksList[world.getBlockId(x, y - 1, z)];
|
||||
if (block != null)
|
||||
{
|
||||
return block.getBlockTexture(world, x, y - 1, z, side);
|
||||
}
|
||||
return Block.sponge.getIcon(side, world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
return Block.sponge.getIcon(1, meta);
|
||||
}
|
||||
|
||||
public void registerIcons (IconRegister par1IconRegister)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* How many world ticks before ticking
|
||||
*/
|
||||
public int tickRate ()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
|
||||
* cleared to be reused)
|
||||
*/
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getBlocksMovement (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
|
||||
*/
|
||||
public boolean canPlaceBlockAt (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) || BlockFence.isIdAFence(par1World.getBlockId(par2, par3 - 1, par4));
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
||||
* their own) Args: x, y, z, neighbor blockID
|
||||
*/
|
||||
public void onNeighborBlockChange (World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
boolean var6 = false;
|
||||
|
||||
if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && !BlockFence.isIdAFence(par1World.getBlockId(par2, par3 - 1, par4)))
|
||||
{
|
||||
var6 = true;
|
||||
}
|
||||
|
||||
if (var6)
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
//par1World.setBlock(par2, par3, par4, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the block if it's been scheduled
|
||||
*/
|
||||
public void updateTick (World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
if (par1World.getBlockMetadata(par2, par3, par4) != 0)
|
||||
{
|
||||
this.setStateIfMobInteractsWithPlate(par1World, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
|
||||
*/
|
||||
public void onEntityCollidedWithBlock (World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
if (par1World.getBlockMetadata(par2, par3, par4) != 1)
|
||||
{
|
||||
this.setStateIfMobInteractsWithPlate(par1World, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are mobs on the plate. If a mob is on the plate and it is off, it turns it on, and vice versa.
|
||||
*/
|
||||
private void setStateIfMobInteractsWithPlate (World world, int posX, int posY, int posZ)
|
||||
{
|
||||
boolean var5 = world.getBlockMetadata(posX, posY, posZ) == 1;
|
||||
boolean var6 = false;
|
||||
float var7 = 0.125F;
|
||||
List var8 = null;
|
||||
|
||||
if (this.triggerMobType == EnumMobType.everything)
|
||||
{
|
||||
var8 = world.getEntitiesWithinAABBExcludingEntity(
|
||||
(Entity) null,
|
||||
AxisAlignedBB.getAABBPool().getAABB((double) ((float) posX + var7), (double) posY, (double) ((float) posZ + var7), (double) ((float) (posX + 1) - var7), (double) posY + 0.25D,
|
||||
(double) ((float) (posZ + 1) - var7)));
|
||||
}
|
||||
|
||||
if (this.triggerMobType == EnumMobType.mobs)
|
||||
{
|
||||
var8 = world.getEntitiesWithinAABB(
|
||||
EntityLiving.class,
|
||||
AxisAlignedBB.getAABBPool().getAABB((double) ((float) posX + var7), (double) posY, (double) ((float) posZ + var7), (double) ((float) (posX + 1) - var7), (double) posY + 0.25D,
|
||||
(double) ((float) (posZ + 1) - var7)));
|
||||
}
|
||||
|
||||
if (this.triggerMobType == EnumMobType.players)
|
||||
{
|
||||
var8 = world.getEntitiesWithinAABB(
|
||||
EntityPlayer.class,
|
||||
AxisAlignedBB.getAABBPool().getAABB((double) ((float) posX + var7), (double) posY, (double) ((float) posZ + var7), (double) ((float) (posX + 1) - var7), (double) posY + 0.25D,
|
||||
(double) ((float) (posZ + 1) - var7)));
|
||||
}
|
||||
|
||||
if (!var8.isEmpty())
|
||||
{
|
||||
Iterator var9 = var8.iterator();
|
||||
|
||||
while (var9.hasNext())
|
||||
{
|
||||
Entity var10 = (Entity) var9.next();
|
||||
|
||||
if (!var10.doesEntityNotTriggerPressurePlate())
|
||||
{
|
||||
var6 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (var6 && !var5)
|
||||
{
|
||||
world.setBlock(posX, posY, posZ, 0);
|
||||
world.createExplosion((Entity) null, posX, posY, posZ, 2.0F, true);
|
||||
/*par1World.setBlockMetadataWithNotify(posX, posY, posZ, 1);
|
||||
par1World.notifyBlocksOfNeighborChange(posX, posY, posZ, this.blockID);
|
||||
par1World.notifyBlocksOfNeighborChange(posX, posY - 1, posZ, this.blockID);
|
||||
par1World.markBlockRangeForRenderUpdate(posX, posY, posZ, posX, posY, posZ);
|
||||
par1World.playSoundEffect((double)posX + 0.5D, (double)posY + 0.1D, (double)posZ + 0.5D, "random.click", 0.3F, 0.6F);*/
|
||||
}
|
||||
|
||||
/*if (!var6 && var5)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(posX, posY, posZ, 0);
|
||||
par1World.notifyBlocksOfNeighborChange(posX, posY, posZ, this.blockID);
|
||||
par1World.notifyBlocksOfNeighborChange(posX, posY - 1, posZ, this.blockID);
|
||||
par1World.markBlockRangeForRenderUpdate(posX, posY, posZ, posX, posY, posZ);
|
||||
par1World.playSoundEffect((double)posX + 0.5D, (double)posY + 0.1D, (double)posZ + 0.5D, "random.click", 0.3F, 0.5F);
|
||||
}
|
||||
|
||||
if (var6)
|
||||
{
|
||||
par1World.scheduleBlockUpdate(posX, posY, posZ, this.blockID, this.tickRate());
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* ejects contained items into the world, and notifies neighbours of an update, as appropriate
|
||||
*/
|
||||
public void breakBlock (World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
if (par6 > 0)
|
||||
{
|
||||
par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID);
|
||||
par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);
|
||||
}
|
||||
|
||||
super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the blocks bounds based on its current state. Args: world, x, y, z
|
||||
*/
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
boolean var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4) == 1;
|
||||
float var6 = 0.0625F;
|
||||
|
||||
if (var5)
|
||||
{
|
||||
this.setBlockBounds(var6, 0.0F, var6, 1.0F - var6, 0.03125F, 1.0F - var6);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(var6, 0.0F, var6, 1.0F - var6, 0.0625F, 1.0F - var6);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the block's bounds for rendering it as an item
|
||||
*/
|
||||
public void setBlockBoundsForItemRender ()
|
||||
{
|
||||
float var1 = 0.5F;
|
||||
float var2 = 0.125F;
|
||||
float var3 = 0.5F;
|
||||
this.setBlockBounds(0.5F - var1, 0.5F - var2, 0.5F - var3, 0.5F + var1, 0.5F + var2, 0.5F + var3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mobility information of the block, 0 = free, 1 = can't push but can move over, 2 = total immobility
|
||||
* and stop pistons
|
||||
*/
|
||||
public int getMobilityFlag ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package tconstruct.blocks.traps;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class Punji extends Block
|
||||
{
|
||||
|
||||
public Punji(int id)
|
||||
{
|
||||
super(id, Material.circuits);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
entity.fallDistance *= 2.0F;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package tconstruct.client;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
public class CustomBowRenderer implements IItemRenderer
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
private RenderBlocks renderBlocksInstance = new RenderBlocks();
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType (ItemStack item, ItemRenderType type)
|
||||
{
|
||||
return type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper (ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem (ItemRenderType type, ItemStack item, Object... data)
|
||||
{
|
||||
EntityLivingBase living = (EntityLivingBase) data[1];
|
||||
ItemRenderer renderer = RenderManager.instance.itemRenderer;
|
||||
for (int i = 0; i < item.getItem().getRenderPasses(item.getItemDamage()) + 1; i++)
|
||||
renderItem(living, item, i, type);
|
||||
}
|
||||
|
||||
public void renderItem (EntityLivingBase living, ItemStack stack, int renderPass, ItemRenderType type)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
Block block = null;
|
||||
if (stack.getItem() instanceof ItemBlock && stack.itemID < Block.blocksList.length)
|
||||
{
|
||||
block = Block.blocksList[stack.itemID];
|
||||
}
|
||||
|
||||
Icon icon = null; //living.getItemIcon(stack, renderPass);
|
||||
if (living instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) living;
|
||||
if (player.getItemInUse() != null)
|
||||
icon = stack.getItem().getIcon(stack, renderPass, player, player.getItemInUse(), player.getItemInUseCount());
|
||||
else
|
||||
icon = living.getItemIcon(stack, renderPass);
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = living.getItemIcon(stack, renderPass);
|
||||
}
|
||||
|
||||
if (icon == null)
|
||||
{
|
||||
GL11.glPopMatrix();
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (stack.getItemSpriteNumber() == 0)
|
||||
{
|
||||
this.mc.renderEngine.bindTexture("/terrain.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mc.renderEngine.bindTexture("/gui/items.png");
|
||||
}*/
|
||||
TextureManager texturemanager = this.mc.func_110434_K();
|
||||
texturemanager.func_110577_a(texturemanager.func_130087_a(stack.getItemSpriteNumber()));
|
||||
|
||||
if (type == ItemRenderType.EQUIPPED_FIRST_PERSON)
|
||||
{
|
||||
GL11.glTranslatef(0.6F, 0.5F, 0.5F);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glRotatef(180.0F, 0F, 0F, 1.0F);
|
||||
GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.75F);
|
||||
GL11.glTranslatef(-0.6F, -0.25F, 1.0F);
|
||||
GL11.glScalef(1.75F, 1.75F, 1.75F);
|
||||
}
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
float f = icon.getMinU();
|
||||
float f1 = icon.getMaxU();
|
||||
float f2 = icon.getMinV();
|
||||
float f3 = icon.getMaxV();
|
||||
float f4 = 0.0F;
|
||||
float f5 = 0.3F;
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glTranslatef(-f4, -f5, 0.0F);
|
||||
float f6 = 1.5F;
|
||||
GL11.glScalef(f6, f6, f6);
|
||||
GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F);
|
||||
ItemRenderer.renderItemIn2D(tessellator, f1, f2, f, f3, icon.getOriginX(), icon.getOriginY(), 0.0625F);
|
||||
|
||||
/*if (stack != null && stack.hasEffect() && renderPass == 0)
|
||||
{
|
||||
GL11.glDepthFunc(GL11.GL_EQUAL);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
this.mc.renderEngine.bindTexture("%blur%/misc/glint.png");
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
|
||||
float f7 = 0.76F;
|
||||
GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glPushMatrix();
|
||||
float f8 = 0.125F;
|
||||
GL11.glScalef(f8, f8, f8);
|
||||
float f9 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
|
||||
GL11.glTranslatef(f9, 0.0F, 0.0F);
|
||||
GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
|
||||
ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(f8, f8, f8);
|
||||
f9 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
|
||||
GL11.glTranslatef(-f9, 0.0F, 0.0F);
|
||||
GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
|
||||
ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
}*/
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
package tconstruct.client;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TheObliterator
|
||||
*
|
||||
* A class to create and draw true type
|
||||
* fonts onto the Minecraft game engine.
|
||||
*/
|
||||
public class CustomFont
|
||||
{
|
||||
private int texID;
|
||||
private int[] xPos;
|
||||
private int[] yPos;
|
||||
private int startChar;
|
||||
private int endChar;
|
||||
private FontMetrics metrics;
|
||||
|
||||
/**
|
||||
* Instantiates the font, filling in default start
|
||||
* and end character parameters.
|
||||
*
|
||||
* 'new CustomFont(ModLoader.getMinecraftInstance(),
|
||||
* "Arial", 12);
|
||||
*
|
||||
* @param mc The Minecraft instance for the font to be bound to.
|
||||
* @param fontName The name of the font to be drawn.
|
||||
* @param size The size of the font to be drawn.
|
||||
*/
|
||||
public CustomFont(Minecraft mc, Object font, int size)
|
||||
{
|
||||
this(mc, font, size, 0, 4000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates the font, pre-rendering a sprite
|
||||
* font image by using a true type font on a
|
||||
* bitmap. Then allocating that bitmap to the
|
||||
* Minecraft rendering engine for later use.
|
||||
*
|
||||
* 'new CustomFont(ModLoader.getMinecraftInstance(),
|
||||
* "Arial", 12, 32, 126);'
|
||||
*
|
||||
* @param mc The Minecraft instance for the font to be bound to.
|
||||
* @param fontName The name of the font to be drawn.
|
||||
* @param size The size of the font to be drawn.
|
||||
* @param startChar The starting ASCII character id to be drawable. (Default 32)
|
||||
* @param endChar The ending ASCII character id to be drawable. (Default 126)
|
||||
*/
|
||||
public CustomFont(Minecraft mc, Object font, int size, int startChar, int endChar)
|
||||
{
|
||||
this.startChar = startChar;
|
||||
this.endChar = endChar;
|
||||
xPos = new int[endChar - startChar];
|
||||
yPos = new int[endChar - startChar];
|
||||
|
||||
// Create a bitmap and fill it with a transparent color as well
|
||||
// as obtain a Graphics instance which can be drawn on.
|
||||
// NOTE: It is CRUICIAL that the size of the image is 256x256, if
|
||||
// it is not the Minecraft engine will not draw it properly.
|
||||
BufferedImage img = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g = img.getGraphics();
|
||||
try
|
||||
{
|
||||
if (font instanceof String)
|
||||
{
|
||||
String fontName = (String) font;
|
||||
if (fontName.contains("/"))
|
||||
g.setFont(Font.createFont(Font.TRUETYPE_FONT, new File(fontName)).deriveFont((float) size));
|
||||
else
|
||||
g.setFont(new Font(fontName, 0, size));
|
||||
}
|
||||
else if (font instanceof InputStream)
|
||||
{
|
||||
g.setFont(Font.createFont(Font.TRUETYPE_FONT, (InputStream) font).deriveFont((float) size));
|
||||
}
|
||||
else if (font instanceof File)
|
||||
{
|
||||
g.setFont(Font.createFont(Font.TRUETYPE_FONT, (File) font).deriveFont((float) size));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
g.setColor(new Color(255, 255, 255, 0));
|
||||
g.fillRect(0, 0, 256, 256);
|
||||
g.setColor(Color.white);
|
||||
metrics = g.getFontMetrics();
|
||||
|
||||
// Draw the specified range of characters onto
|
||||
// the new bitmap, spacing according to the font
|
||||
// widths. Also allocating positions of characters
|
||||
// on the bitmap to two arrays which will be used
|
||||
// later when drawing.
|
||||
int x = 2;
|
||||
int y = 2;
|
||||
for (int i = startChar; i < endChar; i++)
|
||||
{
|
||||
g.drawString("" + ((char) i), x, y + g.getFontMetrics().getAscent());
|
||||
xPos[i - startChar] = x;
|
||||
yPos[i - startChar] = y - metrics.getMaxDescent();
|
||||
x += metrics.stringWidth("" + (char) i) + 2;
|
||||
if (x >= 250 - metrics.getMaxAdvance())
|
||||
{
|
||||
x = 2;
|
||||
y += metrics.getMaxAscent() + metrics.getMaxDescent() + size / 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Render the finished bitmap into the Minecraft
|
||||
// graphics engine.
|
||||
// Sadly broken by 1.6
|
||||
//texID = mc.renderEngine.allocateAndSetupTexture(img);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a given string with an automatically
|
||||
* calculated shadow below it.
|
||||
* @param gui The gui/subclass to be drawn on
|
||||
* @param text The string to be drawn
|
||||
* @param x The x position to start drawing
|
||||
* @param y The y position to start drawing
|
||||
* @param color The color of the non-shadowed text (Hex)
|
||||
*/
|
||||
public void drawStringS (Gui gui, String text, int x, int y, int color)
|
||||
{
|
||||
int l = color & 0xff000000;
|
||||
int shade = (color & 0xfcfcfc) >> 2;
|
||||
shade += l;
|
||||
drawString(gui, text, x + 1, y + 1, shade);
|
||||
drawString(gui, text, x, y, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a given string onto a gui/subclass.
|
||||
* @param gui The gui/subclass to be drawn on
|
||||
* @param text The string to be drawn
|
||||
* @param x The x position to start drawing
|
||||
* @param y The y position to start drawing
|
||||
* @param color The color of the non-shadowed text (Hex)
|
||||
*/
|
||||
public void drawString (Gui gui, String text, int x, int y, int color)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glEnable(3553 /*GL_TEXTURE_2D*/);
|
||||
GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, texID);
|
||||
float red = (float) (color >> 16 & 0xff) / 255F;
|
||||
float green = (float) (color >> 8 & 0xff) / 255F;
|
||||
float blue = (float) (color & 0xff) / 255F;
|
||||
float alpha = (float) (color >> 24 & 0xff) / 255F;
|
||||
GL11.glColor4f(red, green, blue, alpha);
|
||||
int startX = x;
|
||||
for (int i = 0; i < text.length(); i++)
|
||||
{
|
||||
char c = text.charAt(i);
|
||||
if (c == '\\')
|
||||
{
|
||||
char type = text.charAt(i + 1);
|
||||
if (type == 'n')
|
||||
{
|
||||
y += metrics.getAscent() + 2;
|
||||
x = startX;
|
||||
}
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
drawChar(gui, c, x, y);
|
||||
x += metrics.getStringBounds("" + c, null).getWidth();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the created FontMetrics
|
||||
* which is used to retrive various
|
||||
* information about the True Type Font
|
||||
* @return FontMetrics of the created font.
|
||||
*/
|
||||
public FontMetrics getMetrics ()
|
||||
{
|
||||
return metrics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the drawing width of a given
|
||||
* string of string.
|
||||
* @param text The string to be measured
|
||||
* @return The width of the given string.
|
||||
*/
|
||||
public int getStringWidth (String text)
|
||||
{
|
||||
return (int) getBounds(text).getWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the drawing height of a given
|
||||
* string of string.
|
||||
* @param text The string to be measured
|
||||
* @return The height of the given string.
|
||||
*/
|
||||
public int getStringHeight (String text)
|
||||
{
|
||||
return (int) getBounds(text).getHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* A method that returns a Rectangle that
|
||||
* contains the width and height demensions
|
||||
* of the given string.
|
||||
* @param text The string to be measured
|
||||
* @return Rectangle containing width and height that
|
||||
* the text will consume when drawn.
|
||||
*/
|
||||
private Rectangle getBounds (String text)
|
||||
{
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
int tw = 0;
|
||||
for (int i = 0; i < text.length(); i++)
|
||||
{
|
||||
char c = text.charAt(i);
|
||||
if (c == '\\')
|
||||
{
|
||||
char type = text.charAt(i + 1);
|
||||
|
||||
if (type == 'n')
|
||||
{
|
||||
h += metrics.getAscent() + 2;
|
||||
if (tw > w)
|
||||
w = tw;
|
||||
tw = 0;
|
||||
}
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
tw += metrics.stringWidth("" + c);
|
||||
}
|
||||
if (tw > w)
|
||||
w = tw;
|
||||
h += metrics.getAscent();
|
||||
return new Rectangle(0, 0, w, h);
|
||||
}
|
||||
|
||||
/**
|
||||
* Private drawing method used within other
|
||||
* drawing methods.
|
||||
*/
|
||||
private void drawChar (Gui gui, char c, int x, int y)
|
||||
{
|
||||
Rectangle2D bounds = metrics.getStringBounds("" + c, null);
|
||||
drawTexturedModalRect(x, y, xPos[(byte) c - startChar], yPos[(byte) c - startChar], (int) bounds.getWidth(), (int) bounds.getHeight() + metrics.getMaxDescent());
|
||||
}
|
||||
|
||||
public void drawTexturedModalRect (int x, int y, int u, int v, int width, int height)
|
||||
{
|
||||
float offsetWidth = 0.00390625F;
|
||||
float offsetHeight = 0.00390625F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV((x + 0), (y + height), 0, ((u + 0) * offsetWidth), ((v + height) * offsetHeight));
|
||||
tessellator.addVertexWithUV((x + width), (y + height), 0, ((u + width) * offsetWidth), ((v + height) * offsetHeight));
|
||||
tessellator.addVertexWithUV((x + width), (y + 0), 0, ((u + width) * offsetWidth), ((v + 0) * offsetHeight));
|
||||
tessellator.addVertexWithUV((x + 0), (y + 0), 0, ((u + 0) * offsetWidth), ((v + 0) * offsetHeight));
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,669 @@
|
||||
package tconstruct.client;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import tconstruct.client.block.SmallFontRenderer;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderItemCopy extends Render
|
||||
{
|
||||
private static final ResourceLocation field_110798_h = new ResourceLocation("textures/misc/enchanted_item_glint.png");
|
||||
private RenderBlocks itemRenderBlocks = new RenderBlocks();
|
||||
|
||||
/** The RNG used in RenderItem (for bobbing itemstacks on the ground) */
|
||||
private Random random = new Random();
|
||||
public boolean renderWithColor = true;
|
||||
|
||||
/** Defines the zLevel of rendering of item on GUI. */
|
||||
public float zLevel;
|
||||
public static boolean renderInFrame;
|
||||
|
||||
public RenderItemCopy()
|
||||
{
|
||||
this.shadowSize = 0.15F;
|
||||
this.shadowOpaque = 0.75F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the item
|
||||
*/
|
||||
public void doRenderItem (EntityItem par1EntityItem, double par2, double par4, double par6, float par8, float par9)
|
||||
{
|
||||
this.func_110777_b(par1EntityItem);
|
||||
this.random.setSeed(187L);
|
||||
ItemStack itemstack = par1EntityItem.getEntityItem();
|
||||
|
||||
if (itemstack.getItem() != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
float f2 = shouldBob() ? MathHelper.sin(((float) par1EntityItem.age + par9) / 10.0F + par1EntityItem.hoverStart) * 0.1F + 0.1F : 0F;
|
||||
float f3 = (((float) par1EntityItem.age + par9) / 20.0F + par1EntityItem.hoverStart) * (180F / (float) Math.PI);
|
||||
byte b0 = getMiniBlockCount(itemstack);
|
||||
|
||||
GL11.glTranslatef((float) par2, (float) par4 + f2, (float) par6);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
float f4;
|
||||
float f5;
|
||||
float f6;
|
||||
int i;
|
||||
|
||||
Block block = null;
|
||||
if (itemstack.itemID < Block.blocksList.length)
|
||||
{
|
||||
block = Block.blocksList[itemstack.itemID];
|
||||
}
|
||||
|
||||
if (ForgeHooksClient.renderEntityItem(par1EntityItem, itemstack, f2, f3, random, renderManager.renderEngine, renderBlocks))
|
||||
{
|
||||
;
|
||||
}
|
||||
else if (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(Block.blocksList[itemstack.itemID].getRenderType()))
|
||||
{
|
||||
GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
if (renderInFrame)
|
||||
{
|
||||
GL11.glScalef(1.25F, 1.25F, 1.25F);
|
||||
GL11.glTranslatef(0.0F, 0.05F, 0.0F);
|
||||
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
float f7 = 0.25F;
|
||||
int j = block.getRenderType();
|
||||
|
||||
if (j == 1 || j == 19 || j == 12 || j == 2)
|
||||
{
|
||||
f7 = 0.5F;
|
||||
}
|
||||
|
||||
GL11.glScalef(f7, f7, f7);
|
||||
|
||||
for (i = 0; i < b0; ++i)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
f5 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
|
||||
f4 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
|
||||
f6 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7;
|
||||
GL11.glTranslatef(f5, f4, f6);
|
||||
}
|
||||
|
||||
f5 = 1.0F;
|
||||
this.itemRenderBlocks.renderBlockAsItem(block, itemstack.getItemDamage(), f5);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float f8;
|
||||
|
||||
if (itemstack.getItemSpriteNumber() == 1 && itemstack.getItem().requiresMultipleRenderPasses())
|
||||
{
|
||||
if (renderInFrame)
|
||||
{
|
||||
GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
|
||||
GL11.glTranslatef(0.0F, -0.05F, 0.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
|
||||
for (int k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k)
|
||||
{
|
||||
this.random.setSeed(187L);
|
||||
Icon icon = itemstack.getItem().getIcon(itemstack, k);
|
||||
f8 = 1.0F;
|
||||
|
||||
if (this.renderWithColor)
|
||||
{
|
||||
i = Item.itemsList[itemstack.itemID].getColorFromItemStack(itemstack, k);
|
||||
f5 = (float) (i >> 16 & 255) / 255.0F;
|
||||
f4 = (float) (i >> 8 & 255) / 255.0F;
|
||||
f6 = (float) (i & 255) / 255.0F;
|
||||
GL11.glColor4f(f5 * f8, f4 * f8, f6 * f8, 1.0F);
|
||||
this.renderDroppedItem(par1EntityItem, icon, b0, par9, f5 * f8, f4 * f8, f6 * f8, k);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.renderDroppedItem(par1EntityItem, icon, b0, par9, 1.0F, 1.0F, 1.0F, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (renderInFrame)
|
||||
{
|
||||
GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
|
||||
GL11.glTranslatef(0.0F, -0.05F, 0.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
|
||||
Icon icon1 = itemstack.getIconIndex();
|
||||
|
||||
if (this.renderWithColor)
|
||||
{
|
||||
int l = Item.itemsList[itemstack.itemID].getColorFromItemStack(itemstack, 0);
|
||||
f8 = (float) (l >> 16 & 255) / 255.0F;
|
||||
float f9 = (float) (l >> 8 & 255) / 255.0F;
|
||||
f5 = (float) (l & 255) / 255.0F;
|
||||
f4 = 1.0F;
|
||||
this.renderDroppedItem(par1EntityItem, icon1, b0, par9, f8 * f4, f9 * f4, f5 * f4);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.renderDroppedItem(par1EntityItem, icon1, b0, par9, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
protected ResourceLocation func_110796_a (EntityItem par1EntityItem)
|
||||
{
|
||||
return this.renderManager.renderEngine.func_130087_a(par1EntityItem.getEntityItem().getItemSpriteNumber());
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a dropped item
|
||||
*/
|
||||
private void renderDroppedItem (EntityItem par1EntityItem, Icon par2Icon, int par3, float par4, float par5, float par6, float par7)
|
||||
{
|
||||
renderDroppedItem(par1EntityItem, par2Icon, par3, par4, par5, par6, par7, 0);
|
||||
}
|
||||
|
||||
private void renderDroppedItem (EntityItem par1EntityItem, Icon par2Icon, int par3, float par4, float par5, float par6, float par7, int pass)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
if (par2Icon == null)
|
||||
{
|
||||
TextureManager texturemanager = Minecraft.getMinecraft().func_110434_K();
|
||||
ResourceLocation resourcelocation = texturemanager.func_130087_a(par1EntityItem.getEntityItem().getItemSpriteNumber());
|
||||
par2Icon = ((TextureMap) texturemanager.func_110581_b(resourcelocation)).func_110572_b("missingno");
|
||||
}
|
||||
|
||||
float f4 = ((Icon) par2Icon).getMinU();
|
||||
float f5 = ((Icon) par2Icon).getMaxU();
|
||||
float f6 = ((Icon) par2Icon).getMinV();
|
||||
float f7 = ((Icon) par2Icon).getMaxV();
|
||||
float f8 = 1.0F;
|
||||
float f9 = 0.5F;
|
||||
float f10 = 0.25F;
|
||||
float f11;
|
||||
|
||||
if (this.renderManager.options.fancyGraphics)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if (renderInFrame)
|
||||
{
|
||||
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glRotatef((((float) par1EntityItem.age + par4) / 20.0F + par1EntityItem.hoverStart) * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
float f12 = 0.0625F;
|
||||
f11 = 0.021875F;
|
||||
ItemStack itemstack = par1EntityItem.getEntityItem();
|
||||
int j = itemstack.stackSize;
|
||||
byte b0 = getMiniItemCount(itemstack);
|
||||
|
||||
GL11.glTranslatef(-f9, -f10, -((f12 + f11) * (float) b0 / 2.0F));
|
||||
|
||||
for (int k = 0; k < b0; ++k)
|
||||
{
|
||||
// Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug...
|
||||
if (k > 0 && shouldSpreadItems())
|
||||
{
|
||||
float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
||||
float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
||||
float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
||||
GL11.glTranslatef(x, y, f12 + f11);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glTranslatef(0f, 0f, f12 + f11);
|
||||
}
|
||||
|
||||
if (itemstack.getItemSpriteNumber() == 0)
|
||||
{
|
||||
this.func_110776_a(TextureMap.field_110575_b);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.func_110776_a(TextureMap.field_110576_c);
|
||||
}
|
||||
|
||||
GL11.glColor4f(par5, par6, par7, 1.0F);
|
||||
ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, ((Icon) par2Icon).getOriginX(), ((Icon) par2Icon).getOriginY(), f12);
|
||||
|
||||
if (itemstack.hasEffect(pass))
|
||||
{
|
||||
GL11.glDepthFunc(GL11.GL_EQUAL);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
this.renderManager.renderEngine.func_110577_a(field_110798_h);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
|
||||
float f13 = 0.76F;
|
||||
GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F);
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glPushMatrix();
|
||||
float f14 = 0.125F;
|
||||
GL11.glScalef(f14, f14, f14);
|
||||
float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
|
||||
GL11.glTranslatef(f15, 0.0F, 0.0F);
|
||||
GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
|
||||
ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(f14, f14, f14);
|
||||
f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
|
||||
GL11.glTranslatef(-f15, 0.0F, 0.0F);
|
||||
GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
|
||||
ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int l = 0; l < par3; ++l)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if (l > 0)
|
||||
{
|
||||
f11 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
|
||||
float f16 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
|
||||
float f17 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
|
||||
GL11.glTranslatef(f11, f16, f17);
|
||||
}
|
||||
|
||||
if (!renderInFrame)
|
||||
{
|
||||
GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
GL11.glColor4f(par5, par6, par7, 1.0F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
tessellator.addVertexWithUV((double) (0.0F - f9), (double) (0.0F - f10), 0.0D, (double) f4, (double) f7);
|
||||
tessellator.addVertexWithUV((double) (f8 - f9), (double) (0.0F - f10), 0.0D, (double) f5, (double) f7);
|
||||
tessellator.addVertexWithUV((double) (f8 - f9), (double) (1.0F - f10), 0.0D, (double) f5, (double) f6);
|
||||
tessellator.addVertexWithUV((double) (0.0F - f9), (double) (1.0F - f10), 0.0D, (double) f4, (double) f6);
|
||||
tessellator.draw();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the item's icon or block into the UI at the specified position.
|
||||
*/
|
||||
public void renderItemIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
|
||||
{
|
||||
renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, false);
|
||||
}
|
||||
|
||||
public void renderItemIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, boolean renderEffect)
|
||||
{
|
||||
int k = par3ItemStack.itemID;
|
||||
int l = par3ItemStack.getItemDamage();
|
||||
Object object = par3ItemStack.getIconIndex();
|
||||
float f;
|
||||
int i1;
|
||||
float f1;
|
||||
float f2;
|
||||
|
||||
Block block = (k < Block.blocksList.length ? Block.blocksList[k] : null);
|
||||
if (par3ItemStack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(Block.blocksList[k].getRenderType()))
|
||||
{
|
||||
par2TextureManager.func_110577_a(TextureMap.field_110575_b);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) (par4 - 2), (float) (par5 + 3), -3.0F + this.zLevel);
|
||||
GL11.glScalef(10.0F, 10.0F, 10.0F);
|
||||
GL11.glTranslatef(1.0F, 0.5F, 1.0F);
|
||||
GL11.glScalef(1.0F, 1.0F, -1.0F);
|
||||
GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
||||
i1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, 0);
|
||||
f = (float) (i1 >> 16 & 255) / 255.0F;
|
||||
f1 = (float) (i1 >> 8 & 255) / 255.0F;
|
||||
f2 = (float) (i1 & 255) / 255.0F;
|
||||
|
||||
if (this.renderWithColor)
|
||||
{
|
||||
GL11.glColor4f(f, f1, f2, 1.0F);
|
||||
}
|
||||
|
||||
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
|
||||
this.itemRenderBlocks.useInventoryTint = this.renderWithColor;
|
||||
this.itemRenderBlocks.renderBlockAsItem(block, l, 1.0F);
|
||||
this.itemRenderBlocks.useInventoryTint = true;
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else if (Item.itemsList[k].requiresMultipleRenderPasses())
|
||||
{
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
for (int j1 = 0; j1 < Item.itemsList[k].getRenderPasses(l); ++j1)
|
||||
{
|
||||
par2TextureManager.func_110577_a(par3ItemStack.getItemSpriteNumber() == 0 ? TextureMap.field_110575_b : TextureMap.field_110576_c);
|
||||
Icon icon = Item.itemsList[k].getIcon(par3ItemStack, j1);
|
||||
int k1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, j1);
|
||||
f1 = (float) (k1 >> 16 & 255) / 255.0F;
|
||||
f2 = (float) (k1 >> 8 & 255) / 255.0F;
|
||||
float f3 = (float) (k1 & 255) / 255.0F;
|
||||
|
||||
if (this.renderWithColor)
|
||||
{
|
||||
GL11.glColor4f(f1, f2, f3, 1.0F);
|
||||
}
|
||||
|
||||
this.renderIcon(par4, par5, icon, 16, 16);
|
||||
|
||||
if (par3ItemStack.hasEffect(j1))
|
||||
{
|
||||
renderEffect(par2TextureManager, par4, par5);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
ResourceLocation resourcelocation = par2TextureManager.func_130087_a(par3ItemStack.getItemSpriteNumber());
|
||||
par2TextureManager.func_110577_a(resourcelocation);
|
||||
|
||||
if (object == null)
|
||||
{
|
||||
object = ((TextureMap) Minecraft.getMinecraft().func_110434_K().func_110581_b(resourcelocation)).func_110572_b("missingno");
|
||||
}
|
||||
|
||||
i1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, 0);
|
||||
f = (float) (i1 >> 16 & 255) / 255.0F;
|
||||
f1 = (float) (i1 >> 8 & 255) / 255.0F;
|
||||
f2 = (float) (i1 & 255) / 255.0F;
|
||||
|
||||
if (this.renderWithColor)
|
||||
{
|
||||
GL11.glColor4f(f, f1, f2, 1.0F);
|
||||
}
|
||||
|
||||
this.renderIcon(par4, par5, (Icon) object, 16, 16);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
|
||||
if (par3ItemStack.hasEffect(0))
|
||||
{
|
||||
renderEffect(par2TextureManager, par4, par5);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
}
|
||||
|
||||
private void renderEffect (TextureManager manager, int x, int y)
|
||||
{
|
||||
GL11.glDepthFunc(GL11.GL_GREATER);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthMask(false);
|
||||
manager.func_110577_a(field_110798_h);
|
||||
this.zLevel -= 50.0F;
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR);
|
||||
GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
|
||||
this.renderGlint(x * 431278612 + y * 32178161, x - 2, y - 2, 20, 20);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDepthMask(true);
|
||||
this.zLevel += 50.0F;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the item's icon or block into the GUI, including the glint effect.
|
||||
*/
|
||||
public void renderItemAndEffectIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
|
||||
{
|
||||
if (par3ItemStack != null)
|
||||
{
|
||||
if (!ForgeHooksClient.renderInventoryItem(renderBlocks, par2TextureManager, par3ItemStack, renderWithColor, zLevel, (float) par4, (float) par5))
|
||||
{
|
||||
this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, true);
|
||||
}
|
||||
|
||||
/* Modders must handle this themselves if they use custom renderers!
|
||||
if (par3ItemStack.hasEffect())
|
||||
{
|
||||
GL11.glDepthFunc(GL11.GL_GREATER);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthMask(false);
|
||||
par2TextureManager.func_110577_a(field_110798_h);
|
||||
this.zLevel -= 50.0F;
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR);
|
||||
GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
|
||||
this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDepthMask(true);
|
||||
this.zLevel += 50.0F;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
private void renderGlint (int par1, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
for (int j1 = 0; j1 < 2; ++j1)
|
||||
{
|
||||
if (j1 == 0)
|
||||
{
|
||||
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
|
||||
}
|
||||
|
||||
if (j1 == 1)
|
||||
{
|
||||
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
|
||||
}
|
||||
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
float f2 = (float) (Minecraft.getSystemTime() % (long) (3000 + j1 * 1873)) / (3000.0F + (float) (j1 * 1873)) * 256.0F;
|
||||
float f3 = 0.0F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
float f4 = 4.0F;
|
||||
|
||||
if (j1 == 1)
|
||||
{
|
||||
f4 = -1.0F;
|
||||
}
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par5 * f4) * f), (double) ((f3 + (float) par5) * f1));
|
||||
tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par4 + (float) par5 * f4) * f),
|
||||
(double) ((f3 + (float) par5) * f1));
|
||||
tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + (float) par4) * f), (double) ((f3 + 0.0F) * f1));
|
||||
tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1));
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the item's overlay information. Examples being stack count or damage on top of the item's image at the
|
||||
* specified position.
|
||||
*/
|
||||
public void renderItemOverlayIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
|
||||
{
|
||||
this.renderItemOverlayIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, (String) null);
|
||||
}
|
||||
|
||||
public void renderItemOverlayIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, String par6Str)
|
||||
{
|
||||
if (par3ItemStack != null)
|
||||
{
|
||||
if (par3ItemStack.stackSize > 1 || par6Str != null)
|
||||
{
|
||||
String s1 = par6Str == null ? String.valueOf(par3ItemStack.stackSize) : par6Str;
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
par1FontRenderer.drawStringWithShadow(s1, par4 + 19 - 2 - par1FontRenderer.getStringWidth(s1), par5 + 6 + 3, 16777215);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
if (par3ItemStack.isItemDamaged())
|
||||
{
|
||||
int k = (int) Math.round(13.0D - (double) par3ItemStack.getItemDamageForDisplay() * 13.0D / (double) par3ItemStack.getMaxDamage());
|
||||
int l = (int) Math.round(255.0D - (double) par3ItemStack.getItemDamageForDisplay() * 255.0D / (double) par3ItemStack.getMaxDamage());
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
int i1 = 255 - l << 16 | l << 8;
|
||||
int j1 = (255 - l) / 4 << 16 | 16128;
|
||||
this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0);
|
||||
this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, j1);
|
||||
this.renderQuad(tessellator, par4 + 2, par5 + 13, k, 1, i1);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a quad to the tesselator at the specified position with the set width and height and color. Args:
|
||||
* tessellator, x, y, width, height, color
|
||||
*/
|
||||
private void renderQuad (Tessellator par1Tessellator, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
par1Tessellator.startDrawingQuads();
|
||||
par1Tessellator.setColorOpaque_I(par6);
|
||||
par1Tessellator.addVertex((double) (par2 + 0), (double) (par3 + 0), 0.0D);
|
||||
par1Tessellator.addVertex((double) (par2 + 0), (double) (par3 + par5), 0.0D);
|
||||
par1Tessellator.addVertex((double) (par2 + par4), (double) (par3 + par5), 0.0D);
|
||||
par1Tessellator.addVertex((double) (par2 + par4), (double) (par3 + 0), 0.0D);
|
||||
par1Tessellator.draw();
|
||||
}
|
||||
|
||||
public void renderIcon (int par1, int par2, Icon par3Icon, int par4, int par5)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMaxV());
|
||||
tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMaxV());
|
||||
tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMinV());
|
||||
tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMinV());
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
protected ResourceLocation func_110775_a (Entity par1Entity)
|
||||
{
|
||||
return this.func_110796_a((EntityItem) par1Entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
|
||||
* handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
|
||||
* (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
|
||||
* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
|
||||
*/
|
||||
public void doRender (Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
|
||||
{
|
||||
this.doRenderItem((EntityItem) par1Entity, par2, par4, par6, par8, par9);
|
||||
}
|
||||
|
||||
/**
|
||||
* Items should spread out when rendered in 3d?
|
||||
* @return
|
||||
*/
|
||||
public boolean shouldSpreadItems ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Items should have a bob effect
|
||||
* @return
|
||||
*/
|
||||
public boolean shouldBob ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public byte getMiniBlockCount (ItemStack stack)
|
||||
{
|
||||
byte ret = 1;
|
||||
if (stack.stackSize > 1)
|
||||
ret = 2;
|
||||
if (stack.stackSize > 5)
|
||||
ret = 3;
|
||||
if (stack.stackSize > 20)
|
||||
ret = 4;
|
||||
if (stack.stackSize > 40)
|
||||
ret = 5;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows for a subclass to override how many rendered items appear in a
|
||||
* "mini item 3d stack"
|
||||
* @param stack
|
||||
* @return
|
||||
*/
|
||||
public byte getMiniItemCount (ItemStack stack)
|
||||
{
|
||||
byte ret = 1;
|
||||
if (stack.stackSize > 1)
|
||||
ret = 2;
|
||||
if (stack.stackSize > 15)
|
||||
ret = 3;
|
||||
if (stack.stackSize > 31)
|
||||
ret = 4;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package tconstruct.client;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
public class SuperSoakerRender implements IItemRenderer
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType (ItemStack item, ItemRenderType type)
|
||||
{
|
||||
return type != ItemRenderType.INVENTORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper (ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem (ItemRenderType type, ItemStack item, Object... data)
|
||||
{
|
||||
if (type == ItemRenderType.EQUIPPED)
|
||||
renderEquippedItem(item, (RenderBlocks) data[0], (EntityLiving) data[1]);
|
||||
if (type == ItemRenderType.ENTITY)
|
||||
renderEntityItem(item, (RenderBlocks) data[0], (EntityItem) data[1]);
|
||||
}
|
||||
|
||||
void renderEquippedItem (ItemStack item, RenderBlocks renderBlocks, EntityLiving entityLiving)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void renderEntityItem (ItemStack item, RenderBlocks renderBlocks, EntityItem entityItem)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package tconstruct.client;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.LiquidMetalFinite;
|
||||
import tconstruct.client.armor.WingModel;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.util.player.TPlayerStats;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TClientEvents
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
/*@ForgeSubscribe
|
||||
public void interact (PlayerInteractEvent event)
|
||||
{
|
||||
if (event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote)
|
||||
{
|
||||
System.out.println("Fired");
|
||||
List<Skill> skills = TProxyClient.skillList;
|
||||
if (skills.size() > 0)
|
||||
{
|
||||
Skill walls = TConstruct.playerTracker.getPlayerStats(event.entityPlayer.username).skillList.get(0);
|
||||
walls.rightClickActivate(event.entityPlayer, event.entityPlayer.worldObj);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/* Sounds */
|
||||
/*@ForgeSubscribe
|
||||
public void onSound (SoundLoadEvent event)
|
||||
{
|
||||
try
|
||||
{
|
||||
event.manager.soundPoolSounds.addSound("sounds/frypan_hit.ogg", TConstruct.class.getResource("/sounds/frypan_hit.ogg"));
|
||||
event.manager.soundPoolSounds.addSound("sounds/little_saw.ogg", TConstruct.class.getResource("/sounds/little_saw.ogg"));
|
||||
event.manager.soundPoolSounds.addSound("sounds/launcher_clank.ogg", TConstruct.class.getResource("/sounds/launcher_clank.ogg"));
|
||||
System.out.println("[TConstruct] Successfully loaded sounds.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("[TConstruct] Failed to register one or more sounds");
|
||||
}
|
||||
}*/
|
||||
|
||||
/* Liquids */
|
||||
@ForgeSubscribe
|
||||
public void postStitch (TextureStitchEvent.Post event)
|
||||
{
|
||||
for (int i = 0; i < TContent.fluids.length; i++)
|
||||
{
|
||||
if (TContent.fluidBlocks[i] instanceof LiquidMetalFinite)
|
||||
{
|
||||
LiquidMetalFinite block = (LiquidMetalFinite) TContent.fluidBlocks[i];
|
||||
TContent.fluids[i].setIcons(block.stillIcon, block.flowIcon);
|
||||
}
|
||||
Fluid lava = FluidRegistry.getFluid("lava");
|
||||
lava.setIcons(Block.lavaStill.getIcon(0, 0), Block.lavaStill.getIcon(2, 0));
|
||||
Fluid lavawater = FluidRegistry.getFluid("water");
|
||||
lava.setIcons(Block.waterStill.getIcon(0, 0), Block.waterStill.getIcon(2, 0));
|
||||
}
|
||||
}
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/newhearts.png");
|
||||
|
||||
/* HUD */
|
||||
@ForgeSubscribe
|
||||
public void renderHealthbar (RenderGameOverlayEvent.Post event)
|
||||
{
|
||||
ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight);
|
||||
int scaledWidth = scaledresolution.getScaledWidth();
|
||||
int scaledHeight = scaledresolution.getScaledHeight();
|
||||
int xBasePos = scaledWidth / 2 - 91;
|
||||
int yBasePos = scaledHeight - 39;
|
||||
TPlayerStats stats = TConstruct.playerTracker.getPlayerStats(mc.thePlayer.username);
|
||||
|
||||
PotionEffect potion = mc.thePlayer.getActivePotionEffect(Potion.wither);
|
||||
if (potion != null)
|
||||
return;
|
||||
potion = mc.thePlayer.getActivePotionEffect(Potion.poison);
|
||||
if (potion != null)
|
||||
return;
|
||||
|
||||
/*if (event.type == RenderGameOverlayEvent.ElementType.HEALTH)
|
||||
{
|
||||
this.mc.func_110434_K().func_110577_a(background);
|
||||
|
||||
int hp = mc.thePlayer.getHealth();
|
||||
for (int iter = 0; iter < hp / 20; iter++)
|
||||
{
|
||||
int renderHearts = (hp - 20 * (iter + 1)) / 2;
|
||||
if (renderHearts > 10)
|
||||
renderHearts = 10;
|
||||
for (int i = 0; i < renderHearts; i++)
|
||||
{
|
||||
this.drawTexturedModalRect(xBasePos + 8 * i, yBasePos, 0 + 18 * iter, 0, 8, 8);
|
||||
}
|
||||
if (hp % 2 == 1 && renderHearts < 10)
|
||||
{
|
||||
this.drawTexturedModalRect(xBasePos + 8 * renderHearts, yBasePos, 9 + 18 * iter, 0, 8, 8);
|
||||
}
|
||||
}
|
||||
|
||||
this.mc.renderEngine.bindTexture("/gui/icons.png");
|
||||
}*/
|
||||
|
||||
/*if (event.type == RenderGameOverlayEvent.ElementType.HOTBAR)
|
||||
{
|
||||
if (stats.skillList == null)
|
||||
return;
|
||||
|
||||
int amount = 0;
|
||||
GL11.glScalef(1/16f, 1/16f, 1/16f);
|
||||
for (Skill skill : stats.skillList)
|
||||
{
|
||||
if (!skill.getActive())
|
||||
GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0F);
|
||||
this.mc.renderEngine.bindTexture(skill.getTextureFile(scaledresolution.getScaleFactor()));
|
||||
this.drawTexturedModalRect((2+amount*18)*16, 32, 0, 0, 256, 256);
|
||||
amount++;
|
||||
}
|
||||
GL11.glScalef(16f, 16f, 16f);
|
||||
}*/
|
||||
}
|
||||
|
||||
public void drawTexturedModalRect (int par1, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + par6), (double) this.zLevel, (double) ((float) (par3 + 0) * f), (double) ((float) (par4 + par6) * f1));
|
||||
tessellator.addVertexWithUV((double) (par1 + par5), (double) (par2 + par6), (double) this.zLevel, (double) ((float) (par3 + par5) * f), (double) ((float) (par4 + par6) * f1));
|
||||
tessellator.addVertexWithUV((double) (par1 + par5), (double) (par2 + 0), (double) this.zLevel, (double) ((float) (par3 + par5) * f), (double) ((float) (par4 + 0) * f1));
|
||||
tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) ((float) (par3 + 0) * f), (double) ((float) (par4 + 0) * f1));
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
double zLevel = 0;
|
||||
|
||||
/* Armor */
|
||||
ModelBiped model = new ModelBiped(5f);
|
||||
WingModel wings = new WingModel();
|
||||
|
||||
/*static
|
||||
{
|
||||
model.bipedHead.showModel = false;
|
||||
}*/
|
||||
|
||||
private float interpolateRotation (float par1, float par2, float par3)
|
||||
{
|
||||
float f3;
|
||||
|
||||
for (f3 = par2 - par1; f3 < -180.0F; f3 += 360.0F)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
while (f3 >= 180.0F)
|
||||
{
|
||||
f3 -= 360.0F;
|
||||
}
|
||||
|
||||
return par1 + par3 * f3;
|
||||
}
|
||||
|
||||
protected float handleRotationFloat (EntityLiving par1EntityLiving, float par2)
|
||||
{
|
||||
return (float) par1EntityLiving.ticksExisted + par2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package tconstruct.client;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import tconstruct.common.TContent;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
public class TClientTickHandler implements ITickHandler
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
EntityPlayer player;
|
||||
int zLevel = 0;
|
||||
int ticks = 0;
|
||||
|
||||
@Override
|
||||
public void tickEnd (EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
TContent.oreBerry.setGraphicsLevel(Block.leaves.graphicsLevel);
|
||||
TContent.oreBerrySecond.setGraphicsLevel(Block.leaves.graphicsLevel);
|
||||
|
||||
/*player = mc.thePlayer;
|
||||
if (player == null || player.capabilities.isCreativeMode)
|
||||
return;
|
||||
|
||||
ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight);
|
||||
int scaledWidth = scaledresolution.getScaledWidth();
|
||||
int scaledHeight = scaledresolution.getScaledHeight();
|
||||
int xBasePos = scaledWidth / 2 - 91;
|
||||
int yBasePos = scaledHeight - 39;
|
||||
this.mc.renderEngine.bindTexture("/mods/tinker/textures/gui/newhearts.png");
|
||||
|
||||
int hp = player.getHealth();
|
||||
for (int iter = 0; iter < hp / 20; iter++)
|
||||
{
|
||||
int renderHearts = (hp - 20*(iter+1)) / 2;
|
||||
if (renderHearts > 10)
|
||||
renderHearts = 10;
|
||||
for (int i = 0; i < renderHearts; i++)
|
||||
{
|
||||
this.drawTexturedModalRect(xBasePos + 8*i, yBasePos, 0 + 18*iter, 0, 8, 8);
|
||||
}
|
||||
if (hp % 2 == 1 && renderHearts < 10)
|
||||
{
|
||||
this.drawTexturedModalRect(xBasePos + 8*renderHearts, yBasePos, 9 + 18*iter, 0, 8, 8);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks ()
|
||||
{
|
||||
return EnumSet.of(TickType.RENDER);
|
||||
//return EnumSet.of(TickType.PLAYER);
|
||||
}
|
||||
|
||||
public void drawTexturedModalRect (int par1, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + par6), (double) this.zLevel, (double) ((float) (par3 + 0) * f), (double) ((float) (par4 + par6) * f1));
|
||||
tessellator.addVertexWithUV((double) (par1 + par5), (double) (par2 + par6), (double) this.zLevel, (double) ((float) (par3 + par5) * f), (double) ((float) (par4 + par6) * f1));
|
||||
tessellator.addVertexWithUV((double) (par1 + par5), (double) (par2 + 0), (double) this.zLevel, (double) ((float) (par3 + par5) * f), (double) ((float) (par4 + 0) * f1));
|
||||
tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) ((float) (par3 + 0) * f), (double) ((float) (par4 + 0) * f1));
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickStart (EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel ()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
package tconstruct.client;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
|
||||
public class TControls extends TKeyHandler
|
||||
{
|
||||
//static KeyBinding grabKey = new KeyBinding("key.grab", 29);
|
||||
//static KeyBinding stiltsKey = new KeyBinding("key.stilts", 46);
|
||||
public static KeyBinding armorKey = new KeyBinding("key.tarmor", 24);
|
||||
/*public static KeyBinding skillOne = new KeyBinding("key.skill.one", 44);
|
||||
public static KeyBinding skillTwo = new KeyBinding("key.skill.two", 45);
|
||||
public static KeyBinding skillThree = new KeyBinding("key.skill.three", 46);
|
||||
public static KeyBinding skillFour = new KeyBinding("key.skill.four", 47);
|
||||
public static KeyBinding skillFive = new KeyBinding("key.skill.five", 48);*/
|
||||
static KeyBinding jumpKey;
|
||||
static KeyBinding invKey;
|
||||
static Minecraft mc;
|
||||
|
||||
boolean jumping;
|
||||
boolean doubleJump = true;
|
||||
boolean climbing = false;
|
||||
boolean onGround = false;
|
||||
boolean onStilts = false;
|
||||
|
||||
int currentTab = 1;
|
||||
|
||||
//boolean onStilts = false;
|
||||
|
||||
public TControls()
|
||||
{
|
||||
super(new KeyBinding[] { armorKey /*, skillOne, skillTwo, skillThree, skillFour, skillFive*/}, new boolean[] { false /*, false, false, false, false, false*/}, getVanillaKeyBindings(),
|
||||
new boolean[] { false, false });
|
||||
//System.out.println("Controls registered");Natura
|
||||
}
|
||||
|
||||
private static KeyBinding[] getVanillaKeyBindings ()
|
||||
{
|
||||
mc = Minecraft.getMinecraft();
|
||||
jumpKey = mc.gameSettings.keyBindJump;
|
||||
invKey = mc.gameSettings.keyBindInventory;
|
||||
return new KeyBinding[] { jumpKey, invKey };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyDown (EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat)
|
||||
{
|
||||
if (tickEnd && mc.theWorld != null)
|
||||
{
|
||||
if (kb == armorKey && mc.currentScreen == null) //Extended Armor
|
||||
{
|
||||
openArmorGui();//mc.thePlayer.username);
|
||||
}
|
||||
if (kb == invKey && mc.currentScreen != null && mc.currentScreen.getClass() == GuiInventory.class)// && !mc.playerController.isInCreativeMode())
|
||||
{
|
||||
TProxyClient.addTabsToInventory((GuiContainer) mc.currentScreen);
|
||||
}
|
||||
/*if (kb == skillOne)
|
||||
{
|
||||
sendSkillkey(mc.thePlayer, (byte) 0);//, mc.thePlayer.dimension, mc.thePlayer.entityId);
|
||||
}
|
||||
if (kb == skillTwo)
|
||||
{
|
||||
sendSkillkey(mc.thePlayer, (byte) 1);//, mc.thePlayer.dimension, mc.thePlayer.entityId);
|
||||
}
|
||||
if (kb == skillThree)
|
||||
{
|
||||
sendSkillkey(mc.thePlayer, (byte) 2);//, mc.thePlayer.dimension, mc.thePlayer.entityId);
|
||||
}
|
||||
if (kb == skillFour)
|
||||
{
|
||||
sendSkillkey(mc.thePlayer, (byte) 3);//, mc.thePlayer.dimension, mc.thePlayer.entityId);
|
||||
}
|
||||
if (kb == skillFive)
|
||||
{
|
||||
sendSkillkey(mc.thePlayer, (byte) 4);//, mc.thePlayer.dimension, mc.thePlayer.entityId);
|
||||
}*/
|
||||
/*if (kb == jumpKey) //Double jump
|
||||
{
|
||||
if (jumping && !doubleJump)
|
||||
{
|
||||
//if (player == null)
|
||||
//player = mc.thePlayer;
|
||||
|
||||
mc.thePlayer.motionY = 0.42D;
|
||||
mc.thePlayer.fallDistance = 0;
|
||||
|
||||
if (mc.thePlayer.isPotionActive(Potion.jump))
|
||||
{
|
||||
mc.thePlayer.motionY += (double) ((float) (mc.thePlayer.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);
|
||||
}
|
||||
|
||||
doubleJump = true;
|
||||
resetFallDamage(mc.thePlayer.username);
|
||||
}
|
||||
|
||||
if (!jumping)
|
||||
jumping = mc.thePlayer.isAirBorne;
|
||||
}*/
|
||||
}
|
||||
/*else if (kb == stiltsKey) //Stilts
|
||||
{
|
||||
float size = 1.8F;
|
||||
if (!onStilts)
|
||||
size = 0.8F;
|
||||
TConstruct.playerTracker.updateSize(mc.thePlayer.username, size);
|
||||
onStilts = !onStilts;
|
||||
//updateServer(mc.thePlayer.username, (byte) 11);
|
||||
if (onStilts)
|
||||
{
|
||||
onStilts = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
onStilts = true;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyUp (EnumSet<TickType> types, KeyBinding kb, boolean tickEnd)
|
||||
{
|
||||
//landOnGround();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks ()
|
||||
{
|
||||
return EnumSet.of(TickType.CLIENT);
|
||||
}
|
||||
|
||||
public void landOnGround ()
|
||||
{
|
||||
doubleJump = false;
|
||||
jumping = false;
|
||||
}
|
||||
|
||||
public void resetControls ()
|
||||
{
|
||||
doubleJump = false;
|
||||
jumping = false;
|
||||
climbing = false;
|
||||
onGround = false;
|
||||
onStilts = false;
|
||||
}
|
||||
|
||||
void resetFallDamage (String name)
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
try
|
||||
{
|
||||
outputStream.writeByte(10);
|
||||
outputStream.writeUTF(name);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
updateServer(bos);
|
||||
}
|
||||
|
||||
void updateSize (String name, float size)
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
try
|
||||
{
|
||||
outputStream.writeByte(11);
|
||||
outputStream.writeUTF(name);
|
||||
outputStream.writeFloat(size);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
updateServer(bos);
|
||||
}
|
||||
|
||||
public static void openInventoryGui ()
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
try
|
||||
{
|
||||
outputStream.writeByte(3);
|
||||
outputStream.writeByte(0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
updateServer(bos);
|
||||
}
|
||||
|
||||
public static void openArmorGui ()
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
try
|
||||
{
|
||||
outputStream.writeByte(3);
|
||||
outputStream.writeByte(1);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
updateServer(bos);
|
||||
}
|
||||
|
||||
public static void openKnapsackGui ()
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
try
|
||||
{
|
||||
outputStream.writeByte(3);
|
||||
outputStream.writeByte(2);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
updateServer(bos);
|
||||
}
|
||||
|
||||
/*public void activateSkill (EntityPlayer player, int slot)
|
||||
{
|
||||
if (TProxyClient.skillList.size() > slot)
|
||||
{
|
||||
Skill skill = TProxyClient.skillList.get(slot);
|
||||
if (skill != null)
|
||||
{
|
||||
skill.activate(player, player.worldObj);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public void sendSkillkey (EntityPlayer player, byte key)
|
||||
{
|
||||
TConstruct.playerTracker.activateSkill(player, key);
|
||||
|
||||
System.out.println(MinecraftServer.getServer());
|
||||
if (MinecraftServer.getServer().isDedicatedServer())
|
||||
{
|
||||
System.out.println("Send");
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
|
||||
DataOutputStream outputStream = new DataOutputStream(bos);
|
||||
try
|
||||
{
|
||||
outputStream.writeByte(4);
|
||||
outputStream.writeByte(key);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
updateServer(bos);
|
||||
}
|
||||
}
|
||||
|
||||
static void updateServer (ByteArrayOutputStream bos)
|
||||
{
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.channel = "TConstruct";
|
||||
packet.data = bos.toByteArray();
|
||||
packet.length = bos.size();
|
||||
|
||||
PacketDispatcher.sendPacketToServer(packet);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package tconstruct.client;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
public abstract class TKeyHandler implements ITickHandler
|
||||
{
|
||||
public KeyBinding[] keyBindings;
|
||||
public KeyBinding[] vKeyBindings;
|
||||
public boolean[] keyDown;
|
||||
public boolean[] repeatings;
|
||||
public boolean[] vRepeatings;
|
||||
public boolean isDummy;
|
||||
|
||||
/**
|
||||
* Pass an array of keybindings and a repeat flag for each one
|
||||
*
|
||||
* @param keyBindings
|
||||
* @param repeatings
|
||||
*/
|
||||
public TKeyHandler(KeyBinding[] keyBindings, boolean[] repeatings, KeyBinding[] vanillaKeys, boolean[] vanillaRepeatings)
|
||||
{
|
||||
assert keyBindings.length == repeatings.length : "You need to pass two arrays of identical length";
|
||||
assert vanillaKeys.length == vanillaRepeatings.length : "You need to pass two arrays of identical length";
|
||||
this.keyBindings = keyBindings;
|
||||
this.repeatings = repeatings;
|
||||
this.vKeyBindings = vanillaKeys;
|
||||
this.vRepeatings = vanillaRepeatings;
|
||||
this.keyDown = new boolean[keyBindings.length + vanillaKeys.length];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the keys into the system. You will do your own keyboard management elsewhere. No events will fire
|
||||
* if you use this method
|
||||
*
|
||||
* @param keyBindings
|
||||
*/
|
||||
public TKeyHandler(KeyBinding[] keyBindings)
|
||||
{
|
||||
this.keyBindings = keyBindings;
|
||||
this.isDummy = true;
|
||||
}
|
||||
|
||||
public KeyBinding[] getKeyBindings ()
|
||||
{
|
||||
return this.keyBindings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Not to be overridden - KeyBindings are tickhandlers under the covers
|
||||
*/
|
||||
@Override
|
||||
public final void tickStart (EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
keyTick(type, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Not to be overridden - KeyBindings are tickhandlers under the covers
|
||||
*/
|
||||
@Override
|
||||
public final void tickEnd (EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
keyTick(type, true);
|
||||
}
|
||||
|
||||
public void keyTick (EnumSet<TickType> type, boolean tickEnd)
|
||||
{
|
||||
for (int i = 0; i < keyBindings.length; i++)
|
||||
{
|
||||
KeyBinding keyBinding = keyBindings[i];
|
||||
int keyCode = keyBinding.keyCode;
|
||||
boolean state = (keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode));
|
||||
if (state != keyDown[i] || (state && repeatings[i]))
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
keyDown(type, keyBinding, tickEnd, state != keyDown[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyUp(type, keyBinding, tickEnd);
|
||||
}
|
||||
if (tickEnd)
|
||||
{
|
||||
keyDown[i] = state;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < vKeyBindings.length; i++)
|
||||
{
|
||||
KeyBinding keyBinding = vKeyBindings[i];
|
||||
int keyCode = keyBinding.keyCode;
|
||||
boolean state = (keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode));
|
||||
if (state != keyDown[i + keyBindings.length] || (state && vRepeatings[i]))
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
keyDown(type, keyBinding, tickEnd, state != keyDown[i + keyBindings.length]);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyUp(type, keyBinding, tickEnd);
|
||||
}
|
||||
if (tickEnd)
|
||||
{
|
||||
keyDown[i + keyBindings.length] = state;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the key is first in the down position on any tick from the {@link #ticks()}
|
||||
* set. Will be called subsequently with isRepeat set to true
|
||||
*
|
||||
* @see #keyUp(EnumSet, KeyBinding, boolean)
|
||||
*
|
||||
* @param types the type(s) of tick that fired when this key was first down
|
||||
* @param tickEnd was it an end or start tick which fired the key
|
||||
* @param isRepeat is it a repeat key event
|
||||
*/
|
||||
public abstract void keyDown (EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat);
|
||||
|
||||
/**
|
||||
* Fired once when the key changes state from down to up
|
||||
*
|
||||
* @see #keyDown(EnumSet, KeyBinding, boolean, boolean)
|
||||
*
|
||||
* @param types the type(s) of tick that fired when this key was first down
|
||||
* @param tickEnd was it an end or start tick which fired the key
|
||||
*/
|
||||
public abstract void keyUp (EnumSet<TickType> types, KeyBinding kb, boolean tickEnd);
|
||||
|
||||
/**
|
||||
* This is the list of ticks for which the key binding should trigger. The only
|
||||
* valid ticks are client side ticks, obviously.
|
||||
*
|
||||
* @see cpw.mods.fml.common.ITickHandler#ticks()
|
||||
*/
|
||||
public abstract EnumSet<TickType> ticks ();
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,122 @@
|
||||
package tconstruct.client.armor;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public class WingModel extends ModelBase
|
||||
{
|
||||
ModelRenderer WingBaseRight;
|
||||
ModelRenderer WingEdgeRight;
|
||||
ModelRenderer WingInsetRight;
|
||||
ModelRenderer WingCenterRight;
|
||||
ModelRenderer WingFlangeRight;
|
||||
ModelRenderer WingAuxRight;
|
||||
ModelRenderer WingBaseLeft;
|
||||
ModelRenderer WingEdgeLeft;
|
||||
ModelRenderer WingInsetLeft;
|
||||
ModelRenderer WingCenterLeft;
|
||||
ModelRenderer WingFlangeLeft;
|
||||
ModelRenderer WingAuxLeft;
|
||||
|
||||
public WingModel()
|
||||
{
|
||||
textureWidth = 64;
|
||||
textureHeight = 64;
|
||||
|
||||
//Right Wing
|
||||
WingBaseRight = new ModelRenderer(this, 0, 41);
|
||||
WingBaseRight.addBox(-0.5F, -1F, 0F, 1, 2, 10);
|
||||
WingBaseRight.setRotationPoint(-1F, 1F, 0F);
|
||||
setRotation(WingBaseRight, 0.5235988F, -0.5235988F, 0F);
|
||||
|
||||
WingEdgeRight = new ModelRenderer(this, 0, 53); //Texture position
|
||||
WingEdgeRight.addBox(0F, 0F, -2F, 1, 9, 2); //Offset, Size
|
||||
WingEdgeRight.setRotationPoint(-0.502F, -1F, 10F); //Negative x, y - 1, Position
|
||||
setRotation(WingEdgeRight, 0.5235988F, 0F, 0F); //Angle in radians
|
||||
|
||||
WingInsetRight = new ModelRenderer(this, 6, 53);
|
||||
WingInsetRight.addBox(0F, 0F, -1F, 1, 9, 2);
|
||||
WingInsetRight.setRotationPoint(-0.504F, 0F, 7.8F);
|
||||
setRotation(WingInsetRight, 0.3490659F, 0F, 0F);
|
||||
|
||||
WingCenterRight = new ModelRenderer(this, 12, 53);
|
||||
WingCenterRight.addBox(0F, 0F, -1F, 1, 9, 2);
|
||||
WingCenterRight.setRotationPoint(-0.506F, 0.3F, 6.3F);
|
||||
setRotation(WingCenterRight, 0.1745329F, 0F, 0F);
|
||||
|
||||
WingFlangeRight = new ModelRenderer(this, 18, 53);
|
||||
WingFlangeRight.addBox(0F, 0F, -1F, 1, 8, 2);
|
||||
WingFlangeRight.setRotationPoint(-0.508F, 0.3F, 5.1F);
|
||||
setRotation(WingFlangeRight, 0F, 0F, 0F);
|
||||
|
||||
WingAuxRight = new ModelRenderer(this, 24, 53);
|
||||
WingAuxRight.addBox(0F, 0F, -1F, 1, 7, 2);
|
||||
WingAuxRight.setRotationPoint(-0.51F, 0.1F, 4F);
|
||||
setRotation(WingAuxRight, -0.1745329F, 0F, 0F);
|
||||
|
||||
WingBaseRight.addChild(WingEdgeRight);
|
||||
WingBaseRight.addChild(WingInsetRight);
|
||||
WingBaseRight.addChild(WingCenterRight);
|
||||
WingBaseRight.addChild(WingFlangeRight);
|
||||
WingBaseRight.addChild(WingAuxRight);
|
||||
|
||||
//Left Wing
|
||||
WingBaseLeft = new ModelRenderer(this, 42, 41);
|
||||
WingBaseLeft.addBox(-0.5F, -1F, 0F, 1, 2, 10);
|
||||
WingBaseLeft.setRotationPoint(1F, 1F, 0F);
|
||||
setRotation(WingBaseLeft, 0.5235988F, 0.5235988F, 0F);
|
||||
|
||||
WingEdgeLeft = new ModelRenderer(this, 58, 53);
|
||||
WingEdgeLeft.addBox(0F, 0F, -2F, 1, 9, 2);
|
||||
WingEdgeLeft.setRotationPoint(-0.502F, -1F, 10F);
|
||||
setRotation(WingEdgeLeft, 0.5235988F, 0F, 0F);
|
||||
|
||||
WingInsetLeft = new ModelRenderer(this, 52, 53);
|
||||
WingInsetLeft.addBox(0F, 0F, -1F, 1, 9, 2);
|
||||
WingInsetLeft.setRotationPoint(-0.504F, 0F, 7.8F);
|
||||
setRotation(WingInsetLeft, 0.3490659F, 0F, 0F);
|
||||
|
||||
WingCenterLeft = new ModelRenderer(this, 46, 53);
|
||||
WingCenterLeft.addBox(0F, 0F, -1F, 1, 9, 2);
|
||||
WingCenterLeft.setRotationPoint(-0.506F, 0.3F, 6.3F);
|
||||
setRotation(WingCenterLeft, 0.1745329F, 0F, 0F);
|
||||
|
||||
WingFlangeLeft = new ModelRenderer(this, 40, 53);
|
||||
WingFlangeLeft.addBox(0F, 0F, -1F, 1, 8, 2);
|
||||
WingFlangeLeft.setRotationPoint(-0.508F, 0.3F, 5.1F);
|
||||
setRotation(WingFlangeLeft, 0F, 0F, 0F);
|
||||
|
||||
WingAuxLeft = new ModelRenderer(this, 34, 53);
|
||||
WingAuxLeft.addBox(0F, 0F, -1F, 1, 7, 2);
|
||||
WingAuxLeft.setRotationPoint(-0.51F, 0.1F, 4F);
|
||||
setRotation(WingAuxLeft, -0.1745329F, 0F, 0F);
|
||||
|
||||
WingBaseLeft.addChild(WingEdgeLeft);
|
||||
WingBaseLeft.addChild(WingInsetLeft);
|
||||
WingBaseLeft.addChild(WingCenterLeft);
|
||||
WingBaseLeft.addChild(WingFlangeLeft);
|
||||
WingBaseLeft.addChild(WingAuxLeft);
|
||||
}
|
||||
|
||||
public void render (Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
|
||||
{
|
||||
super.render(entity, f, f1, f2, f3, f4, f5);
|
||||
setRotationAngles(f, f1, f2, f3, f4, f5, entity);
|
||||
WingBaseRight.render(f5);
|
||||
WingBaseLeft.render(f5);
|
||||
}
|
||||
|
||||
private void setRotation (ModelRenderer model, float x, float y, float z)
|
||||
{
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles (float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
|
||||
{
|
||||
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import tconstruct.blocks.RedstoneBallRepeater;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BallRepeaterRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int model = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
//Inventory should be an item. This is not here!
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
return renderRedstoneBallRepeater(block, x, y, z, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public boolean renderRedstoneBallRepeater (Block par1Block, int par2, int par3, int par4, IBlockAccess world)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
int l = world.getBlockMetadata(par2, par3, par4);
|
||||
Icon icon = RedstoneBallRepeater.func_94409_b("repeaterDust_cross");
|
||||
Icon icon1 = RedstoneBallRepeater.func_94409_b("repeaterDust_line");
|
||||
Icon icon2 = RedstoneBallRepeater.func_94409_b("repeaterDust_cross_overlay");
|
||||
Icon icon3 = RedstoneBallRepeater.func_94409_b("repeaterDust_line_overlay");
|
||||
tessellator.setBrightness(par1Block.getMixedBrightnessForBlock(world, par2, par3, par4));
|
||||
float f = 1.0F;
|
||||
float f1 = (float) l / 15.0F;
|
||||
float f2 = f1 * 0.6F + 0.4F;
|
||||
|
||||
if (l == 0)
|
||||
{
|
||||
f2 = 0.3F;
|
||||
}
|
||||
|
||||
float f3 = f1 * f1 * 0.7F - 0.5F;
|
||||
float f4 = f1 * f1 * 0.6F - 0.7F;
|
||||
|
||||
if (f3 < 0.0F)
|
||||
{
|
||||
f3 = 0.0F;
|
||||
}
|
||||
|
||||
if (f4 < 0.0F)
|
||||
{
|
||||
f4 = 0.0F;
|
||||
}
|
||||
|
||||
tessellator.setColorOpaque_F(f2, f3, f4);
|
||||
boolean flag = RedstoneBallRepeater.isPowerProviderOrWire(world, par2 - 1, par3, par4, 1) || !world.isBlockNormalCube(par2 - 1, par3, par4)
|
||||
&& RedstoneBallRepeater.isPowerProviderOrWire(world, par2 - 1, par3 - 1, par4, -1);
|
||||
boolean flag1 = RedstoneBallRepeater.isPowerProviderOrWire(world, par2 + 1, par3, par4, 3) || !world.isBlockNormalCube(par2 + 1, par3, par4)
|
||||
&& RedstoneBallRepeater.isPowerProviderOrWire(world, par2 + 1, par3 - 1, par4, -1);
|
||||
boolean flag2 = RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3, par4 - 1, 2) || !world.isBlockNormalCube(par2, par3, par4 - 1)
|
||||
&& RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3 - 1, par4 - 1, -1);
|
||||
boolean flag3 = RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3, par4 + 1, 0) || !world.isBlockNormalCube(par2, par3, par4 + 1)
|
||||
&& RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3 - 1, par4 + 1, -1);
|
||||
|
||||
if (!world.isBlockNormalCube(par2, par3 + 1, par4))
|
||||
{
|
||||
if (world.isBlockNormalCube(par2 - 1, par3, par4) && RedstoneBallRepeater.isPowerProviderOrWire(world, par2 - 1, par3 + 1, par4, -1))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (world.isBlockNormalCube(par2 + 1, par3, par4) && RedstoneBallRepeater.isPowerProviderOrWire(world, par2 + 1, par3 + 1, par4, -1))
|
||||
{
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
if (world.isBlockNormalCube(par2, par3, par4 - 1) && RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3 + 1, par4 - 1, -1))
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
|
||||
if (world.isBlockNormalCube(par2, par3, par4 + 1) && RedstoneBallRepeater.isPowerProviderOrWire(world, par2, par3 + 1, par4 + 1, -1))
|
||||
{
|
||||
flag3 = true;
|
||||
}
|
||||
}
|
||||
|
||||
float f5 = (float) (par2 + 0);
|
||||
float f6 = (float) (par2 + 1);
|
||||
float f7 = (float) (par4 + 0);
|
||||
float f8 = (float) (par4 + 1);
|
||||
int i1 = 0;
|
||||
|
||||
if ((flag || flag1) && !flag2 && !flag3)
|
||||
{
|
||||
i1 = 1;
|
||||
}
|
||||
|
||||
if ((flag2 || flag3) && !flag1 && !flag)
|
||||
{
|
||||
i1 = 2;
|
||||
}
|
||||
|
||||
if (i1 == 0)
|
||||
{
|
||||
int j1 = 0;
|
||||
int k1 = 0;
|
||||
int l1 = 16;
|
||||
int i2 = 16;
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
f5 += 0.3125F;
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
j1 += 5;
|
||||
}
|
||||
|
||||
if (!flag1)
|
||||
{
|
||||
f6 -= 0.3125F;
|
||||
}
|
||||
|
||||
if (!flag1)
|
||||
{
|
||||
l1 -= 5;
|
||||
}
|
||||
|
||||
if (!flag2)
|
||||
{
|
||||
f7 += 0.3125F;
|
||||
}
|
||||
|
||||
if (!flag2)
|
||||
{
|
||||
k1 += 5;
|
||||
}
|
||||
|
||||
if (!flag3)
|
||||
{
|
||||
f8 -= 0.3125F;
|
||||
}
|
||||
|
||||
if (!flag3)
|
||||
{
|
||||
i2 -= 5;
|
||||
}
|
||||
|
||||
tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f8, (double) icon.getInterpolatedU((double) l1), (double) icon.getInterpolatedV((double) i2));
|
||||
tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f7, (double) icon.getInterpolatedU((double) l1), (double) icon.getInterpolatedV((double) k1));
|
||||
tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f7, (double) icon.getInterpolatedU((double) j1), (double) icon.getInterpolatedV((double) k1));
|
||||
tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f8, (double) icon.getInterpolatedU((double) j1), (double) icon.getInterpolatedV((double) i2));
|
||||
tessellator.setColorOpaque_F(f, f, f);
|
||||
tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f8, (double) icon2.getInterpolatedU((double) l1), (double) icon2.getInterpolatedV((double) i2));
|
||||
tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f7, (double) icon2.getInterpolatedU((double) l1), (double) icon2.getInterpolatedV((double) k1));
|
||||
tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f7, (double) icon2.getInterpolatedU((double) j1), (double) icon2.getInterpolatedV((double) k1));
|
||||
tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f8, (double) icon2.getInterpolatedU((double) j1), (double) icon2.getInterpolatedV((double) i2));
|
||||
}
|
||||
else if (i1 == 1)
|
||||
{
|
||||
tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f8, (double) icon1.getMaxU(), (double) icon1.getMaxV());
|
||||
tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f7, (double) icon1.getMaxU(), (double) icon1.getMinV());
|
||||
tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f7, (double) icon1.getMinU(), (double) icon1.getMinV());
|
||||
tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f8, (double) icon1.getMinU(), (double) icon1.getMaxV());
|
||||
tessellator.setColorOpaque_F(f, f, f);
|
||||
tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f8, (double) icon3.getMaxU(), (double) icon3.getMaxV());
|
||||
tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f7, (double) icon3.getMaxU(), (double) icon3.getMinV());
|
||||
tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f7, (double) icon3.getMinU(), (double) icon3.getMinV());
|
||||
tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f8, (double) icon3.getMinU(), (double) icon3.getMaxV());
|
||||
}
|
||||
else
|
||||
{
|
||||
tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f8, (double) icon1.getMaxU(), (double) icon1.getMaxV());
|
||||
tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f7, (double) icon1.getMinU(), (double) icon1.getMaxV());
|
||||
tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f7, (double) icon1.getMinU(), (double) icon1.getMinV());
|
||||
tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f8, (double) icon1.getMaxU(), (double) icon1.getMinV());
|
||||
tessellator.setColorOpaque_F(f, f, f);
|
||||
tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f8, (double) icon3.getMaxU(), (double) icon3.getMaxV());
|
||||
tessellator.addVertexWithUV((double) f6, (double) par3 + 0.015625D, (double) f7, (double) icon3.getMinU(), (double) icon3.getMaxV());
|
||||
tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f7, (double) icon3.getMinU(), (double) icon3.getMinV());
|
||||
tessellator.addVertexWithUV((double) f5, (double) par3 + 0.015625D, (double) f8, (double) icon3.getMaxU(), (double) icon3.getMinV());
|
||||
}
|
||||
|
||||
if (!world.isBlockNormalCube(par2, par3 + 1, par4))
|
||||
{
|
||||
if (world.isBlockNormalCube(par2 - 1, par3, par4) && world.getBlockId(par2 - 1, par3 + 1, par4) == Block.redstoneWire.blockID)
|
||||
{
|
||||
tessellator.setColorOpaque_F(f * f2, f * f3, f * f4);
|
||||
tessellator.addVertexWithUV((double) par2 + 0.015625D, (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 1), (double) icon1.getMaxU(), (double) icon1.getMinV());
|
||||
tessellator.addVertexWithUV((double) par2 + 0.015625D, (double) (par3 + 0), (double) (par4 + 1), (double) icon1.getMinU(), (double) icon1.getMinV());
|
||||
tessellator.addVertexWithUV((double) par2 + 0.015625D, (double) (par3 + 0), (double) (par4 + 0), (double) icon1.getMinU(), (double) icon1.getMaxV());
|
||||
tessellator.addVertexWithUV((double) par2 + 0.015625D, (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 0), (double) icon1.getMaxU(), (double) icon1.getMaxV());
|
||||
tessellator.setColorOpaque_F(f, f, f);
|
||||
tessellator.addVertexWithUV((double) par2 + 0.015625D, (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 1), (double) icon3.getMaxU(), (double) icon3.getMinV());
|
||||
tessellator.addVertexWithUV((double) par2 + 0.015625D, (double) (par3 + 0), (double) (par4 + 1), (double) icon3.getMinU(), (double) icon3.getMinV());
|
||||
tessellator.addVertexWithUV((double) par2 + 0.015625D, (double) (par3 + 0), (double) (par4 + 0), (double) icon3.getMinU(), (double) icon3.getMaxV());
|
||||
tessellator.addVertexWithUV((double) par2 + 0.015625D, (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 0), (double) icon3.getMaxU(), (double) icon3.getMaxV());
|
||||
}
|
||||
|
||||
if (world.isBlockNormalCube(par2 + 1, par3, par4) && world.getBlockId(par2 + 1, par3 + 1, par4) == Block.redstoneWire.blockID)
|
||||
{
|
||||
tessellator.setColorOpaque_F(f * f2, f * f3, f * f4);
|
||||
tessellator.addVertexWithUV((double) (par2 + 1) - 0.015625D, (double) (par3 + 0), (double) (par4 + 1), (double) icon1.getMinU(), (double) icon1.getMaxV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 1) - 0.015625D, (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 1), (double) icon1.getMaxU(), (double) icon1.getMaxV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 1) - 0.015625D, (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 0), (double) icon1.getMaxU(), (double) icon1.getMinV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 1) - 0.015625D, (double) (par3 + 0), (double) (par4 + 0), (double) icon1.getMinU(), (double) icon1.getMinV());
|
||||
tessellator.setColorOpaque_F(f, f, f);
|
||||
tessellator.addVertexWithUV((double) (par2 + 1) - 0.015625D, (double) (par3 + 0), (double) (par4 + 1), (double) icon3.getMinU(), (double) icon3.getMaxV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 1) - 0.015625D, (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 1), (double) icon3.getMaxU(), (double) icon3.getMaxV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 1) - 0.015625D, (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 0), (double) icon3.getMaxU(), (double) icon3.getMinV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 1) - 0.015625D, (double) (par3 + 0), (double) (par4 + 0), (double) icon3.getMinU(), (double) icon3.getMinV());
|
||||
}
|
||||
|
||||
if (world.isBlockNormalCube(par2, par3, par4 - 1) && world.getBlockId(par2, par3 + 1, par4 - 1) == Block.redstoneWire.blockID)
|
||||
{
|
||||
tessellator.setColorOpaque_F(f * f2, f * f3, f * f4);
|
||||
tessellator.addVertexWithUV((double) (par2 + 1), (double) (par3 + 0), (double) par4 + 0.015625D, (double) icon1.getMinU(), (double) icon1.getMaxV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 1), (double) ((float) (par3 + 1) + 0.021875F), (double) par4 + 0.015625D, (double) icon1.getMaxU(), (double) icon1.getMaxV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 0), (double) ((float) (par3 + 1) + 0.021875F), (double) par4 + 0.015625D, (double) icon1.getMaxU(), (double) icon1.getMinV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) par4 + 0.015625D, (double) icon1.getMinU(), (double) icon1.getMinV());
|
||||
tessellator.setColorOpaque_F(f, f, f);
|
||||
tessellator.addVertexWithUV((double) (par2 + 1), (double) (par3 + 0), (double) par4 + 0.015625D, (double) icon3.getMinU(), (double) icon3.getMaxV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 1), (double) ((float) (par3 + 1) + 0.021875F), (double) par4 + 0.015625D, (double) icon3.getMaxU(), (double) icon3.getMaxV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 0), (double) ((float) (par3 + 1) + 0.021875F), (double) par4 + 0.015625D, (double) icon3.getMaxU(), (double) icon3.getMinV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) par4 + 0.015625D, (double) icon3.getMinU(), (double) icon3.getMinV());
|
||||
}
|
||||
|
||||
if (world.isBlockNormalCube(par2, par3, par4 + 1) && world.getBlockId(par2, par3 + 1, par4 + 1) == Block.redstoneWire.blockID)
|
||||
{
|
||||
tessellator.setColorOpaque_F(f * f2, f * f3, f * f4);
|
||||
tessellator.addVertexWithUV((double) (par2 + 1), (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 1) - 0.015625D, (double) icon1.getMaxU(), (double) icon1.getMinV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 1), (double) (par3 + 0), (double) (par4 + 1) - 0.015625D, (double) icon1.getMinU(), (double) icon1.getMinV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) (par4 + 1) - 0.015625D, (double) icon1.getMinU(), (double) icon1.getMaxV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 0), (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 1) - 0.015625D, (double) icon1.getMaxU(), (double) icon1.getMaxV());
|
||||
tessellator.setColorOpaque_F(f, f, f);
|
||||
tessellator.addVertexWithUV((double) (par2 + 1), (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 1) - 0.015625D, (double) icon3.getMaxU(), (double) icon3.getMinV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 1), (double) (par3 + 0), (double) (par4 + 1) - 0.015625D, (double) icon3.getMinU(), (double) icon3.getMinV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) (par4 + 1) - 0.015625D, (double) icon3.getMinU(), (double) icon3.getMaxV());
|
||||
tessellator.addVertexWithUV((double) (par2 + 0), (double) ((float) (par3 + 1) + 0.021875F), (double) (par4 + 1) - 0.015625D, (double) icon3.getMaxU(), (double) icon3.getMaxV());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,70 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BreakingFX extends EntityFX
|
||||
{
|
||||
public BreakingFX(World par1World, double par2, double par4, double par6, Item par8Item)
|
||||
{
|
||||
this(par1World, par2, par4, par6, par8Item, 0);
|
||||
}
|
||||
|
||||
public BreakingFX(World par1World, double par2, double par4, double par6, Item par8Item, int par9)
|
||||
{
|
||||
super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D);
|
||||
this.func_110125_a(par8Item.getIconFromDamage(par9));
|
||||
this.particleRed = this.particleGreen = this.particleBlue = 1.0F;
|
||||
this.particleGravity = Block.blockSnow.blockParticleGravity;
|
||||
this.particleScale /= 2.0F;
|
||||
}
|
||||
|
||||
public BreakingFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, Item par14Item, int par15)
|
||||
{
|
||||
this(par1World, par2, par4, par6, par14Item, par15);
|
||||
this.motionX *= 0.10000000149011612D;
|
||||
this.motionY *= 0.10000000149011612D;
|
||||
this.motionZ *= 0.10000000149011612D;
|
||||
this.motionX += par8;
|
||||
this.motionY += par10;
|
||||
this.motionZ += par12;
|
||||
}
|
||||
|
||||
public int getFXLayer()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
|
||||
{
|
||||
float f6 = ((float)this.particleTextureIndexX + this.particleTextureJitterX / 4.0F) / 16.0F;
|
||||
float f7 = f6 + 0.015609375F;
|
||||
float f8 = ((float)this.particleTextureIndexY + this.particleTextureJitterY / 4.0F) / 16.0F;
|
||||
float f9 = f8 + 0.015609375F;
|
||||
float f10 = 0.1F * this.particleScale;
|
||||
|
||||
if (this.particleIcon != null)
|
||||
{
|
||||
f6 = this.particleIcon.getInterpolatedU((double)(this.particleTextureJitterX / 4.0F * 16.0F));
|
||||
f7 = this.particleIcon.getInterpolatedU((double)((this.particleTextureJitterX + 1.0F) / 4.0F * 16.0F));
|
||||
f8 = this.particleIcon.getInterpolatedV((double)(this.particleTextureJitterY / 4.0F * 16.0F));
|
||||
f9 = this.particleIcon.getInterpolatedV((double)((this.particleTextureJitterY + 1.0F) / 4.0F * 16.0F));
|
||||
}
|
||||
|
||||
float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX);
|
||||
float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY);
|
||||
float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ);
|
||||
float f14 = 1.0F;
|
||||
par1Tessellator.setColorOpaque_F(f14 * this.particleRed, f14 * this.particleGreen, f14 * this.particleBlue);
|
||||
par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 - par5 * f10 - par7 * f10), (double)f6, (double)f9);
|
||||
par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 - par5 * f10 + par7 * f10), (double)f6, (double)f8);
|
||||
par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 + par5 * f10 + par7 * f10), (double)f7, (double)f8);
|
||||
par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 + par5 * f10 - par7 * f10), (double)f7, (double)f9);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.blocks.logic.CastingBasinLogic;
|
||||
import tconstruct.entity.FancyEntityItem;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/* Special renderer, only used for drawing tools */
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class CastingBasinSpecialRender extends TileEntitySpecialRenderer
|
||||
{
|
||||
@Override
|
||||
public void renderTileEntityAt (TileEntity logic, double var2, double var4, double var6, float var8)
|
||||
{
|
||||
this.render((CastingBasinLogic) logic, var2, var4, var6, var8);
|
||||
}
|
||||
|
||||
public void render (CastingBasinLogic logic, double posX, double posY, double posZ, float var8)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
float var10 = (float) (posX - 0.5F);
|
||||
float var11 = (float) (posY - 0.5F);
|
||||
float var12 = (float) (posZ - 0.5F);
|
||||
GL11.glTranslatef(var10, var11, var12);
|
||||
|
||||
ItemStack stack = logic.getStackInSlot(0);
|
||||
if (stack != null)
|
||||
renderItem(logic, stack);
|
||||
|
||||
stack = logic.getStackInSlot(1);
|
||||
if (stack != null)
|
||||
renderItem(logic, stack);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
void renderItem (CastingBasinLogic logic, ItemStack stack)
|
||||
{
|
||||
FancyEntityItem entityitem = new FancyEntityItem(logic.worldObj, 0.0D, 0.0D, 0.0D, stack);
|
||||
entityitem.getEntityItem().stackSize = 1;
|
||||
entityitem.hoverStart = 0.0F;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(1F, 0.675F, 1.0F);
|
||||
//GL11.glRotatef(90F, 1, 0F, 0F);
|
||||
GL11.glScalef(1.75F, 1.75F, 1.75F);
|
||||
if (stack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
GL11.glScalef(1.6F, 1.6F, 1.6F);
|
||||
GL11.glTranslatef(0F, 0.045F, 0.0f);
|
||||
}
|
||||
|
||||
RenderItem.renderInFrame = true;
|
||||
RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
RenderItem.renderInFrame = false;
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.blocks.logic.CastingTableLogic;
|
||||
import tconstruct.entity.FancyEntityItem;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/* Special renderer, only used for drawing tools */
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class CastingTableSpecialRenderer extends TileEntitySpecialRenderer
|
||||
{
|
||||
@Override
|
||||
public void renderTileEntityAt (TileEntity logic, double var2, double var4, double var6, float var8)
|
||||
{
|
||||
//System.out.println("Render!!!");
|
||||
this.render((CastingTableLogic) logic, var2, var4, var6, var8);
|
||||
}
|
||||
|
||||
public void render (CastingTableLogic logic, double posX, double posY, double posZ, float var8)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
float var10 = (float) (posX - 0.5F);
|
||||
float var11 = (float) (posY - 0.5F);
|
||||
float var12 = (float) (posZ - 0.5F);
|
||||
GL11.glTranslatef(var10, var11, var12);
|
||||
this.func_82402_b(logic);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void func_82402_b (CastingTableLogic logic)
|
||||
{
|
||||
ItemStack stack = logic.getStackInSlot(0);
|
||||
|
||||
if (stack != null)
|
||||
renderItem(logic, stack);
|
||||
|
||||
stack = logic.getStackInSlot(1);
|
||||
|
||||
if (stack != null)
|
||||
renderItem(logic, stack);
|
||||
}
|
||||
|
||||
void renderItem (CastingTableLogic logic, ItemStack stack)
|
||||
{
|
||||
FancyEntityItem entityitem = new FancyEntityItem(logic.worldObj, 0.0D, 0.0D, 0.0D, stack);
|
||||
entityitem.getEntityItem().stackSize = 1;
|
||||
entityitem.hoverStart = 0.0F;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(1F, 1.48F, 0.55F);
|
||||
GL11.glRotatef(90F, 1, 0F, 0F);
|
||||
GL11.glScalef(2F, 2F, 2F);
|
||||
if (stack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
GL11.glRotatef(90F, -1, 0F, 0F);
|
||||
GL11.glTranslatef(0F, -0.1F, 0.2275F);
|
||||
}
|
||||
|
||||
RenderItem.renderInFrame = true;
|
||||
RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
RenderItem.renderInFrame = false;
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import tconstruct.client.TProxyClient;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class CrystalBlockRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int model = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == model)
|
||||
{
|
||||
renderer.setRenderBounds(0.375F, 0.0F, 0.375F, 0.625F, 0.125F, 0.625F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.3125F, 0.125F, 0.3125F, 0.6875F, 0.25F, 0.6875F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.25F, 0.25F, 0.25F, 0.75F, 0.75F, 0.75F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.3125F, 0.75F, 0.3125F, 0.6875F, 0.875F, 0.6875F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.375F, 0.875F, 0.375F, 0.625F, 1.0F, 0.625F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == model)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z) % 5;
|
||||
|
||||
if (metadata != 3)
|
||||
{
|
||||
renderer.setRenderBounds(0.0625F, 0.0F, 0.0625F, 0.25F, 0.0625F, 0.375F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.5F, 0.0F, 0.75F, 0.625F, 0.125F, 0.8125F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.5F, 0.0F, 0.8125F, 0.5625F, 0.0625F, 0.875F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
if (metadata == 0)
|
||||
{
|
||||
renderer.setRenderBounds(0.375F, 0.0F, 0.375F, 0.625F, 0.125F, 0.625F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
else if (metadata == 1)
|
||||
{
|
||||
renderer.setRenderBounds(0.3125F, 0.0F, 0.3125F, 0.6875F, 0.25, 0.6875F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.375F, 0.25, 0.375F, 0.625F, 0.375, 0.625F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.1875, 0.0F, 0.5F, 0.3125F, 0.1875, 0.75F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.4325F, 0.0F, 0.1875, 0.625, 0.125, 0.3125F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.625F, 0.0F, 0.5F, 0.8125f, 0.125, 0.75F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
else if (metadata == 2)
|
||||
{
|
||||
renderer.setRenderBounds(0.3125F, 0.0F, 0.3125F, 0.6875F, 0.5F, 0.6875F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.375F, 0.5F, 0.375F, 0.625F, 0.625F, 0.625F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.125F, 0.0F, 0.5F, 0.3125F, 0.25F, 0.75F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.4325F, 0.0F, 0.125F, 0.6875F, 0.375F, 0.3125F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.625F, 0.0F, 0.5F, 0.8125f, 0.375F, 0.75F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
else if (metadata == 3)
|
||||
{
|
||||
renderer.setRenderBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.75F, 0.75F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.3125F, 0.75F, 0.3125F, 0.6875F, 0.875F, 0.6875F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.375F, 0.875F, 0.375F, 0.625F, 0.9325F, 0.625F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
renderer.setRenderBounds(0.125F, 0.0F, 0.5F, 0.375F, 0.375, 0.875F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.4325F, 0.0F, 0.0625, 0.625, 0.5, 0.3125F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.625F, 0.0F, 0.5F, 0.875F, 0.625, 0.875F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
else if (metadata == 4)
|
||||
{
|
||||
/*renderer.setRenderBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.75F, 0.75F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.3125F, 0.75F, 0.3125F, 0.6875F, 0.875F, 0.6875F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.375F, 0.875F, 0.375F, 0.625F, 0.9325F, 0.625F);
|
||||
renderer.renderStandardBlock(block, x, y, z);*/
|
||||
|
||||
renderer.setRenderBounds(0.125F, 0.0F, 0.5F, 0.375F, 0.125F, 0.75F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.4325F, 0.0F, 0.0625, 0.625, 0.25F, 0.3125F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.625F, 0.0F, 0.5F, 0.75F, 0.1875F, 0.75F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.client.TProxyClient;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class DryingRackRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int model = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == model)
|
||||
{
|
||||
renderer.setRenderBounds(0.375F, 0.375F, 0.0F, 0.625F, 0.625F, 1.0F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == model)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
if (metadata == 0)
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.0, 0.375F, 1.0F, 0.25F, 0.625F);
|
||||
}
|
||||
if (metadata == 1)
|
||||
{
|
||||
renderer.setRenderBounds(0.375F, 0.0, 0.0f, 0.625F, 0.25F, 1F);
|
||||
}
|
||||
|
||||
if (metadata == 2)
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.75F, 0.75F, 1F, 1.0F, 1F);
|
||||
}
|
||||
if (metadata == 3)
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.75F, 0F, 1F, 1.0F, 0.25F);
|
||||
}
|
||||
if (metadata == 4)
|
||||
{
|
||||
renderer.setRenderBounds(0.75F, 0.75F, 0.0f, 1F, 1.0F, 1F);
|
||||
}
|
||||
if (metadata == 5)
|
||||
{
|
||||
renderer.setRenderBounds(0F, 0.75F, 0.0f, 0.25F, 1.0F, 1F);
|
||||
}
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public static void renderStandardInvBlock (RenderBlocks renderblocks, Block block, int meta)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta));
|
||||
tessellator.draw();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.blocks.logic.DryingRackLogic;
|
||||
import tconstruct.entity.FancyEntityItem;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/* Special renderer, only used for drawing tools */
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class DryingRackSpecialRender extends TileEntitySpecialRenderer
|
||||
{
|
||||
@Override
|
||||
public void renderTileEntityAt (TileEntity logic, double var2, double var4, double var6, float var8)
|
||||
{
|
||||
//System.out.println("Render!!!");
|
||||
this.render((DryingRackLogic) logic, var2, var4, var6, var8);
|
||||
}
|
||||
|
||||
public void render (DryingRackLogic logic, double posX, double posY, double posZ, float var8)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
float var10 = (float) (posX - 0.5F);
|
||||
float var11 = (float) (posY - 0.5F);
|
||||
float var12 = (float) (posZ - 0.5F);
|
||||
GL11.glTranslatef(var10, var11, var12);
|
||||
this.func_82402_b(logic);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void func_82402_b (DryingRackLogic logic)
|
||||
{
|
||||
ItemStack stack = logic.getStackInSlot(0);
|
||||
|
||||
if (stack != null)
|
||||
renderItem(logic, stack);
|
||||
}
|
||||
|
||||
void renderItem (DryingRackLogic logic, ItemStack stack)
|
||||
{
|
||||
FancyEntityItem entityitem = new FancyEntityItem(logic.worldObj, 0.0D, 0.0D, 0.0D, stack);
|
||||
entityitem.getEntityItem().stackSize = 1;
|
||||
entityitem.hoverStart = 0.0F;
|
||||
GL11.glPushMatrix();
|
||||
int meta = logic.worldObj.getBlockMetadata(logic.xCoord, logic.yCoord, logic.zCoord);
|
||||
if (meta <= 1)
|
||||
GL11.glTranslatef(1F, -0.375F, 0.905F);
|
||||
else
|
||||
{
|
||||
GL11.glTranslatef(1F, 0.375F, 0.905F);
|
||||
|
||||
if (meta / 2 == 2)
|
||||
{
|
||||
GL11.glRotatef(90F, 0F, 1F, 0F);
|
||||
GL11.glTranslatef(-0.0625F, 0F, 0F);
|
||||
}
|
||||
if (meta == 2)
|
||||
GL11.glTranslatef(0F, 0F, 0.375F);
|
||||
if (meta == 3)
|
||||
GL11.glTranslatef(0F, 0F, -0.375F);
|
||||
if (meta == 4)
|
||||
GL11.glTranslatef(0F, 0F, 0.2875F);
|
||||
if (meta == 5)
|
||||
GL11.glTranslatef(0F, 0F, -0.5F);
|
||||
}
|
||||
GL11.glScalef(2F, 2F, 2F);
|
||||
if (stack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
//GL11.glRotatef(90F, -1, 0F, 0F);
|
||||
GL11.glTranslatef(0F, 0.2125F, 0.0375F);
|
||||
}
|
||||
|
||||
RenderItem.renderInFrame = true;
|
||||
RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
RenderItem.renderInFrame = false;
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class FrypanRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int frypanModelID = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
//Inventory should be an item. This is not here!
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.125F, 0.0F, 0.125F, 0.25F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.125F, 0.125F, 0.875F, 0.875F, 0.25F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.875F, 0.125F, 0.0F, 1.0F, 0.25F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.125F, 0.125F, 0.0F, 0.875F, 0.25F, 0.125F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(1F, 0.0F, 0.4375F, 2F, 0.125F, 0.5625F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return frypanModelID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import tconstruct.client.TProxyClient;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class GolemCoreRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int model = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0F, 0.0F, 1.0F, 0.1875F, 1.0F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.0F, 0.8125F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.0F, 0.1875F, 0.0F, 0.1875F, 0.8125F, 0.1875F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.8175, 0.1875F, 0.0F, 1f, 0.8125F, 0.1875F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.0F, 0.1875F, 0.8175, 0.1875F, 0.8125F, 1f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.8175F, 0.1875F, 0.8175, 1f, 0.8125F, 1f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0F, 0.0F, 1.0F, 0.1875F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.8125F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.1875F, 0.0F, 0.1875F, 0.8125F, 0.1875F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.8175, 0.1875F, 0.0F, 1f, 0.8125F, 0.1875F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.1875F, 0.8175, 0.1875F, 0.8125F, 1f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.8175F, 0.1875F, 0.8175, 1f, 0.8125F, 1f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.blocks.logic.GolemCoreLogic;
|
||||
import tconstruct.entity.FancyEntityItem;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/* Special renderer, only used for drawing tools */
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GolemCoreSpecialRender extends TileEntitySpecialRenderer
|
||||
{
|
||||
@Override
|
||||
public void renderTileEntityAt (TileEntity logic, double var2, double var4, double var6, float var8)
|
||||
{
|
||||
this.render((GolemCoreLogic) logic, var2, var4, var6, var8);
|
||||
}
|
||||
|
||||
public void render (GolemCoreLogic logic, double posX, double posY, double posZ, float var8)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
float var10 = (float) (posX - 0.5F);
|
||||
float var11 = (float) (posY - 0.5F);
|
||||
float var12 = (float) (posZ - 0.5F);
|
||||
GL11.glTranslatef(var10, var11, var12);
|
||||
|
||||
ItemStack stack = logic.getStackInSlot(0);
|
||||
if (stack != null)
|
||||
renderItem(logic, stack);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
void renderItem (GolemCoreLogic logic, ItemStack stack)
|
||||
{
|
||||
FancyEntityItem entityitem = new FancyEntityItem(logic.worldObj, 0.0D, 0.0D, 0.0D, stack);
|
||||
entityitem.getEntityItem().stackSize = 1;
|
||||
entityitem.hoverStart = 0.0F;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(1F, 0.675F, 1.0F);
|
||||
//GL11.glRotatef(90F, 1, 0F, 0F);
|
||||
GL11.glScalef(1.4F, 1.4F, 1.4F);
|
||||
if (stack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
GL11.glScalef(1.6F, 1.6F, 1.6F);
|
||||
GL11.glTranslatef(0F, 0.045F, 0.0f);
|
||||
}
|
||||
|
||||
RenderItem.renderInFrame = true;
|
||||
RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
RenderItem.renderInFrame = false;
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import tconstruct.client.TProxyClient;
|
||||
import tconstruct.library.util.IFacingLogic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class MachineRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int model = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == model)
|
||||
{
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == model)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
if (metadata == 0)
|
||||
{
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderRotatedBlock(block, x, y, z, world, renderer);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean renderRotatedBlock (Block block, int x, int y, int z, IBlockAccess world, RenderBlocks renderer)
|
||||
{
|
||||
IFacingLogic logic = (IFacingLogic) world.getBlockTileEntity(x, y, z);
|
||||
byte direction = logic.getRenderDirection();
|
||||
|
||||
if (direction == 0)
|
||||
{
|
||||
renderer.uvRotateEast = 3;
|
||||
renderer.uvRotateWest = 3;
|
||||
renderer.uvRotateNorth = 3;
|
||||
renderer.uvRotateSouth = 3;
|
||||
}
|
||||
if (direction == 2)
|
||||
{
|
||||
renderer.uvRotateNorth = 2;
|
||||
renderer.uvRotateSouth = 1;
|
||||
}
|
||||
if (direction == 3)
|
||||
{
|
||||
renderer.uvRotateNorth = 1;
|
||||
renderer.uvRotateSouth = 2;
|
||||
renderer.uvRotateTop = 3;
|
||||
renderer.uvRotateBottom = 3;
|
||||
}
|
||||
if (direction == 4)
|
||||
{
|
||||
renderer.uvRotateEast = 1;
|
||||
renderer.uvRotateWest = 2;
|
||||
renderer.uvRotateTop = 2;
|
||||
renderer.uvRotateBottom = 1;
|
||||
}
|
||||
if (direction == 5)
|
||||
{
|
||||
renderer.uvRotateEast = 2;
|
||||
renderer.uvRotateWest = 1;
|
||||
renderer.uvRotateTop = 1;
|
||||
renderer.uvRotateBottom = 2;
|
||||
}
|
||||
|
||||
boolean flag = renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.uvRotateSouth = 0;
|
||||
renderer.uvRotateEast = 0;
|
||||
renderer.uvRotateWest = 0;
|
||||
renderer.uvRotateNorth = 0;
|
||||
renderer.uvRotateTop = 0;
|
||||
renderer.uvRotateBottom = 0;
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import tconstruct.client.TProxyClient;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class OreberryRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int model = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
|
||||
{
|
||||
|
||||
if (modelId == model)
|
||||
{
|
||||
int md = world.getBlockMetadata(x, y, z);
|
||||
if (md < 4)
|
||||
{
|
||||
renderer.setRenderBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
else if (md < 8)
|
||||
{
|
||||
renderer.setRenderBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.75F, 0.875F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == model)
|
||||
{
|
||||
renderer.setRenderBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.75F, 0.875F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,481 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import static net.minecraftforge.common.ForgeDirection.EAST;
|
||||
import static net.minecraftforge.common.ForgeDirection.NORTH;
|
||||
import static net.minecraftforge.common.ForgeDirection.SOUTH;
|
||||
import static net.minecraftforge.common.ForgeDirection.WEST;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import tconstruct.blocks.GlassPaneConnected;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class PaneConnectedRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
|
||||
public static int model = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
|
||||
{
|
||||
GlassPaneConnected paneConnected = (GlassPaneConnected) block;
|
||||
int l = world.getHeight();
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.setBrightness(paneConnected.getMixedBrightnessForBlock(world, x, y, z));
|
||||
float f = 1.0F;
|
||||
int i1 = paneConnected.colorMultiplier(world, x, y, z);
|
||||
float f1 = (float) (i1 >> 16 & 255) / 255.0F;
|
||||
float f2 = (float) (i1 >> 8 & 255) / 255.0F;
|
||||
float f3 = (float) (i1 & 255) / 255.0F;
|
||||
|
||||
if (EntityRenderer.anaglyphEnable)
|
||||
{
|
||||
float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
|
||||
float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
|
||||
float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
|
||||
f1 = f4;
|
||||
f2 = f5;
|
||||
f3 = f6;
|
||||
}
|
||||
|
||||
tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);
|
||||
Icon icon;
|
||||
Icon icon1;
|
||||
|
||||
if (renderer.hasOverrideBlockTexture())
|
||||
{
|
||||
icon = renderer.overrideBlockTexture;
|
||||
icon1 = renderer.overrideBlockTexture;
|
||||
}
|
||||
else
|
||||
{
|
||||
int j1 = world.getBlockMetadata(x, y, z);
|
||||
icon = renderer.getBlockIconFromSideAndMetadata(paneConnected, 0, j1);
|
||||
icon1 = paneConnected.getSideTextureIndex();
|
||||
}
|
||||
|
||||
double d0 = (double) icon.getMinU();
|
||||
double d1 = (double) icon.getInterpolatedU(8.0D);
|
||||
double d2 = (double) icon.getMaxU();
|
||||
double d3 = (double) icon.getMinV();
|
||||
double d4 = (double) icon.getMaxV();
|
||||
double d5 = (double) icon1.getInterpolatedU(7.0D);
|
||||
double d6 = (double) icon1.getInterpolatedU(9.0D);
|
||||
double d7 = (double) icon1.getMinV();
|
||||
double d8 = (double) icon1.getInterpolatedV(8.0D);
|
||||
double d9 = (double) icon1.getMaxV();
|
||||
double d10 = (double) x;
|
||||
double d11 = (double) x + 0.5D;
|
||||
double d12 = (double) (x + 1);
|
||||
double d13 = (double) z;
|
||||
double d14 = (double) z + 0.5D;
|
||||
double d15 = (double) (z + 1);
|
||||
double d16 = (double) x + 0.5D - 0.0625D;
|
||||
double d17 = (double) x + 0.5D + 0.0625D;
|
||||
double d18 = (double) z + 0.5D - 0.0625D;
|
||||
double d19 = (double) z + 0.5D + 0.0625D;
|
||||
boolean flag = paneConnected.canPaneConnectTo(world, x, y, z, NORTH);
|
||||
boolean flag1 = paneConnected.canPaneConnectTo(world, x, y, z, SOUTH);
|
||||
boolean flag2 = paneConnected.canPaneConnectTo(world, x, y, z, WEST);
|
||||
boolean flag3 = paneConnected.canPaneConnectTo(world, x, y, z, EAST);
|
||||
boolean flag4 = paneConnected.shouldSideBeRendered(world, x, y + 1, z, 1);
|
||||
boolean flag5 = paneConnected.shouldSideBeRendered(world, x, y - 1, z, 0);
|
||||
double d20 = 0.01D;
|
||||
double d21 = 0.005D;
|
||||
|
||||
if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1))
|
||||
{
|
||||
if (flag2 && !flag3)
|
||||
{
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 1), d14, d0, d3);
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 0), d14, d0, d4);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d14, d1, d4);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d14, d1, d3);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d14, d0, d3);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d14, d0, d4);
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 0), d14, d1, d4);
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 1), d14, d1, d3);
|
||||
|
||||
if (!flag1 && !flag)
|
||||
{
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d19, d5, d7);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d19, d5, d9);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d18, d6, d9);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d18, d6, d7);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d18, d5, d7);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d18, d5, d9);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d19, d6, d9);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d19, d6, d7);
|
||||
}
|
||||
|
||||
if (flag4 || y < l - 1 && world.isAirBlock(x - 1, y + 1, z))
|
||||
{
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d19, d6, d8);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d19, d6, d9);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d18, d5, d9);
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d18, d5, d8);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d19, d6, d8);
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d19, d6, d9);
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d18, d5, d9);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d18, d5, d8);
|
||||
}
|
||||
|
||||
if (flag5 || y > 1 && world.isAirBlock(x - 1, y - 1, z))
|
||||
{
|
||||
tessellator.addVertexWithUV(d10, (double) y - 0.01D, d19, d6, d8);
|
||||
tessellator.addVertexWithUV(d11, (double) y - 0.01D, d19, d6, d9);
|
||||
tessellator.addVertexWithUV(d11, (double) y - 0.01D, d18, d5, d9);
|
||||
tessellator.addVertexWithUV(d10, (double) y - 0.01D, d18, d5, d8);
|
||||
tessellator.addVertexWithUV(d11, (double) y - 0.01D, d19, d6, d8);
|
||||
tessellator.addVertexWithUV(d10, (double) y - 0.01D, d19, d6, d9);
|
||||
tessellator.addVertexWithUV(d10, (double) y - 0.01D, d18, d5, d9);
|
||||
tessellator.addVertexWithUV(d11, (double) y - 0.01D, d18, d5, d8);
|
||||
}
|
||||
}
|
||||
else if (!flag2 && flag3)
|
||||
{
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d14, d1, d3);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d14, d1, d4);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 0), d14, d2, d4);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 1), d14, d2, d3);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 1), d14, d1, d3);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 0), d14, d1, d4);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d14, d2, d4);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d14, d2, d3);
|
||||
|
||||
if (!flag1 && !flag)
|
||||
{
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d18, d5, d7);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d18, d5, d9);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d19, d6, d9);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d19, d6, d7);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d19, d5, d7);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d19, d5, d9);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d18, d6, d9);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d18, d6, d7);
|
||||
}
|
||||
|
||||
if (flag4 || y < l - 1 && world.isAirBlock(x + 1, y + 1, z))
|
||||
{
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d19, d6, d7);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d19, d6, d8);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d18, d5, d8);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d18, d5, d7);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d19, d6, d7);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d19, d6, d8);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d18, d5, d8);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d18, d5, d7);
|
||||
}
|
||||
|
||||
if (flag5 || y > 1 && world.isAirBlock(x + 1, y - 1, z))
|
||||
{
|
||||
tessellator.addVertexWithUV(d11, (double) y - 0.01D, d19, d6, d7);
|
||||
tessellator.addVertexWithUV(d12, (double) y - 0.01D, d19, d6, d8);
|
||||
tessellator.addVertexWithUV(d12, (double) y - 0.01D, d18, d5, d8);
|
||||
tessellator.addVertexWithUV(d11, (double) y - 0.01D, d18, d5, d7);
|
||||
tessellator.addVertexWithUV(d12, (double) y - 0.01D, d19, d6, d7);
|
||||
tessellator.addVertexWithUV(d11, (double) y - 0.01D, d19, d6, d8);
|
||||
tessellator.addVertexWithUV(d11, (double) y - 0.01D, d18, d5, d8);
|
||||
tessellator.addVertexWithUV(d12, (double) y - 0.01D, d18, d5, d7);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 1), d14, d0, d3);
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 0), d14, d0, d4);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 0), d14, d2, d4);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 1), d14, d2, d3);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 1), d14, d0, d3);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 0), d14, d0, d4);
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 0), d14, d2, d4);
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 1), d14, d2, d3);
|
||||
|
||||
if (flag4)
|
||||
{
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d19, d6, d9);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d19, d6, d7);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d18, d5, d7);
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d18, d5, d9);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d19, d6, d9);
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d19, d6, d7);
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d18, d5, d7);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d18, d5, d9);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (y < l - 1 && world.isAirBlock(x - 1, y + 1, z))
|
||||
{
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d19, d6, d8);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d19, d6, d9);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d18, d5, d9);
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d18, d5, d8);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d19, d6, d8);
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d19, d6, d9);
|
||||
tessellator.addVertexWithUV(d10, (double) (y + 1) + 0.01D, d18, d5, d9);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d18, d5, d8);
|
||||
}
|
||||
|
||||
if (y < l - 1 && world.isAirBlock(x + 1, y + 1, z))
|
||||
{
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d19, d6, d7);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d19, d6, d8);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d18, d5, d8);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d18, d5, d7);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d19, d6, d7);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d19, d6, d8);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1) + 0.01D, d18, d5, d8);
|
||||
tessellator.addVertexWithUV(d12, (double) (y + 1) + 0.01D, d18, d5, d7);
|
||||
}
|
||||
}
|
||||
|
||||
if (flag5)
|
||||
{
|
||||
tessellator.addVertexWithUV(d10, (double) y - 0.01D, d19, d6, d9);
|
||||
tessellator.addVertexWithUV(d12, (double) y - 0.01D, d19, d6, d7);
|
||||
tessellator.addVertexWithUV(d12, (double) y - 0.01D, d18, d5, d7);
|
||||
tessellator.addVertexWithUV(d10, (double) y - 0.01D, d18, d5, d9);
|
||||
tessellator.addVertexWithUV(d12, (double) y - 0.01D, d19, d6, d9);
|
||||
tessellator.addVertexWithUV(d10, (double) y - 0.01D, d19, d6, d7);
|
||||
tessellator.addVertexWithUV(d10, (double) y - 0.01D, d18, d5, d7);
|
||||
tessellator.addVertexWithUV(d12, (double) y - 0.01D, d18, d5, d9);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (y > 1 && world.isAirBlock(x - 1, y - 1, z))
|
||||
{
|
||||
tessellator.addVertexWithUV(d10, (double) y - 0.01D, d19, d6, d8);
|
||||
tessellator.addVertexWithUV(d11, (double) y - 0.01D, d19, d6, d9);
|
||||
tessellator.addVertexWithUV(d11, (double) y - 0.01D, d18, d5, d9);
|
||||
tessellator.addVertexWithUV(d10, (double) y - 0.01D, d18, d5, d8);
|
||||
tessellator.addVertexWithUV(d11, (double) y - 0.01D, d19, d6, d8);
|
||||
tessellator.addVertexWithUV(d10, (double) y - 0.01D, d19, d6, d9);
|
||||
tessellator.addVertexWithUV(d10, (double) y - 0.01D, d18, d5, d9);
|
||||
tessellator.addVertexWithUV(d11, (double) y - 0.01D, d18, d5, d8);
|
||||
}
|
||||
|
||||
if (y > 1 && world.isAirBlock(x + 1, y - 1, z))
|
||||
{
|
||||
tessellator.addVertexWithUV(d11, (double) y - 0.01D, d19, d6, d7);
|
||||
tessellator.addVertexWithUV(d12, (double) y - 0.01D, d19, d6, d8);
|
||||
tessellator.addVertexWithUV(d12, (double) y - 0.01D, d18, d5, d8);
|
||||
tessellator.addVertexWithUV(d11, (double) y - 0.01D, d18, d5, d7);
|
||||
tessellator.addVertexWithUV(d12, (double) y - 0.01D, d19, d6, d7);
|
||||
tessellator.addVertexWithUV(d11, (double) y - 0.01D, d19, d6, d8);
|
||||
tessellator.addVertexWithUV(d11, (double) y - 0.01D, d18, d5, d8);
|
||||
tessellator.addVertexWithUV(d12, (double) y - 0.01D, d18, d5, d7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1))
|
||||
{
|
||||
if (flag && !flag1)
|
||||
{
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d13, d0, d3);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d13, d0, d4);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d14, d1, d4);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d14, d1, d3);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d14, d0, d3);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d14, d0, d4);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d13, d1, d4);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d13, d1, d3);
|
||||
|
||||
if (!flag3 && !flag2)
|
||||
{
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1), d14, d5, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 0), d14, d5, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 0), d14, d6, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1), d14, d6, d7);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1), d14, d5, d7);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 0), d14, d5, d9);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 0), d14, d6, d9);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1), d14, d6, d7);
|
||||
}
|
||||
|
||||
if (flag4 || y < l - 1 && world.isAirBlock(x, y + 1, z - 1))
|
||||
{
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d13, d6, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d14, d6, d8);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d14, d5, d8);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d13, d5, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d14, d6, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d13, d6, d8);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d13, d5, d8);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d14, d5, d7);
|
||||
}
|
||||
|
||||
if (flag5 || y > 1 && world.isAirBlock(x, y - 1, z - 1))
|
||||
{
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d13, d6, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d14, d6, d8);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d14, d5, d8);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d13, d5, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d14, d6, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d13, d6, d8);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d13, d5, d8);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d14, d5, d7);
|
||||
}
|
||||
}
|
||||
else if (!flag && flag1)
|
||||
{
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d14, d1, d3);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d14, d1, d4);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d15, d2, d4);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d15, d2, d3);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d15, d1, d3);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d15, d1, d4);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d14, d2, d4);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d14, d2, d3);
|
||||
|
||||
if (!flag3 && !flag2)
|
||||
{
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1), d14, d5, d7);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 0), d14, d5, d9);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 0), d14, d6, d9);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1), d14, d6, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1), d14, d5, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 0), d14, d5, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 0), d14, d6, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1), d14, d6, d7);
|
||||
}
|
||||
|
||||
if (flag4 || y < l - 1 && world.isAirBlock(x, y + 1, z + 1))
|
||||
{
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d14, d5, d8);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d15, d5, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d15, d6, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d14, d6, d8);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d15, d5, d8);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d14, d5, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d14, d6, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d15, d6, d8);
|
||||
}
|
||||
|
||||
if (flag5 || y > 1 && world.isAirBlock(x, y - 1, z + 1))
|
||||
{
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d14, d5, d8);
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d15, d5, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d15, d6, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d14, d6, d8);
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d15, d5, d8);
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d14, d5, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d14, d6, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d15, d6, d8);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d15, d0, d3);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d15, d0, d4);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d13, d2, d4);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d13, d2, d3);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d13, d0, d3);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d13, d0, d4);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 0), d15, d2, d4);
|
||||
tessellator.addVertexWithUV(d11, (double) (y + 1), d15, d2, d3);
|
||||
|
||||
if (flag4)
|
||||
{
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d15, d6, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d13, d6, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d13, d5, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d15, d5, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d13, d6, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d15, d6, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d15, d5, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d13, d5, d9);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (y < l - 1 && world.isAirBlock(x, y + 1, z - 1))
|
||||
{
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d13, d6, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d14, d6, d8);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d14, d5, d8);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d13, d5, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d14, d6, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d13, d6, d8);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d13, d5, d8);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d14, d5, d7);
|
||||
}
|
||||
|
||||
if (y < l - 1 && world.isAirBlock(x, y + 1, z + 1))
|
||||
{
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d14, d5, d8);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d15, d5, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d15, d6, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d14, d6, d8);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d15, d5, d8);
|
||||
tessellator.addVertexWithUV(d16, (double) (y + 1) + 0.005D, d14, d5, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d14, d6, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) (y + 1) + 0.005D, d15, d6, d8);
|
||||
}
|
||||
}
|
||||
|
||||
if (flag5)
|
||||
{
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d15, d6, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d13, d6, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d13, d5, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d15, d5, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d13, d6, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d15, d6, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d15, d5, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d13, d5, d9);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (y > 1 && world.isAirBlock(x, y - 1, z - 1))
|
||||
{
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d13, d6, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d14, d6, d8);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d14, d5, d8);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d13, d5, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d14, d6, d7);
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d13, d6, d8);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d13, d5, d8);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d14, d5, d7);
|
||||
}
|
||||
|
||||
if (y > 1 && world.isAirBlock(x, y - 1, z + 1))
|
||||
{
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d14, d5, d8);
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d15, d5, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d15, d6, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d14, d6, d8);
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d15, d5, d8);
|
||||
tessellator.addVertexWithUV(d16, (double) y - 0.005D, d14, d5, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d14, d6, d9);
|
||||
tessellator.addVertexWithUV(d17, (double) y - 0.005D, d15, d6, d8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,394 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import tconstruct.blocks.PaneBase;
|
||||
import tconstruct.client.TProxyClient;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class PaneRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int model = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == model)
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == model)
|
||||
{
|
||||
return renderPaneInWorld(renderer, world, x, y, z, (PaneBase) block);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public static boolean renderPaneInWorld (RenderBlocks renderblocks, IBlockAccess iblockaccess, int x, int y, int z, PaneBase pane)
|
||||
{
|
||||
int l = iblockaccess.getHeight();
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.setBrightness(pane.getMixedBrightnessForBlock(iblockaccess, x, y, z));
|
||||
float f = 1.0F;
|
||||
int i1 = pane.colorMultiplier(iblockaccess, x, y, z);
|
||||
float f1 = (float) (i1 >> 16 & 0xff) / 255F;
|
||||
float f2 = (float) (i1 >> 8 & 0xff) / 255F;
|
||||
float f3 = (float) (i1 & 0xff) / 255F;
|
||||
if (EntityRenderer.anaglyphEnable)
|
||||
{
|
||||
float f4 = (f1 * 30F + f2 * 59F + f3 * 11F) / 100F;
|
||||
float f5 = (f1 * 30F + f2 * 70F) / 100F;
|
||||
float f6 = (f1 * 30F + f3 * 70F) / 100F;
|
||||
f1 = f4;
|
||||
f2 = f5;
|
||||
f3 = f6;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);
|
||||
boolean flag = false;
|
||||
boolean flag1 = false;
|
||||
Icon icon;
|
||||
Icon icon1;
|
||||
int meta = iblockaccess.getBlockMetadata(x, y, z);
|
||||
icon = renderblocks.getBlockIconFromSideAndMetadata(pane, 0, meta);
|
||||
icon1 = pane.getSideTextureIndex(meta);
|
||||
|
||||
meta = icon.getOriginX();
|
||||
int k1 = icon.getOriginY();
|
||||
double d = (double) icon.getMinU();
|
||||
double d1 = (double) icon.getInterpolatedU(8.0D);
|
||||
double d2 = (double) icon.getMaxU();
|
||||
double d3 = (double) icon.getMinV();
|
||||
double d4 = (double) icon.getMaxV();
|
||||
int l1 = icon1.getOriginX();
|
||||
int i2 = icon1.getOriginY();
|
||||
double d5 = (double) icon1.getInterpolatedU(7.0D);
|
||||
double d6 = (double) icon1.getInterpolatedU(9.0D);
|
||||
double d7 = (double) icon1.getMinV();
|
||||
double d8 = (double) icon1.getInterpolatedV(8.0D);
|
||||
double d9 = (double) icon1.getMaxV();
|
||||
|
||||
/*int blockTextureIndex;
|
||||
int blockSideIndex;
|
||||
|
||||
int j1 = iblockaccess.getBlockMetadata(x, y, z);
|
||||
blockTextureIndex = pane.getBlockTextureFromSideAndMetadata(0, j1);
|
||||
blockSideIndex = pane.getSideTextureIndex(j1);
|
||||
|
||||
int k1 = (blockTextureIndex & 0xf) << 4;
|
||||
int j2 = blockTextureIndex & 0xf0;
|
||||
double d = (float) k1 / 256F;
|
||||
double d1 = ((float) k1 + 7.99F) / 256F;
|
||||
double d2 = ((float) k1 + 15.99F) / 256F;
|
||||
double d3 = (float) j2 / 256F;
|
||||
double d4 = ((float) j2 + 15.99F) / 256F;
|
||||
int k2 = (blockSideIndex & 0xf) << 4;
|
||||
int l2 = blockSideIndex & 0xf0;
|
||||
double d5 = (float) (k2 + 7) / 256F;
|
||||
double d6 = ((float) k2 + 8.99F) / 256F;
|
||||
double d7 = (float) l2 / 256F;
|
||||
double d8 = (float) (l2 + 8) / 256F;
|
||||
double d9 = ((float) l2 + 15.99F) / 256F;*/
|
||||
|
||||
double xBot = x;
|
||||
double xMid = (double) x + 0.5D;
|
||||
double xTop = x + 1;
|
||||
double zBot = z;
|
||||
double zMid = (double) z + 0.5D;
|
||||
double zTop = z + 1;
|
||||
double xMidDown = ((double) x + 0.5D) - 0.0625D;
|
||||
double xMidUp = (double) x + 0.5D + 0.0625D;
|
||||
double zMidDown = ((double) z + 0.5D) - 0.0625D;
|
||||
double zMidUp = (double) z + 0.5D + 0.0625D;
|
||||
boolean west = pane.canConnectTo(iblockaccess.getBlockId(x, y, z - 1));
|
||||
boolean east = pane.canConnectTo(iblockaccess.getBlockId(x, y, z + 1));
|
||||
boolean south = pane.canConnectTo(iblockaccess.getBlockId(x - 1, y, z));
|
||||
boolean north = pane.canConnectTo(iblockaccess.getBlockId(x + 1, y, z));
|
||||
boolean renderAbove = pane.shouldSideBeRendered(iblockaccess, x, y + 1, z, 1);
|
||||
boolean renderBelow = pane.shouldSideBeRendered(iblockaccess, x, y - 1, z, 0);
|
||||
if ((!south || !north) && (south || north || west || east))
|
||||
{
|
||||
if (south && !north)
|
||||
{
|
||||
tessellator.addVertexWithUV(xBot, y + 1, zMidDown, d, d3);
|
||||
tessellator.addVertexWithUV(xBot, y + 0, zMidDown, d, d4);
|
||||
tessellator.addVertexWithUV(xMid, y + 0, zMidDown, d1, d4);
|
||||
tessellator.addVertexWithUV(xMid, y + 1, zMidDown, d1, d3);
|
||||
tessellator.addVertexWithUV(xMid, y + 1, zMidUp, d, d3);
|
||||
tessellator.addVertexWithUV(xMid, y + 0, zMidUp, d, d4);
|
||||
tessellator.addVertexWithUV(xBot, y + 0, zMidUp, d1, d4);
|
||||
tessellator.addVertexWithUV(xBot, y + 1, zMidUp, d1, d3);
|
||||
if (!east && !west)
|
||||
{
|
||||
tessellator.addVertexWithUV(xMid, y + 1, zMidUp, d5, d7);
|
||||
tessellator.addVertexWithUV(xMid, y + 0, zMidUp, d5, d9);
|
||||
tessellator.addVertexWithUV(xMid, y + 0, zMidDown, d6, d9);
|
||||
tessellator.addVertexWithUV(xMid, y + 1, zMidDown, d6, d7);
|
||||
}
|
||||
if (renderAbove || y < l - 1 && iblockaccess.isAirBlock(x - 1, y + 1, z))
|
||||
{
|
||||
tessellator.addVertexWithUV(xBot, (double) (y + 1) + 0.01D, zMidUp, d6, d8);
|
||||
tessellator.addVertexWithUV(xMid, (double) (y + 1) + 0.01D, zMidUp, d6, d9);
|
||||
tessellator.addVertexWithUV(xMid, (double) (y + 1) + 0.01D, zMidDown, d5, d9);
|
||||
tessellator.addVertexWithUV(xBot, (double) (y + 1) + 0.01D, zMidDown, d5, d8);
|
||||
}
|
||||
if (renderBelow || y > 1 && iblockaccess.isAirBlock(x - 1, y - 1, z))
|
||||
{
|
||||
tessellator.addVertexWithUV(xBot, (double) y - 0.01D, zMidUp, d6, d8);
|
||||
tessellator.addVertexWithUV(xMid, (double) y - 0.01D, zMidUp, d6, d9);
|
||||
tessellator.addVertexWithUV(xMid, (double) y - 0.01D, zMidDown, d5, d9);
|
||||
tessellator.addVertexWithUV(xBot, (double) y - 0.01D, zMidDown, d5, d8);
|
||||
}
|
||||
}
|
||||
else if (!south && north)
|
||||
{
|
||||
tessellator.addVertexWithUV(xMid, y + 1, zMidDown, d1, d3);
|
||||
tessellator.addVertexWithUV(xMid, y + 0, zMidDown, d1, d4);
|
||||
tessellator.addVertexWithUV(xTop, y + 0, zMidDown, d2, d4);
|
||||
tessellator.addVertexWithUV(xTop, y + 1, zMidDown, d2, d3);
|
||||
tessellator.addVertexWithUV(xTop, y + 1, zMidUp, d1, d3);
|
||||
tessellator.addVertexWithUV(xTop, y + 0, zMidUp, d1, d4);
|
||||
tessellator.addVertexWithUV(xMid, y + 0, zMidUp, d2, d4);
|
||||
tessellator.addVertexWithUV(xMid, y + 1, zMidUp, d2, d3);
|
||||
if (!east && !west)
|
||||
{
|
||||
tessellator.addVertexWithUV(xMid, y + 1, zMidDown, d5, d7);
|
||||
tessellator.addVertexWithUV(xMid, y + 0, zMidDown, d5, d9);
|
||||
tessellator.addVertexWithUV(xMid, y + 0, zMidUp, d6, d9);
|
||||
tessellator.addVertexWithUV(xMid, y + 1, zMidUp, d6, d7);
|
||||
}
|
||||
if (renderAbove || y < l - 1 && iblockaccess.isAirBlock(x + 1, y + 1, z))
|
||||
{
|
||||
tessellator.addVertexWithUV(xMid, (double) (y + 1) + 0.01D, zMidUp, d6, d7);
|
||||
tessellator.addVertexWithUV(xTop, (double) (y + 1) + 0.01D, zMidUp, d6, d8);
|
||||
tessellator.addVertexWithUV(xTop, (double) (y + 1) + 0.01D, zMidDown, d5, d8);
|
||||
tessellator.addVertexWithUV(xMid, (double) (y + 1) + 0.01D, zMidDown, d5, d7);
|
||||
}
|
||||
if (renderBelow || y > 1 && iblockaccess.isAirBlock(x + 1, y - 1, z))
|
||||
{
|
||||
tessellator.addVertexWithUV(xMid, (double) y - 0.01D, zMidUp, d6, d7);
|
||||
tessellator.addVertexWithUV(xTop, (double) y - 0.01D, zMidUp, d6, d8);
|
||||
tessellator.addVertexWithUV(xTop, (double) y - 0.01D, zMidDown, d5, d8);
|
||||
tessellator.addVertexWithUV(xMid, (double) y - 0.01D, zMidDown, d5, d7);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tessellator.addVertexWithUV(xBot, y + 1, zMidDown, d, d3);
|
||||
tessellator.addVertexWithUV(xBot, y + 0, zMidDown, d, d4);
|
||||
tessellator.addVertexWithUV(xTop, y + 0, zMidDown, d2, d4);
|
||||
tessellator.addVertexWithUV(xTop, y + 1, zMidDown, d2, d3);
|
||||
tessellator.addVertexWithUV(xTop, y + 1, zMidUp, d, d3);
|
||||
tessellator.addVertexWithUV(xTop, y + 0, zMidUp, d, d4);
|
||||
tessellator.addVertexWithUV(xBot, y + 0, zMidUp, d2, d4);
|
||||
tessellator.addVertexWithUV(xBot, y + 1, zMidUp, d2, d3);
|
||||
if (renderAbove)
|
||||
{
|
||||
tessellator.addVertexWithUV(xBot, (double) (y + 1) + 0.01D, zMidUp, d6, d9);
|
||||
tessellator.addVertexWithUV(xTop, (double) (y + 1) + 0.01D, zMidUp, d6, d7);
|
||||
tessellator.addVertexWithUV(xTop, (double) (y + 1) + 0.01D, zMidDown, d5, d7);
|
||||
tessellator.addVertexWithUV(xBot, (double) (y + 1) + 0.01D, zMidDown, d5, d9);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (y < l - 1 && iblockaccess.isAirBlock(x - 1, y + 1, z))
|
||||
{
|
||||
tessellator.addVertexWithUV(xBot, (double) (y + 1) + 0.01D, zMidUp, d6, d8);
|
||||
tessellator.addVertexWithUV(xMid, (double) (y + 1) + 0.01D, zMidUp, d6, d9);
|
||||
tessellator.addVertexWithUV(xMid, (double) (y + 1) + 0.01D, zMidDown, d5, d9);
|
||||
tessellator.addVertexWithUV(xBot, (double) (y + 1) + 0.01D, zMidDown, d5, d8);
|
||||
}
|
||||
if (y < l - 1 && iblockaccess.isAirBlock(x + 1, y + 1, z))
|
||||
{
|
||||
tessellator.addVertexWithUV(xMid, (double) (y + 1) + 0.01D, zMidUp, d6, d7);
|
||||
tessellator.addVertexWithUV(xTop, (double) (y + 1) + 0.01D, zMidUp, d6, d8);
|
||||
tessellator.addVertexWithUV(xTop, (double) (y + 1) + 0.01D, zMidDown, d5, d8);
|
||||
tessellator.addVertexWithUV(xMid, (double) (y + 1) + 0.01D, zMidDown, d5, d7);
|
||||
}
|
||||
}
|
||||
if (renderBelow)
|
||||
{
|
||||
tessellator.addVertexWithUV(xBot, (double) y - 0.01D, zMidUp, d6, d9);
|
||||
tessellator.addVertexWithUV(xTop, (double) y - 0.01D, zMidUp, d6, d7);
|
||||
tessellator.addVertexWithUV(xTop, (double) y - 0.01D, zMidDown, d5, d7);
|
||||
tessellator.addVertexWithUV(xBot, (double) y - 0.01D, zMidDown, d5, d9);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (y > 1 && iblockaccess.isAirBlock(x - 1, y - 1, z))
|
||||
{
|
||||
tessellator.addVertexWithUV(xBot, (double) y - 0.01D, zMidUp, d6, d8);
|
||||
tessellator.addVertexWithUV(xMid, (double) y - 0.01D, zMidUp, d6, d9);
|
||||
tessellator.addVertexWithUV(xMid, (double) y - 0.01D, zMidDown, d5, d9);
|
||||
tessellator.addVertexWithUV(xBot, (double) y - 0.01D, zMidDown, d5, d8);
|
||||
}
|
||||
if (y > 1 && iblockaccess.isAirBlock(x + 1, y - 1, z))
|
||||
{
|
||||
tessellator.addVertexWithUV(xMid, (double) y - 0.01D, zMidUp, d6, d7);
|
||||
tessellator.addVertexWithUV(xTop, (double) y - 0.01D, zMidUp, d6, d8);
|
||||
tessellator.addVertexWithUV(xTop, (double) y - 0.01D, zMidDown, d5, d8);
|
||||
tessellator.addVertexWithUV(xMid, (double) y - 0.01D, zMidDown, d5, d7);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((!west || !east) && (south || north || west || east))
|
||||
{
|
||||
if (west && !east)
|
||||
{
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zBot, d, d3);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 0, zBot, d, d4);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 0, zMid, d1, d4);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zMid, d1, d3);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zMid, d, d3);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 0, zMid, d, d4);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 0, zBot, d1, d4);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zBot, d1, d3);
|
||||
if (!north && !south)
|
||||
{
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zMid, d5, d7);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 0, zMid, d5, d9);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 0, zMid, d6, d9);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zMid, d6, d7);
|
||||
}
|
||||
if (renderAbove || y < l - 1 && iblockaccess.isAirBlock(x, y + 1, z - 1))
|
||||
{
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zBot, d6, d7);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zMid, d6, d8);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zMid, d5, d8);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zBot, d5, d7);
|
||||
}
|
||||
if (renderBelow || y > 1 && iblockaccess.isAirBlock(x, y - 1, z - 1))
|
||||
{
|
||||
tessellator.addVertexWithUV(xMidDown, y, zBot, d6, d7);
|
||||
tessellator.addVertexWithUV(xMidDown, y, zMid, d6, d8);
|
||||
tessellator.addVertexWithUV(xMidUp, y, zMid, d5, d8);
|
||||
tessellator.addVertexWithUV(xMidUp, y, zBot, d5, d7);
|
||||
}
|
||||
}
|
||||
else if (!west && east)
|
||||
{
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zMid, d1, d3);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 0, zMid, d1, d4);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 0, zTop, d2, d4);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zTop, d2, d3);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zTop, d1, d3);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 0, zTop, d1, d4);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 0, zMid, d2, d4);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zMid, d2, d3);
|
||||
if (!north && !south)
|
||||
{
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zMid, d5, d7);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 0, zMid, d5, d9);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 0, zMid, d6, d9);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zMid, d6, d7);
|
||||
}
|
||||
if (renderAbove || y < l - 1 && iblockaccess.isAirBlock(x, y + 1, z + 1))
|
||||
{
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zMid, d5, d8);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zTop, d5, d9);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zTop, d6, d9);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zMid, d6, d8);
|
||||
}
|
||||
if (renderBelow || y > 1 && iblockaccess.isAirBlock(x, y - 1, z + 1))
|
||||
{
|
||||
tessellator.addVertexWithUV(xMidDown, y, zMid, d5, d8);
|
||||
tessellator.addVertexWithUV(xMidDown, y, zTop, d5, d9);
|
||||
tessellator.addVertexWithUV(xMidUp, y, zTop, d6, d9);
|
||||
tessellator.addVertexWithUV(xMidUp, y, zMid, d6, d8);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zTop, d, d3);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 0, zTop, d, d4);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 0, zBot, d2, d4);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zBot, d2, d3);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zBot, d, d3);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 0, zBot, d, d4);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 0, zTop, d2, d4);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zTop, d2, d3);
|
||||
if (renderAbove)
|
||||
{
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zTop, d6, d9);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zBot, d6, d7);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zBot, d5, d7);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zTop, d5, d9);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (y < l - 1 && iblockaccess.isAirBlock(x, y + 1, z - 1))
|
||||
{
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zBot, d6, d7);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zMid, d6, d8);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zMid, d5, d8);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zBot, d5, d7);
|
||||
}
|
||||
if (y < l - 1 && iblockaccess.isAirBlock(x, y + 1, z + 1))
|
||||
{
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zMid, d5, d8);
|
||||
tessellator.addVertexWithUV(xMidDown, y + 1, zTop, d5, d9);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zTop, d6, d9);
|
||||
tessellator.addVertexWithUV(xMidUp, y + 1, zMid, d6, d8);
|
||||
}
|
||||
}
|
||||
if (renderBelow)
|
||||
{
|
||||
tessellator.addVertexWithUV(xMidUp, y, zTop, d6, d9);
|
||||
tessellator.addVertexWithUV(xMidUp, y, zBot, d6, d7);
|
||||
tessellator.addVertexWithUV(xMidDown, y, zBot, d5, d7);
|
||||
tessellator.addVertexWithUV(xMidDown, y, zTop, d5, d9);
|
||||
tessellator.addVertexWithUV(xMidUp, y, zBot, d6, d9);
|
||||
tessellator.addVertexWithUV(xMidUp, y, zTop, d6, d7);
|
||||
tessellator.addVertexWithUV(xMidDown, y, zTop, d5, d7);
|
||||
tessellator.addVertexWithUV(xMidDown, y, zBot, d5, d9);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (y > 1 && iblockaccess.isAirBlock(x, y - 1, z - 1))
|
||||
{
|
||||
tessellator.addVertexWithUV(xMidDown, y, zBot, d6, d7);
|
||||
tessellator.addVertexWithUV(xMidDown, y, zMid, d6, d8);
|
||||
tessellator.addVertexWithUV(xMidUp, y, zMid, d5, d8);
|
||||
tessellator.addVertexWithUV(xMidUp, y, zBot, d5, d7);
|
||||
}
|
||||
if (y > 1 && iblockaccess.isAirBlock(x, y - 1, z + 1))
|
||||
{
|
||||
tessellator.addVertexWithUV(xMidDown, y, zMid, d5, d8);
|
||||
tessellator.addVertexWithUV(xMidDown, y, zTop, d5, d9);
|
||||
tessellator.addVertexWithUV(xMidUp, y, zTop, d6, d9);
|
||||
tessellator.addVertexWithUV(xMidUp, y, zMid, d6, d8);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,409 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import tconstruct.blocks.logic.CastingBasinLogic;
|
||||
import tconstruct.blocks.logic.CastingTableLogic;
|
||||
import tconstruct.blocks.logic.FaucetLogic;
|
||||
import tconstruct.client.TProxyClient;
|
||||
import tconstruct.common.TContent;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class SearedRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int searedModel = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == searedModel)
|
||||
{
|
||||
if (metadata == 0)
|
||||
{
|
||||
//Top
|
||||
renderer.setRenderBounds(0.0F, 0.625F, 0.0F, 1.0F, 0.9375F, 1.0F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
|
||||
//Lip
|
||||
renderer.setRenderBounds(0.0F, 0.9375, 0.0F, 0.0625, 1.0, 1.0F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.0625, 0.9375, 0.9375, 0.9375, 1.0, 1.0F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.9375, 0.9375, 0.0F, 1.0F, 1.0, 1.0F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.0625, 0.9375, 0.0F, 0.9375, 1.0, 0.0625);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
|
||||
//Legs
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.3125F, 0.625F, 0.3125F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.6875, 0.0F, 0.0F, 1.0F, 0.625F, 0.25F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.6875, 0.3125F, 0.625F, 1.0F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.6875, 0.0F, 0.6875, 1.0F, 0.625F, 1.0F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
}
|
||||
else if (metadata == 1)
|
||||
{
|
||||
renderer.setRenderBounds(0.25, 0.25, 0.625, 0.75, 0.375, 1);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.25, 0.25, 0.625, 0.375, 0.625, 1);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.625, 0.25, 0.625, 0.75, 0.625, 1);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.375, 0.375, 0.625, 0.625, 0.625, 1);
|
||||
}
|
||||
else if (metadata == 2)
|
||||
{
|
||||
renderer.setRenderBounds(0.125F, 0.125f, 0.125F, 0.875F, 0.25F, 0.875F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
|
||||
//Details
|
||||
renderer.setRenderBounds(0.001f, 0.1245f, 0.001f, 0.1245f, 0.999f, 0.4375f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.001f, 0.1245f, 0.5625f, 0.1245f, 0.999f, 0.999f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.001f, 0.8755f, 0.4375f, 0.1245f, 0.999f, 0.5625f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.001f, 0.1245f, 0.4375f, 0.1245f, 0.25F, 0.5625f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
|
||||
renderer.setRenderBounds(0.8755f, 0.1245f, 0f, 0.999f, 0.999f, 0.4375f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.8755f, 0.1245f, 0.5625f, 0.999f, 0.999f, 0.999f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.8755f, 0.8755f, 0.4375f, 0.999f, 0.999f, 0.5625f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.8755f, 0.1245f, 0.4375f, 0.999f, 0.25F, 0.5625f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
|
||||
renderer.setRenderBounds(0.1245f, 0.1245f, 0.8755f, 0.4375f, 0.999f, 0.999f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.5625f, 0.1245f, 0.8755f, 0.8755f, 0.999f, 0.999f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.4375f, 0.8755f, 0.8755f, 0.5625f, 0.999f, 0.999f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.4375f, 0.1245f, 0.8755f, 0.5625f, 0.2495F, 0.999f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
|
||||
renderer.setRenderBounds(0.1245f, 0.1245f, 0.001f, 0.4375f, 0.999f, 0.1245f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.5625f, 0.1245f, 0.001f, 0.8755f, 0.999f, 0.1245f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.4375f, 0.8755f, 0.001f, 0.5625f, 0.999f, 0.1245f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.4375f, 0.1245f, 0.001f, 0.5625f, 0.25F, 0.1245f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
|
||||
//Legs
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.3125F, 0.125, 0.3125F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.6875F, 0.0F, 0.0F, 1.0F, 0.125, 0.3125F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.6875F, 0.3125F, 0.125, 1.0F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.6875F, 0.0F, 0.6875F, 1.0F, 0.125, 1.0F);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
|
||||
//Outside
|
||||
renderer.setRenderBounds(0.0f, 0.125, 0f, 0.125, 1.0F, 1);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.875f, 0.125, 0f, 1, 1.0F, 1);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.125f, 0.125, 0f, 0.875f, 1.0F, 0.125f);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.125f, 0.125, 0.875f, 0.875f, 1.0F, 1);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer.setRenderBounds(0, 0, 0, 1, 1, 1);
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == searedModel)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
if (metadata == 0)
|
||||
{
|
||||
//Top
|
||||
renderer.setRenderBounds(0.0F, 0.625F, 0.0F, 1.0F, 0.9375F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
//Lip
|
||||
renderer.setRenderBounds(0.0F, 0.9375, 0.0F, 0.0625, 1.0, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0625, 0.9375, 0.9375, 0.9375, 1.0, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.9375, 0.9375, 0.0F, 1.0F, 1.0, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0625, 0.9375, 0.0F, 0.9375, 1.0, 0.0625);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
//Legs
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.3125F, 0.625F, 0.3125F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.6875, 0.0F, 0.0F, 1.0F, 0.625F, 0.25F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.6875, 0.3125F, 0.625F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.6875, 0.0F, 0.6875, 1.0F, 0.625F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
CastingTableLogic logic = (CastingTableLogic) world.getBlockTileEntity(x, y, z);
|
||||
if (logic.liquid != null)
|
||||
{
|
||||
float height = logic.getLiquidAmount() / (logic.getCapacity() * 1.03F) / 16F;
|
||||
renderer.setRenderBounds(0.0625F, 0.9375F, 0.0625F, 0.9375F, 0.9375F + height, 0.9375F);
|
||||
|
||||
Fluid fluid = logic.liquid.getFluid();
|
||||
BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world);
|
||||
/*if (logic.liquid.fluidID < 4096) //Block
|
||||
{
|
||||
Block liquidBlock = Block.blocksList[logic.liquid.fluidID];
|
||||
if (liquidBlock != null)
|
||||
{
|
||||
//ForgeHooksClient.bindTexture(liquidBlock.getTextureFile(), 0);
|
||||
BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, 0, x, y, z, renderer, world);
|
||||
}
|
||||
}
|
||||
else
|
||||
//Item
|
||||
{
|
||||
Item liquidItem = Item.itemsList[logic.liquid.fluidID];
|
||||
if (liquidItem != null)
|
||||
{
|
||||
//ForgeHooksClient.bindTexture(liquidItem.getTextureFile(), 0);
|
||||
BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(0), x, y, z, renderer, world);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
else if (metadata == 1)
|
||||
{
|
||||
FaucetLogic logic = (FaucetLogic) world.getBlockTileEntity(x, y, z);
|
||||
float xMin = 0.375F, zMin = 0.375F, xMax = 0.625F, zMax = 0.625F;
|
||||
switch (logic.getRenderDirection())
|
||||
{
|
||||
case 2:
|
||||
renderer.setRenderBounds(0.25, 0.25, 0.625, 0.75, 0.375, 1);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.25, 0.375, 0.625, 0.375, 0.625, 1);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.625, 0.375, 0.625, 0.75, 0.625, 1);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.375, 0.375, 0.625, 0.625, 0.625, 1);
|
||||
zMin = 0.5F;
|
||||
//zMin = 0.625F;
|
||||
break;
|
||||
case 3:
|
||||
renderer.setRenderBounds(0.25, 0.25, 0, 0.75, 0.375, 0.375);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.25, 0.375, 0, 0.375, 0.625, 0.375);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.625, 0.375, 0, 0.75, 0.625, 0.375);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.375, 0.375, 0, 0.625, 0.625, 0.375);
|
||||
zMax = 0.5F;
|
||||
break;
|
||||
case 4:
|
||||
renderer.setRenderBounds(0.625, 0.25, 0.25, 1, 0.375, 0.75);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.625, 0.375, 0.25, 1, 0.625, 0.375);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.625, 0.375, 0.625, 1, 0.625, 0.75);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.625, 0.375, 0.375, 1, 0.625, 0.625);
|
||||
xMin = 0.5F;
|
||||
break;
|
||||
case 5:
|
||||
renderer.setRenderBounds(0, 0.25, 0.25, 0.375, 0.375, 0.75);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0, 0.375, 0.25, 0.375, 0.625, 0.375);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0, 0.375, 0.625, 0.375, 0.625, 0.75);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0, 0.375, 0.375, 0.375, 0.625, 0.625);
|
||||
xMax = 0.5F;
|
||||
break;
|
||||
}
|
||||
|
||||
float yMin = 0F;
|
||||
int uID = world.getBlockId(x, y - 1, z);
|
||||
int uMeta = world.getBlockMetadata(x, y - 1, z);
|
||||
if (uID == TContent.searedBlock.blockID && uMeta == 0)
|
||||
{
|
||||
yMin = -0.125F;
|
||||
}
|
||||
else if (uID == TContent.searedBlock.blockID && uMeta == 2)
|
||||
{
|
||||
yMin = -0.75F;
|
||||
}
|
||||
else if (uID == TContent.lavaTank.blockID)
|
||||
{
|
||||
yMin = -1F;
|
||||
}
|
||||
|
||||
if (logic.liquid != null)
|
||||
{
|
||||
Fluid fluid = logic.liquid.getFluid();
|
||||
renderer.setRenderBounds(xMin, yMin, zMin, xMax, 0.625, zMax);
|
||||
BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world);
|
||||
/*if (fluid.canBePlacedInWorld())
|
||||
{
|
||||
Block liquidBlock = Block.blocksList[blockToRender.itemID];
|
||||
BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, 0, x, y, z, renderer, world);
|
||||
renderer.setRenderBounds(xMin, yMin, zMin, xMax, 0.625, zMax);
|
||||
BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, 0, x, y, z, renderer, world);
|
||||
}*/
|
||||
/*ItemStack blockToRender = new ItemStack(logic.liquid.fluidID, 1, logic.liquid.itemMeta);
|
||||
if (blockToRender.itemID < 4096) //Block
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
//Item
|
||||
{
|
||||
Item liquidItem = Item.itemsList[blockToRender.itemID];
|
||||
//ForgeHooksClient.bindTexture(liquidItem.getTextureFile(), 0);
|
||||
int meta = blockToRender.getItemDamage();
|
||||
BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(meta), x, y, z, renderer, world);
|
||||
renderer.setRenderBounds(xMin, yMin, zMin, xMax, 0.625, zMax);
|
||||
BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(meta), x, y, z, renderer, world);
|
||||
}*/
|
||||
//renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
else if (metadata == 2)
|
||||
{
|
||||
renderer.setRenderBounds(0.125F, 0.125f, 0.125F, 0.875F, 0.25F, 0.875F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
//Outside
|
||||
renderer.setRenderBounds(0.0f, 0.125, 0f, 0.125, 1.0F, 1);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.875f, 0.125, 0f, 1, 1.0F, 1);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.125f, 0.125, 0f, 0.875f, 1.0F, 0.125f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.125f, 0.125, 0.875f, 0.875f, 1.0F, 1);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
//Details
|
||||
|
||||
renderer.setRenderBounds(0.001f, 0.1245f, 0.001f, 0.1245f, 0.999f, 0.4375f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.001f, 0.1245f, 0.5625f, 0.1245f, 0.999f, 0.999f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.001f, 0.8755f, 0.4375f, 0.1245f, 0.999f, 0.5625f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.001f, 0.1245f, 0.4375f, 0.1245f, 0.25F, 0.5625f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
renderer.setRenderBounds(0.8755f, 0.1245f, 0f, 0.999f, 0.999f, 0.4375f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.8755f, 0.1245f, 0.5625f, 0.999f, 0.999f, 0.999f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.8755f, 0.8755f, 0.4375f, 0.999f, 0.999f, 0.5625f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.8755f, 0.1245f, 0.4375f, 0.999f, 0.25F, 0.5625f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
renderer.setRenderBounds(0.1245f, 0.1245f, 0.8755f, 0.4375f, 0.999f, 0.999f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.5625f, 0.1245f, 0.8755f, 0.8755f, 0.999f, 0.999f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.4375f, 0.8755f, 0.8755f, 0.5625f, 0.999f, 0.999f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.4375f, 0.1245f, 0.8755f, 0.5625f, 0.2495F, 0.999f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
renderer.setRenderBounds(0.1245f, 0.1245f, 0.001f, 0.4375f, 0.999f, 0.1245f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.5625f, 0.1245f, 0.001f, 0.8755f, 0.999f, 0.1245f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.4375f, 0.8755f, 0.001f, 0.5625f, 0.999f, 0.1245f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.4375f, 0.1245f, 0.001f, 0.5625f, 0.25F, 0.1245f);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
//Legs
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.3125F, 0.125, 0.3125F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.6875F, 0.0F, 0.0F, 1.0F, 0.125, 0.3125F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.6875F, 0.3125F, 0.125, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.6875F, 0.0F, 0.6875F, 1.0F, 0.125, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
//Liquids
|
||||
CastingBasinLogic logic = (CastingBasinLogic) world.getBlockTileEntity(x, y, z);
|
||||
if (logic.liquid != null)
|
||||
{
|
||||
float height = logic.getLiquidAmount() / (logic.getCapacity() * 1.05F) * 0.6875F;
|
||||
renderer.setRenderBounds(0.0625F, 0.25f, 0.0625F, 0.9375F, 0.25f + height, 0.9375F);
|
||||
|
||||
Fluid fluid = logic.liquid.getFluid();
|
||||
BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world);
|
||||
/*if (logic.liquid.itemID < 4096) //Block
|
||||
{
|
||||
Block liquidBlock = Block.blocksList[logic.liquid.itemID];
|
||||
if (liquidBlock != null)
|
||||
{
|
||||
//ForgeHooksClient.bindTexture(liquidBlock.getTextureFile(), 0);
|
||||
BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, logic.liquid.itemMeta, x, y, z, renderer, world);
|
||||
}
|
||||
}
|
||||
else
|
||||
//Item
|
||||
{
|
||||
Item liquidItem = Item.itemsList[logic.liquid.itemID];
|
||||
if (liquidItem != null)
|
||||
{
|
||||
//ForgeHooksClient.bindTexture(liquidItem.getTextureFile(), 0);
|
||||
BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(logic.liquid.itemMeta), x, y, z, renderer, world);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.25F, 0.75F, 0.25F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.0F, 1.0F, 0.75F, 0.25F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.75F, 0.25F, 0.75F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.75F, 1.0F, 0.75F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return searedModel;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,175 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import tconstruct.blocks.logic.SmelteryLogic;
|
||||
import tconstruct.client.TProxyClient;
|
||||
import tconstruct.library.crafting.Smeltery;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class SmelteryRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int smelteryModel = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == smelteryModel)
|
||||
{
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == smelteryModel)
|
||||
{
|
||||
if (world.getBlockMetadata(x, y, z) == 0)
|
||||
return renderSmeltery(world, x, y, z, block, modelID, renderer);
|
||||
else
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean renderSmeltery (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
SmelteryLogic logic = (SmelteryLogic) world.getBlockTileEntity(x, y, z);
|
||||
if (logic.validStructure)
|
||||
{
|
||||
int posX = logic.centerPos.x - 1, posY = logic.centerPos.y, posZ = logic.centerPos.z - 1;
|
||||
//Melting
|
||||
if (logic.getSizeInventory() > 0)
|
||||
{
|
||||
for (int i = 0; i < logic.layers; i++)
|
||||
{
|
||||
renderLayer(logic, i * 9, posX, posY + i, posZ, renderer, world);
|
||||
}
|
||||
}
|
||||
|
||||
//Liquids
|
||||
float base = 0F;
|
||||
int yBase = 0;
|
||||
int liquidBase = 0;
|
||||
for (FluidStack liquid : logic.moltenMetal)
|
||||
{
|
||||
int liquidSize = liquid.amount;
|
||||
while (liquidSize > 0)
|
||||
{
|
||||
int room = 20000 - liquidBase;
|
||||
int countSize = liquidSize > room ? room : liquidSize;
|
||||
liquidSize -= countSize;
|
||||
|
||||
float height = countSize > 20000 ? 1.0F : countSize / 20000F;
|
||||
//renderer.setRenderBounds(0, base, 0, 1, height + base, 1);
|
||||
float renderBase = base;
|
||||
float renderHeight = height + base;
|
||||
base += height;
|
||||
liquidBase += countSize;
|
||||
|
||||
Fluid fluid = liquid.getFluid();
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
float minX = i % 3 == 0 ? -0.001F : 0F;
|
||||
float minZ = i / 3 == 0 ? -0.001F : 0F;
|
||||
float maxX = i % 3 == 2 ? 1.001F : 1F;
|
||||
float maxZ = i / 3 == 2 ? 1.001F : 1F;
|
||||
renderer.setRenderBounds(minX, renderBase, minZ, maxX, renderHeight, maxZ);
|
||||
if (fluid.canBePlacedInWorld())
|
||||
BlockSkinRenderHelper.renderMetadataBlock(Block.blocksList[fluid.getBlockID()], 0, posX + i % 3, posY + yBase, posZ + i / 3, renderer, world);
|
||||
else
|
||||
BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), posX + i % 3, posY + yBase, posZ + i / 3, renderer, world);
|
||||
}
|
||||
/*if (liquid.itemID < 4096) //Block
|
||||
{
|
||||
Block liquidBlock = Block.blocksList[liquid.itemID];
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
float minX = i % 3 == 0 ? -0.001F : 0F;
|
||||
float minZ = i / 3 == 0 ? -0.001F : 0F;
|
||||
float maxX = i % 3 == 2 ? 1.001F : 1F;
|
||||
float maxZ = i / 3 == 2 ? 1.001F : 1F;
|
||||
renderer.setRenderBounds(minX, renderBase, minZ, maxX, renderHeight, maxZ);
|
||||
BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, liquid.itemMeta, posX + i % 3, posY + yBase, posZ + i / 3, renderer, world);
|
||||
}
|
||||
}
|
||||
else
|
||||
//Item
|
||||
{
|
||||
Item liquidItem = Item.itemsList[liquid.itemID];
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
float minX = i % 3 == 0 ? -0.001F : 0F;
|
||||
float minZ = i / 3 == 0 ? -0.001F : 0F;
|
||||
float maxX = i % 3 == 2 ? 1.001F : 1F;
|
||||
float maxZ = i / 3 == 2 ? 1.001F : 1F;
|
||||
renderer.setRenderBounds(minX, renderBase, minZ, maxX, renderHeight, maxZ);
|
||||
BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(liquid.itemMeta), posX, posY + yBase, posZ, renderer, world);
|
||||
}
|
||||
}*/
|
||||
|
||||
if (countSize == room)
|
||||
{
|
||||
base = 0F;
|
||||
yBase++;
|
||||
liquidBase = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void renderLayer (SmelteryLogic logic, int start, int posX, int posY, int posZ, RenderBlocks renderer, IBlockAccess world)
|
||||
{
|
||||
renderer.setRenderBounds(-0.001F, -0.001F, -0.001F, 1.001F, 1.001F, 1.001F);
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
ItemStack input = logic.getStackInSlot(i + start);
|
||||
if (input != null && logic.getTempForSlot(i + start) > 20)
|
||||
{
|
||||
ItemStack blockToRender = Smeltery.getRenderIndex(input);
|
||||
if (blockToRender != null)
|
||||
{
|
||||
float blockHeight = input.stackSize / (float) blockToRender.stackSize;
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, MathHelper.clamp_float(blockHeight, 0.01F, 1.0F), 1.0F);
|
||||
|
||||
if (blockToRender.itemID < 4096) //Block
|
||||
{
|
||||
Block liquidBlock = Block.blocksList[blockToRender.itemID];
|
||||
BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, blockToRender.getItemDamage(), posX + i % 3, posY, posZ + i / 3, renderer, world);
|
||||
}
|
||||
|
||||
/*else //No items, only blocks
|
||||
//Item
|
||||
{
|
||||
Item liquidItem = Item.itemsList[blockToRender.itemID];
|
||||
int metadata = blockToRender.getItemDamage();
|
||||
BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(metadata), posX + i % 3, posY, posZ + i / 3, renderer, world);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return smelteryModel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class TableForgeRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int model = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == model)
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.25F, 0.75F, 0.25F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.0F, 1.0F, 0.75F, 0.25F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.75F, 0.25F, 0.75F, 1.0F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.75F, 1.0F, 0.75F, 1.0F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == model)
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.25F, 0.75F, 0.25F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.0F, 1.0F, 0.75F, 0.25F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.75F, 0.25F, 0.75F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.75F, 1.0F, 0.75F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public static void renderStandardInvBlock (RenderBlocks renderblocks, Block block, int meta)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta));
|
||||
tessellator.draw();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class TableRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int tabelModelID = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == tabelModelID)
|
||||
{
|
||||
if (metadata == 5)
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.0, 0.0F, 1.0F, 0.875F, 1.0F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.25F, 0.75F, 0.25F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.0F, 1.0F, 0.75F, 0.25F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.75F, 0.25F, 0.75F, 1.0F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.75F, 1.0F, 0.75F, 1.0F);
|
||||
renderStandardInvBlock(renderer, block, metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == tabelModelID)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
if (metadata == 5)
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.0, 0.0F, 1.0F, 0.875F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer.setRenderBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 0.25F, 0.75F, 0.25F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.0F, 1.0F, 0.75F, 0.25F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.75F, 0.25F, 0.75F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(0.75F, 0.0F, 0.75F, 1.0F, 0.75F, 1.0F);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return tabelModelID;
|
||||
}
|
||||
|
||||
public static void renderStandardInvBlock (RenderBlocks renderblocks, Block block, int meta)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta));
|
||||
tessellator.draw();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package tconstruct.client.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.blocks.logic.LavaTankLogic;
|
||||
import tconstruct.client.TProxyClient;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class TankRender implements ISimpleBlockRenderingHandler
|
||||
{
|
||||
public static int tankModelID = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == tankModelID)
|
||||
{
|
||||
TProxyClient.renderStandardInvBlock(renderer, block, metadata);
|
||||
if (metadata == 0)
|
||||
{
|
||||
renderer.setRenderBounds(0.1875, 0, 0.1875, 0.8125, 0.125, 0.8125);
|
||||
renderDoRe(renderer, block, metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
if (modelID == tankModelID)
|
||||
{
|
||||
//Liquid
|
||||
LavaTankLogic logic = (LavaTankLogic) world.getBlockTileEntity(x, y, z);
|
||||
if (logic.containsFluid())
|
||||
{
|
||||
FluidStack liquid = logic.tank.getFluid();
|
||||
renderer.setRenderBounds(0.001, 0.001, 0.001, 0.999, logic.getFluidAmountScaled(), 0.999);
|
||||
Fluid fluid = liquid.getFluid();
|
||||
if (fluid.canBePlacedInWorld())
|
||||
BlockSkinRenderHelper.renderMetadataBlock(Block.blocksList[fluid.getBlockID()], 0, x, y, z, renderer, world);
|
||||
else
|
||||
BlockSkinRenderHelper.renderLiquidBlock(fluid.getStillIcon(), fluid.getFlowingIcon(), x, y, z, renderer, world);
|
||||
|
||||
|
||||
renderer.setRenderBounds(00, 0.001, 0.001, 0.999, logic.getFluidAmountScaled(), 0.999);
|
||||
}
|
||||
|
||||
//Block
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 0 && world.getBlockId(x, y + 1, z) == 0)
|
||||
{
|
||||
renderer.setRenderBounds(0.1875, 0, 0.1875, 0.8125, 0.125, 0.8125);
|
||||
renderer.renderStandardBlock(block, x, y + 1, z);
|
||||
}
|
||||
renderer.setRenderBounds(0, 0, 0, 1, 1, 1);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId ()
|
||||
{
|
||||
return tankModelID;
|
||||
}
|
||||
|
||||
private void renderDoRe (RenderBlocks renderblocks, Block block, int meta)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
GL11.glTranslatef(-0.5F, 0.5F, -0.5F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, meta));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, meta));
|
||||
tessellator.draw();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package tconstruct.client.entity;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tconstruct.entity.CartEntity;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class CartRender extends Render
|
||||
{
|
||||
protected ModelBase modelCart;
|
||||
RenderBlocks renderblocks;
|
||||
|
||||
public CartRender()
|
||||
{
|
||||
this.shadowSize = 0.5F;
|
||||
this.modelCart = new ModelPullcart();
|
||||
renderblocks = new RenderBlocks();
|
||||
}
|
||||
|
||||
public void renderPullcart (CartEntity cart, double posX, double posY, double posZ, float par8, float par9)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
long var10 = (long) cart.entityId * 493286711L;
|
||||
var10 = var10 * var10 * 4392167121L + var10 * 98761L;
|
||||
float var12 = (((float) (var10 >> 16 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
|
||||
float var13 = (((float) (var10 >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
|
||||
float var14 = (((float) (var10 >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
|
||||
GL11.glTranslatef(var12, var13, var14);
|
||||
double var15 = cart.lastTickPosX + (cart.posX - cart.lastTickPosX) * (double) par9;
|
||||
double var17 = cart.lastTickPosY + (cart.posY - cart.lastTickPosY) * (double) par9;
|
||||
double var19 = cart.lastTickPosZ + (cart.posZ - cart.lastTickPosZ) * (double) par9;
|
||||
double var21 = 0.30000001192092896D;
|
||||
Vec3 var23 = cart.func_70489_a(var15, var17, var19);
|
||||
float var24 = cart.prevRotationPitch + (cart.rotationPitch - cart.prevRotationPitch) * par9;
|
||||
|
||||
if (var23 != null)
|
||||
{
|
||||
Vec3 var25 = cart.func_70495_a(var15, var17, var19, var21);
|
||||
Vec3 var26 = cart.func_70495_a(var15, var17, var19, -var21);
|
||||
|
||||
if (var25 == null)
|
||||
{
|
||||
var25 = var23;
|
||||
}
|
||||
|
||||
if (var26 == null)
|
||||
{
|
||||
var26 = var23;
|
||||
}
|
||||
|
||||
posX += var23.xCoord - var15;
|
||||
posY += (var25.yCoord + var26.yCoord) / 2.0D - var17;
|
||||
posZ += var23.zCoord - var19;
|
||||
Vec3 var27 = var26.addVector(-var25.xCoord, -var25.yCoord, -var25.zCoord);
|
||||
|
||||
if (var27.lengthVector() != 0.0D)
|
||||
{
|
||||
var27 = var27.normalize();
|
||||
par8 = (float) (Math.atan2(var27.zCoord, var27.xCoord) * 180.0D / Math.PI);
|
||||
var24 = (float) (Math.atan(var27.yCoord) * 73.0D);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glTranslatef((float) posX, (float) posY + 0.3125f, (float) posZ);
|
||||
GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(-var24, 0.0F, 0.0F, 1.0F);
|
||||
float var28 = (float) cart.func_70496_j() - par9;
|
||||
float var30 = (float) cart.getDamage() - par9;
|
||||
|
||||
if (var30 < 0.0F)
|
||||
{
|
||||
var30 = 0.0F;
|
||||
}
|
||||
|
||||
if (var28 > 0.0F)
|
||||
{
|
||||
GL11.glRotatef(MathHelper.sin(var28) * var28 * var30 / 10.0F * (float) cart.func_70493_k(), 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (cart.getCartType() != 0)
|
||||
{
|
||||
//this.loadTexture("/terrain.png");
|
||||
float var29 = 0.75F;
|
||||
GL11.glScalef(var29, var29, var29);
|
||||
|
||||
if (cart.getCartType() == 1)
|
||||
{
|
||||
GL11.glTranslatef(0.0F, 0.5F, 0.0F);
|
||||
renderblocks.renderBlockAsItem(Block.chest, 0, cart.getBrightness(par9));
|
||||
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(0.5F, 0.0F, -0.5F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
else if (cart.getCartType() == 2)
|
||||
{
|
||||
GL11.glTranslatef(0.0F, 0.3125F, 0.0F);
|
||||
renderblocks.renderBlockAsItem(Block.furnaceIdle, 0, cart.getBrightness(par9));
|
||||
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(0.0F, -0.3125F, 0.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
//GL11.glScalef(1.0F / var29, 1.0F / var29, 1.0F / var29);
|
||||
}
|
||||
|
||||
//this.loadTexture("/tinkertextures/entity/pullcart.png");
|
||||
GL11.glScalef(-1.0F, -1.0F, 1.0F);
|
||||
this.modelCart.render(cart, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
|
||||
* handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
|
||||
* (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
|
||||
* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
|
||||
*/
|
||||
public void doRender (Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
|
||||
{
|
||||
this.renderPullcart((CartEntity) par1Entity, par2, par4, par6, par8, par9);
|
||||
}
|
||||
|
||||
protected ResourceLocation func_110775_a(Entity par1Entity)
|
||||
{
|
||||
return texture;
|
||||
}
|
||||
|
||||
static final ResourceLocation texture = new ResourceLocation("assets/tinker/textures/mob/pullcart.png");
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package tconstruct.client.entity;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class CloneHeadModel extends ModelBase
|
||||
{
|
||||
/** The slime's bodies, both the inside box and the outside box */
|
||||
ModelRenderer slimeBodies;
|
||||
ModelRenderer slimeHeadwear;
|
||||
|
||||
public CloneHeadModel(float scale)
|
||||
{
|
||||
this.slimeBodies = new ModelRenderer(this, 0, 0);
|
||||
this.slimeBodies.addBox(-4.0F, 16.0F, -4.0F, 8, 8, 8);
|
||||
this.slimeHeadwear = new ModelRenderer(this, 32, 0);
|
||||
this.slimeHeadwear.addBox(-4.0F, 16.0F, -4.0F, 8, 8, 8, scale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the models various rotation angles then renders the model.
|
||||
*/
|
||||
public void render (Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
|
||||
{
|
||||
this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
|
||||
this.slimeBodies.render(par7);
|
||||
this.slimeHeadwear.render(par7);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 704 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user