mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-22 05:02:39 +00:00
Move to Maven structure
This commit is contained in:
1 parent
ad86fccb88
commit
5cdc894dad
537 files changed
No files matched your search
@@ -0,0 +1,194 @@
|
||||
package tconstruct;
|
||||
|
||||
import tconstruct.achievements.TAchievements;
|
||||
|
||||
import cpw.mods.fml.common.*;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.event.*;
|
||||
import cpw.mods.fml.common.network.*;
|
||||
import cpw.mods.fml.common.registry.*;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.crash.CallableMinecraftVersion;
|
||||
import net.minecraft.world.gen.structure.MapGenStructureIO;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import tconstruct.client.event.EventCloakRender;
|
||||
import tconstruct.common.*;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.crafting.*;
|
||||
import tconstruct.library.util.TabTools;
|
||||
import tconstruct.plugins.PluginController;
|
||||
import tconstruct.util.*;
|
||||
import tconstruct.util.config.*;
|
||||
import tconstruct.util.landmine.behavior.Behavior;
|
||||
import tconstruct.util.landmine.behavior.stackCombo.SpecialStackHandler;
|
||||
import tconstruct.util.player.TPlayerHandler;
|
||||
import tconstruct.worldgen.*;
|
||||
import tconstruct.worldgen.village.*;
|
||||
|
||||
/** TConstruct, the tool mod.
|
||||
* Craft your tools with style, then modify until the original is gone!
|
||||
* @author mDiyo
|
||||
*/
|
||||
|
||||
@Mod(modid = "TConstruct", name = "TConstruct", version = "1.6.X_1.5.3dev", dependencies = "required-after:Forge@[8.9,);after:ForgeMultipart;after:MineFactoryReloaded;after:NotEnoughItems;after:Waila;after:ThermalExpansion")
|
||||
@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 oreLiquidValue = ingotLiquidValue * 2;
|
||||
public static final int blockLiquidValue = ingotLiquidValue * 9;
|
||||
public static final int chunkLiquidValue = ingotLiquidValue / 2;
|
||||
public static final int nuggetLiquidValue = ingotLiquidValue / 9;
|
||||
|
||||
public static final int liquidUpdateAmount = 6;
|
||||
|
||||
// Shared mod logger
|
||||
public static final Logger logger = Logger.getLogger("TConstruct");
|
||||
|
||||
/* 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()
|
||||
{
|
||||
logger.setParent(FMLCommonHandler.instance().getFMLLogger());
|
||||
if (Loader.isModLoaded("Natura"))
|
||||
{
|
||||
TConstruct.logger.info("[TConstruct] Natura, what are we going to do tomorrow night?");
|
||||
TConstruct.logger.info("[Natura] TConstruct, we're going to take over the world!");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
TConstruct.logger.info("[TConstruct] Preparing to take over the world");
|
||||
}
|
||||
|
||||
EnvironmentChecks.verifyEnvironmentSanity();
|
||||
|
||||
PluginController.getController().registerBuiltins();
|
||||
}
|
||||
|
||||
@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();
|
||||
MinecraftForge.EVENT_BUS.register(events);
|
||||
MinecraftForge.EVENT_BUS.register(new TEventHandlerAchievement());
|
||||
content.oreRegistry();
|
||||
|
||||
proxy.registerRenderer();
|
||||
proxy.addNames();
|
||||
proxy.readManuals();
|
||||
proxy.registerKeys();
|
||||
proxy.registerTickHandler();
|
||||
|
||||
GameRegistry.registerWorldGenerator(new TBaseWorldGenerator());
|
||||
MinecraftForge.TERRAIN_GEN_BUS.register(new TerrainGenEventHandler());
|
||||
GameRegistry.registerFuelHandler(content);
|
||||
GameRegistry.registerCraftingHandler(new TCraftingHandler());
|
||||
NetworkRegistry.instance().registerGuiHandler(instance, proxy);
|
||||
|
||||
if (PHConstruct.addToVillages)
|
||||
{
|
||||
// adds to the villager spawner egg
|
||||
VillagerRegistry.instance().registerVillagerId(78943);
|
||||
// moved down, not needed if 'addToVillages' is false
|
||||
VillagerRegistry.instance().registerVillageTradeHandler(78943, new TVillageTrades());
|
||||
VillagerRegistry.instance().registerVillageCreationHandler(new VillageToolStationHandler());
|
||||
VillagerRegistry.instance().registerVillageCreationHandler(new VillageSmelteryHandler());
|
||||
try
|
||||
{
|
||||
if (new CallableMinecraftVersion(null).minecraftVersion().equals("1.6.4"))
|
||||
{
|
||||
MapGenStructureIO.func_143031_a(ComponentToolWorkshop.class, "TConstruct:ToolWorkshopStructure");
|
||||
MapGenStructureIO.func_143031_a(ComponentSmeltery.class, "TConstruct:SmelteryStructure");
|
||||
}
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
playerTracker = new TPlayerHandler();
|
||||
GameRegistry.registerPlayerTracker(playerTracker);
|
||||
MinecraftForge.EVENT_BUS.register(playerTracker);
|
||||
|
||||
PluginController.getController().preInit();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init (FMLInitializationEvent event)
|
||||
{
|
||||
if (event.getSide() == Side.CLIENT)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(new EventCloakRender());
|
||||
}
|
||||
|
||||
content.intermodCommunication();
|
||||
TwilightForestConfig.initProps(PHConstruct.cfglocation);
|
||||
BOPConfig.initProps(PHConstruct.cfglocation);
|
||||
DimensionBlacklist.getbaddimensions();
|
||||
GameRegistry.registerWorldGenerator(new SlimeIslandGen(TContent.slimePool.blockID, 0));
|
||||
|
||||
PluginController.getController().init();
|
||||
|
||||
if(PHConstruct.achievementsEnabled){
|
||||
TAchievements.init();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit (FMLPostInitializationEvent evt)
|
||||
{
|
||||
proxy.postInit();
|
||||
Behavior.registerBuiltInBehaviors();
|
||||
SpecialStackHandler.registerBuiltInStackHandlers();
|
||||
content.modIntegration();
|
||||
content.addOreDictionarySmelteryRecipes();
|
||||
content.createEntities();
|
||||
content.modRecipes();
|
||||
|
||||
PluginController.getController().postInit();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package tconstruct.achievements;
|
||||
|
||||
import java.util.HashMap;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.AchievementPage;
|
||||
|
||||
public class TAchievements {
|
||||
|
||||
//Add achievements in here before the load executes(end of TC's init event)
|
||||
public static HashMap<String, Achievement> achievements = new HashMap<String, Achievement>();
|
||||
|
||||
//Warning: Will be null until after the init stage
|
||||
public static AchievementPage achievementPage = null;
|
||||
|
||||
public static void init(){
|
||||
Achievement[] achs = new Achievement[achievements.values().size()];
|
||||
|
||||
for(int i = 0; i < achs.length; i++){
|
||||
achs[i] = (Achievement)achievements.values().toArray()[i];
|
||||
}
|
||||
|
||||
achievementPage = new AchievementPage(StatCollector.translateToLocal("tconstruct.achievementPage.name"), achs);
|
||||
|
||||
AchievementPage.registerAchievementPage(achievementPage);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,671 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import static net.minecraftforge.common.ForgeDirection.DOWN;
|
||||
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.UP;
|
||||
import static net.minecraftforge.common.ForgeDirection.WEST;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.EnumMobType;
|
||||
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.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityTNTPrimed;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.LandmineExplodeLogic;
|
||||
import tconstruct.blocks.logic.TileEntityLandmine;
|
||||
import tconstruct.client.block.RenderLandmine;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.util.landmine.Helper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class BlockLandmine extends BlockContainer
|
||||
{
|
||||
|
||||
// Should explode when broken instead of dropping items(may not actually work
|
||||
boolean explodeOnBroken = false;
|
||||
|
||||
public BlockLandmine(int par1)
|
||||
{
|
||||
super(par1, Material.tnt);
|
||||
this.setTickRandomly(true);
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F - 0.0625F, 0.0625F, 1.0F - 0.0625F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
if (world.getBlockId(x, y, z) == this.blockID && world.getBlockTileEntity(x, y, z) instanceof TileEntityLandmine)
|
||||
{
|
||||
TileEntityLandmine te = (TileEntityLandmine) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (te != null)
|
||||
{
|
||||
if (te.getStackInSlot(3) != null)
|
||||
{
|
||||
return lightValue[te.getStackInSlot(3).itemID];
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getLightValue(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int tickRate (World par1World)
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getBlockTexture (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
TileEntityLandmine te = (TileEntityLandmine) par1IBlockAccess.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
ItemStack camo = te.getStackInSlot(3);
|
||||
if (camo != null && camo.itemID < blocksList.length)
|
||||
{
|
||||
return Block.blocksList[camo.itemID].getIcon(par5, camo.getItemDamage());
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.getIcon(par5, par1IBlockAccess.getBlockMetadata(par2, par3, par4));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return RenderLandmine.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked (World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
|
||||
{
|
||||
super.onBlockClicked(par1World, par2, par3, par4, par5EntityPlayer);
|
||||
|
||||
if (this.explodeOnBroken)
|
||||
{
|
||||
checkExplosion(par1World, par2, par3, par4, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons (IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon("tinker:Landmine");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated (World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
par5EntityPlayer.openGui(TConstruct.instance, TProxyCommon.landmineID, par1World, par2, par3, par4);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock (World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
TileEntityLandmine tileentity = (TileEntityLandmine) par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
int metadata = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if (tileentity != null && (!explodeOnBroken || !hasItems(par1World, par2, par3, par4)) && par6 != 193 && !tileentity.isExploding)
|
||||
{
|
||||
int id = this.blockID;
|
||||
if (id > 0)
|
||||
{
|
||||
ItemStack is = new ItemStack(id, 1, damageDropped(tileentity.triggerType));
|
||||
if (tileentity.isInvNameLocalized())
|
||||
{
|
||||
is.setItemName(tileentity.getInvName());
|
||||
}
|
||||
dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(id, 1, damageDropped(tileentity.triggerType)));
|
||||
}
|
||||
|
||||
for (int j1 = 0; j1 < tileentity.getSizeInventory(); ++j1)
|
||||
{
|
||||
ItemStack itemstack = tileentity.getStackInSlot(j1);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
while (itemstack.stackSize > 0)
|
||||
{
|
||||
|
||||
int ss = itemstack.stackSize;
|
||||
itemstack.stackSize -= ss;
|
||||
EntityItem entityitem = new EntityItem(par1World, (double) ((float) par2), (double) ((float) par3), (double) ((float) par4), new ItemStack(itemstack.itemID, ss,
|
||||
itemstack.getItemDamage()));
|
||||
|
||||
if (itemstack.hasTagCompound())
|
||||
{
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = (double) (f3);
|
||||
entityitem.motionY = (double) (f3 + 0.2F);
|
||||
entityitem.motionZ = (double) (f3);
|
||||
par1World.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
par1World.func_96440_m(par2, par3, par4, par5);
|
||||
}
|
||||
else if (explodeOnBroken)
|
||||
{
|
||||
checkExplosion(par1World, par2, par3, par4, true);
|
||||
}
|
||||
|
||||
super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, 0));
|
||||
par3List.add(new ItemStack(par1, 1, 1));
|
||||
par3List.add(new ItemStack(par1, 1, 2));
|
||||
par3List.add(new ItemStack(par1, 1, 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBlocksMovement (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockOnSide (World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(par5);
|
||||
return (dir == DOWN && par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN)) || (dir == UP && par1World.isBlockSolidOnSide(par2, par3 - 1, par4, UP))
|
||||
|| (dir == NORTH && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH)) || (dir == SOUTH && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH))
|
||||
|| (dir == WEST && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST)) || (dir == EAST && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST) || par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST) || par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH)
|
||||
|| par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH) || par1World.isBlockSolidOnSide(par2, par3 - 1, par4, UP) || par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced (World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
|
||||
{
|
||||
int j1 = par9 & 8;
|
||||
int k1 = par9 & 7;
|
||||
byte b0 = -1;
|
||||
|
||||
if (par5 == 0 && par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN))
|
||||
{
|
||||
b0 = 0;
|
||||
}
|
||||
|
||||
if (par5 == 1 && par1World.isBlockSolidOnSide(par2, par3 - 1, par4, UP))
|
||||
{
|
||||
b0 = 5;
|
||||
}
|
||||
|
||||
if (par5 == 2 && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH))
|
||||
{
|
||||
b0 = 4;
|
||||
}
|
||||
|
||||
if (par5 == 3 && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH))
|
||||
{
|
||||
b0 = 3;
|
||||
}
|
||||
|
||||
if (par5 == 4 && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST))
|
||||
{
|
||||
b0 = 2;
|
||||
}
|
||||
|
||||
if (par5 == 5 && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST))
|
||||
{
|
||||
b0 = 1;
|
||||
}
|
||||
|
||||
return b0 + j1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
int l = par1World.getBlockMetadata(par2, par3, par4);
|
||||
int i1 = l & 7;
|
||||
int j1 = l & 8;
|
||||
|
||||
if (i1 == invertMetadata(1))
|
||||
{
|
||||
if ((MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 1) == 0)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 5 | j1, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 6 | j1, 2);
|
||||
}
|
||||
}
|
||||
else if (i1 == invertMetadata(0))
|
||||
{
|
||||
if ((MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 1) == 0)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 7 | j1, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | j1, 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (par6ItemStack.hasDisplayName())
|
||||
{
|
||||
((TileEntityLandmine) par1World.getBlockTileEntity(par2, par3, par4)).setGuiDisplayName(par6ItemStack.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
public static int invertMetadata (int par0)
|
||||
{
|
||||
switch (par0)
|
||||
{
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
return 5;
|
||||
case 2:
|
||||
return 4;
|
||||
case 3:
|
||||
return 3;
|
||||
case 4:
|
||||
return 2;
|
||||
case 5:
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange (World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
checkPlacement(par1World, par2, par3, par4, par5);
|
||||
|
||||
checkExplosion(par1World, par2, par3, par4, false);
|
||||
}
|
||||
|
||||
public void checkPlacement (World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (this.checkIfAttachedToBlock(par1World, par2, par3, par4))
|
||||
{
|
||||
int i1 = par1World.getBlockMetadata(par2, par3, par4) & 7;
|
||||
boolean flag = false;
|
||||
|
||||
if (!par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST) && i1 == 1)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST) && i1 == 2)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH) && i1 == 3)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH) && i1 == 4)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isBlockSolidOnSide(par2, par3 - 1, par4, UP) && i1 == 5)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isBlockSolidOnSide(par2, par3 - 1, par4, UP) && i1 == 6)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN) && i1 == 0)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isBlockSolidOnSide(par2, par3 + 1, par4, DOWN) && i1 == 7)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkIfAttachedToBlock (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (!this.canPlaceBlockAt(par1World, par2, par3, par4))
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick (World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
checkExplosion(par1World, par2, par3, par4, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void onEntityCollidedWithBlock (World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
this.checkExplosion(par1World, par2, par3, par4, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkExplosion (World par1World, int par2, int par3, int par4, boolean skipCheck)
|
||||
{
|
||||
if (skipCheck || getMineState(par1World, par2, par3, par4) > 0)
|
||||
{
|
||||
if (hasItems(par1World, par2, par3, par4))
|
||||
{
|
||||
TileEntityLandmine te = (TileEntityLandmine) par1World.getBlockTileEntity(par2, par3, par4);
|
||||
if (te.soundcountything <= 0)
|
||||
{
|
||||
par1World.playSoundEffect((double) par2 + 0.5D, (double) par3 + 0.1D, (double) par4 + 0.5D, "random.click", 0.3F, 0.6F);
|
||||
te.setSoundPlayed();
|
||||
}
|
||||
new LandmineExplodeLogic(par1World, par2, par3, par4, getMineTriggerer(par1World, par2, par3, par4)).explode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean hasItems (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
TileEntityLandmine te = (TileEntityLandmine) par1World.getBlockTileEntity(par2, par3, par4);
|
||||
if (te != null && te.getStackInSlot(0) != null || te.getStackInSlot(1) != null || te.getStackInSlot(2) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected int getMineState (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
EnumMobType triggerMobType;
|
||||
|
||||
TileEntityLandmine te = (TileEntityLandmine) par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
// Change to return 1 if you want the landmine to blow up when the block
|
||||
// holding it is broken
|
||||
if (te == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
switch (te.triggerType)
|
||||
{
|
||||
case 0:
|
||||
triggerMobType = EnumMobType.everything;
|
||||
break;
|
||||
case 1:
|
||||
triggerMobType = EnumMobType.mobs;
|
||||
break;
|
||||
case 2:
|
||||
triggerMobType = EnumMobType.players;
|
||||
break;
|
||||
default:
|
||||
triggerMobType = null;
|
||||
break;
|
||||
}
|
||||
|
||||
if (triggerMobType != null)
|
||||
{
|
||||
List list = null;
|
||||
|
||||
if (triggerMobType == EnumMobType.everything)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABBExcludingEntity((Entity) null, getSensitiveAABB(par1World, par2, par3, par4));
|
||||
}
|
||||
|
||||
if (triggerMobType == EnumMobType.mobs)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABB(EntityLivingBase.class, getSensitiveAABB(par1World, par2, par3, par4));
|
||||
}
|
||||
|
||||
if (triggerMobType == EnumMobType.players)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABB(EntityPlayer.class, this.getSensitiveAABB(par1World, par2, par3, par4));
|
||||
}
|
||||
|
||||
if (list != null && !list.isEmpty())
|
||||
{
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
if (!entity.doesEntityNotTriggerPressurePlate())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1World.isBlockIndirectlyGettingPowered(par2, par3, par4) ? 1 : 0;
|
||||
}
|
||||
|
||||
protected AxisAlignedBB getSensitiveAABB (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
float f = 0.125F;
|
||||
// return AxisAlignedBB.getAABBPool().getAABB((double)((float)par1 + f), (double)par2, (double)((float)par3 + f), (double)((float)(par1 + 1) - f), (double)par2 + 0.25D, (double)((float)(par3 + 1) - f));
|
||||
|
||||
int l = par1World.getBlockMetadata(par2, par3, par4);
|
||||
int i1 = l & 7;
|
||||
boolean flag = (l & 8) > 0;
|
||||
|
||||
float minX = par2 + f, minY = par3, minZ = par4 + f, maxX = par2 + 1 - f, maxY = par3 + 0.25F, maxZ = par4 + 1 - f;
|
||||
|
||||
ForgeDirection dir = Helper.convertMetaToForgeOrientation(i1);
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
break;
|
||||
case UP:
|
||||
minY = par3 + 0.75F;
|
||||
maxY = par3 + 1;
|
||||
break;
|
||||
default:
|
||||
minX = par2;
|
||||
minY = par3;
|
||||
minZ = par4;
|
||||
maxX = par2 + 1;
|
||||
maxY = par3 + 1;
|
||||
maxZ = par4 + 1;
|
||||
}
|
||||
return AxisAlignedBB.getAABBPool().getAABB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
public Entity getMineTriggerer (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
|
||||
EnumMobType triggerMobType;
|
||||
|
||||
TileEntityLandmine te = (TileEntityLandmine) par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
// Change to return 1 if you want the landmine to blow up when the
|
||||
// block holding it is broken
|
||||
if (te == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
switch (te.triggerType)
|
||||
{
|
||||
case 0:
|
||||
triggerMobType = EnumMobType.everything;
|
||||
break;
|
||||
case 1:
|
||||
triggerMobType = EnumMobType.mobs;
|
||||
break;
|
||||
case 2:
|
||||
triggerMobType = EnumMobType.players;
|
||||
break;
|
||||
default:
|
||||
triggerMobType = null;
|
||||
break;
|
||||
}
|
||||
|
||||
if (triggerMobType != null)
|
||||
{
|
||||
List list = null;
|
||||
|
||||
if (triggerMobType == EnumMobType.everything)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABBExcludingEntity((Entity) null, AxisAlignedBB.getAABBPool().getAABB(par2 + 0D, par3 + 0D, par4 + 0D, par2 + 1D, par3 + 1D, par4 + 1D));
|
||||
}
|
||||
|
||||
if (triggerMobType == EnumMobType.mobs)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getAABBPool().getAABB(par2 + 0D, par3 + 0D, par4 + 0D, par2 + 1D, par3 + 1D, par4 + 1D));
|
||||
}
|
||||
|
||||
if (triggerMobType == EnumMobType.players)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getAABBPool().getAABB(par2 + 0D, par3 + 0D, par4 + 0D, par2 + 1D, par3 + 1D, par4 + 1D));
|
||||
}
|
||||
|
||||
if (list != null && !list.isEmpty())
|
||||
{
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
if (!entity.doesEntityNotTriggerPressurePlate())
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new EntityTNTPrimed(par1World, par2, par3, par4, (EntityLivingBase) null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropFromExplosion (Explosion par1Explosion)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
int l = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
|
||||
int i1 = l & 7;
|
||||
boolean flag = (l & 8) > 0;
|
||||
|
||||
ForgeDirection dir = Helper.convertMetaToForgeOrientation(i1);
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F - 0.0625F, 0.0625F, 1.0F - 0.0625F);
|
||||
break;
|
||||
case UP:
|
||||
this.setBlockBounds(0.0625F, 1.0F - 0.0625F, 0.0625F, 1.0F - 0.0625F, 1.0F, 1.0F - 0.0625F);
|
||||
break;
|
||||
case NORTH:
|
||||
this.setBlockBounds(0.0625F, 0.0625F, 0.0F, 1.0F - 0.0625F, 1.0F - 0.0625F, 0.0625F);
|
||||
break;
|
||||
case SOUTH:
|
||||
this.setBlockBounds(0.0625F, 0.0625F, 1.0F - 0.0625F, 1.0F - 0.0625F, 1.0F - 0.0625F, 1.0F);
|
||||
break;
|
||||
case EAST:
|
||||
this.setBlockBounds(1.0F - 0.0625F, 0.0625F, 0.0625F, 1.0F, 1.0F - 0.0625F, 1.0F - 0.0625F);
|
||||
break;
|
||||
case WEST:
|
||||
this.setBlockBounds(0.0F, 0.0625F, 0.0625F, 0.0625F, 1.0F - 0.0625F, 1.0F - 0.0625F);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int idDropped (int par1, Random par2Random, int par3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world)
|
||||
{
|
||||
return new TileEntityLandmine();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
public class BloodBlock extends TConstructFluid
|
||||
{
|
||||
|
||||
public BloodBlock(int id, Fluid fluid, Material material, String texture)
|
||||
{
|
||||
super(id, fluid, material, texture);
|
||||
}
|
||||
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.field_76434_w.id, 20*15, 0));
|
||||
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.poison.id, 20*5, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import tconstruct.blocks.logic.CastingChannelLogic;
|
||||
import tconstruct.client.block.BlockRenderCastingChannel;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
/**
|
||||
* @author BluSunrize
|
||||
*/
|
||||
|
||||
public class CastingChannelBlock extends BlockContainer
|
||||
{
|
||||
|
||||
public CastingChannelBlock(int par1)
|
||||
{
|
||||
super(par1, Material.rock);
|
||||
this.setHardness(1F);
|
||||
this.setResistance(10);
|
||||
this.setStepSound(soundStoneFootstep);
|
||||
setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
CastingChannelLogic tile = (CastingChannelLogic) world.getBlockTileEntity(x, y, z);
|
||||
if (player.isSneaking())
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
//int amount = 0;
|
||||
//if (tile.getFluid() != null)
|
||||
//amount = tile.getLiquidAmount();
|
||||
//player.addChatMessage("LiquidAmount: " + amount);
|
||||
tile.setActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack != null && stack.itemID == this.blockID)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
CastingChannelLogic tile = (CastingChannelLogic) world.getBlockTileEntity(x, y, z);
|
||||
float minX = 0.3125F;
|
||||
float maxX = 0.6875F;
|
||||
float minZ = 0.3125F;
|
||||
float maxZ = 0.6875F;
|
||||
if (tile.hasTankConnected(ForgeDirection.NORTH))
|
||||
minZ = 0F;
|
||||
if (tile.hasTankConnected(ForgeDirection.SOUTH))
|
||||
maxZ = 1F;
|
||||
if (tile.hasTankConnected(ForgeDirection.WEST))
|
||||
minX = 0F;
|
||||
if (tile.hasTankConnected(ForgeDirection.EAST))
|
||||
maxX = 1F;
|
||||
|
||||
this.setBlockBounds(minX, 0.375F, minZ, maxX, 0.625F, maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return BlockRenderCastingChannel.renderID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
this.blockIcon = iconRegister.registerIcon("tinker:searedstone");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World var1)
|
||||
{
|
||||
return new CastingChannelLogic();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
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.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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;
|
||||
import tconstruct.client.block.SlimeChannelRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ConveyorBase extends Block
|
||||
{
|
||||
String textureName;
|
||||
public ConveyorBase(int ID, Material material, String name)
|
||||
{
|
||||
super(ID, material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
setBlockBounds(0f, 0f, 0f, 1f, 0.5f, 1f);
|
||||
textureName = name;
|
||||
}
|
||||
|
||||
public boolean isBlockReplaceable (World world, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (!world.isBlockIndirectlyGettingPowered(x, y, z))
|
||||
{
|
||||
double moveX = 0;
|
||||
double moveZ = 0;
|
||||
|
||||
double speed = 0.01;
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta % 8)
|
||||
{
|
||||
case 6:
|
||||
moveX += speed;
|
||||
break;
|
||||
case 7:
|
||||
moveX += speed;
|
||||
moveZ += speed;
|
||||
break;
|
||||
case 0:
|
||||
moveZ += speed;
|
||||
break;
|
||||
case 1:
|
||||
moveZ += speed;
|
||||
moveX -= speed;
|
||||
break;
|
||||
case 2:
|
||||
moveX -= speed;
|
||||
break;
|
||||
case 3:
|
||||
moveX -= speed;
|
||||
moveZ -= speed;
|
||||
break;
|
||||
case 4:
|
||||
moveZ -= speed;
|
||||
break;
|
||||
case 5:
|
||||
moveZ -= speed;
|
||||
moveX += speed;
|
||||
break;
|
||||
}
|
||||
|
||||
entity.addVelocity(moveX, 0, moveZ);
|
||||
}
|
||||
|
||||
if (entity instanceof EntityItem)
|
||||
{
|
||||
((EntityItem) entity).age = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack)
|
||||
{
|
||||
int face = MathHelper.floor_double((double) (entity.rotationYaw * 8.0F / 360.0F) + 0.5D) + (entity.isSneaking() ? 4 : 0) & 7;
|
||||
int meta = world.getBlockMetadata(x, y, z) & 8;
|
||||
world.setBlockMetadataWithNotify(x, y, z, face | meta, 2);
|
||||
}
|
||||
|
||||
public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
if (side == 1)
|
||||
return false;
|
||||
return super.shouldSideBeRendered(world, x, y, z, side);
|
||||
}
|
||||
|
||||
public Icon[] icons;
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return SlimeChannelRender.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
String[] textureNames = new String[] { textureName, textureName+"_flow" };
|
||||
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)
|
||||
{
|
||||
if (meta >= 8)
|
||||
return icons[0];
|
||||
return side == 1 ? icons[1] : icons[0];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.CraftingStationLogic;
|
||||
import tconstruct.blocks.logic.PartBuilderLogic;
|
||||
import tconstruct.blocks.logic.PatternChestLogic;
|
||||
import tconstruct.blocks.logic.StencilTableLogic;
|
||||
import tconstruct.blocks.logic.ToolForgeLogic;
|
||||
import tconstruct.blocks.logic.ToolStationLogic;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventorySlab;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
public class CraftingSlab extends InventorySlab
|
||||
{
|
||||
public CraftingSlab(int id, Material material)
|
||||
{
|
||||
super(id, material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setHardness(2f);
|
||||
this.setStepSound(Block.soundWoodFootstep);
|
||||
}
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "craftingstation_top", "craftingstation_slab_side", "craftingstation_bottom", "toolstation_top", "toolstation_slab_side", "toolstation_bottom",
|
||||
"partbuilder_oak_top", "partbuilder_slab_side", "partbuilder_oak_bottom", "stenciltable_oak_top", "stenciltable_slab_side", "stenciltable_oak_bottom", "patternchest_top",
|
||||
"patternchest_slab_side", "patternchest_bottom", "toolforge_top", "toolforge_slab_side", "toolforge_top" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[(meta % 8) * 3 + getTextureIndex(side)];
|
||||
}
|
||||
|
||||
public int getTextureIndex (int side)
|
||||
{
|
||||
if (side == 0)
|
||||
return 2;
|
||||
if (side == 1)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
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 % 8)
|
||||
{
|
||||
case 0:
|
||||
return new CraftingStationLogic();
|
||||
case 1:
|
||||
return new ToolStationLogic();
|
||||
case 2:
|
||||
return new PartBuilderLogic();
|
||||
case 3:
|
||||
return new StencilTableLogic();
|
||||
case 4:
|
||||
return new PatternChestLogic();
|
||||
case 5:
|
||||
return new ToolForgeLogic();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z) % 8;
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return TProxyCommon.craftingStationID;
|
||||
case 1:
|
||||
return TProxyCommon.toolStationID;
|
||||
case 2:
|
||||
return TProxyCommon.partBuilderID;
|
||||
case 3:
|
||||
return TProxyCommon.stencilTableID;
|
||||
case 4:
|
||||
return TProxyCommon.patternChestID;
|
||||
case 5:
|
||||
return TProxyCommon.toolForgeID;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack)
|
||||
{
|
||||
if (PHConstruct.freePatterns)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 4)
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
super.onBlockPlacedBy(world, x, y, z, entityliving, stack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
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.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.CraftingStationLogic;
|
||||
import tconstruct.client.block.TableRender;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
|
||||
public class CraftingStationBlock extends InventoryBlock
|
||||
{
|
||||
public CraftingStationBlock(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 = { "craftingstation_top", "craftingstation_side", "craftingstation_bottom" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[meta * 3 + getTextureIndex(side)];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
return new CraftingStationLogic();
|
||||
/*switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
return new CraftingStationLogic();
|
||||
default:
|
||||
return null;
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
return TProxyCommon.craftingStationID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 1; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
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.wood);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
setHardness(2.0f);
|
||||
setStepSound(soundMetalFootstep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
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,190 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import tconstruct.blocks.logic.EquipLogic;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cpw.mods.fml.relauncher.*;
|
||||
|
||||
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.*;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.*;
|
||||
|
||||
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 void onBlockPlacedBy (World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
|
||||
int i3 = MathHelper.floor_double((par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
|
||||
int newMeta = 0;
|
||||
|
||||
switch (i3)
|
||||
{
|
||||
case 3:
|
||||
newMeta = 0;
|
||||
break;
|
||||
case 0:
|
||||
newMeta = 3;
|
||||
break;
|
||||
case 1:
|
||||
newMeta = 1;
|
||||
break;
|
||||
case 2:
|
||||
newMeta = 2;
|
||||
break;
|
||||
}
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, newMeta, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock (World par1World, int x, int y, int z, int par5, int meta)
|
||||
{
|
||||
TileEntity te = par1World.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (te != null && te instanceof EquipLogic)
|
||||
{
|
||||
EquipLogic logic = (EquipLogic) te;
|
||||
for (int iter = 0; iter < logic.getSizeInventory(); ++iter)
|
||||
{
|
||||
ItemStack stack = iter == 0 ? logic.getEquipmentItem() : logic.getStackInSlot(iter);
|
||||
|
||||
if (stack != null && logic.canDropInventorySlot(iter))
|
||||
{
|
||||
float jumpX = rand.nextFloat() * 0.8F + 0.1F;
|
||||
float jumpY = rand.nextFloat() * 0.8F + 0.1F;
|
||||
float jumpZ = rand.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (stack.stackSize > 0)
|
||||
{
|
||||
int itemSize = rand.nextInt(21) + 10;
|
||||
|
||||
if (itemSize > stack.stackSize)
|
||||
{
|
||||
itemSize = stack.stackSize;
|
||||
}
|
||||
|
||||
stack.stackSize -= itemSize;
|
||||
EntityItem entityitem = new EntityItem(par1World, (double) ((float) x + jumpX), (double) ((float) y + jumpY), (double) ((float) z + jumpZ), new ItemStack(stack.itemID,
|
||||
itemSize, stack.getItemDamage()));
|
||||
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
float offset = 0.05F;
|
||||
entityitem.motionX = (double) ((float) rand.nextGaussian() * offset);
|
||||
entityitem.motionY = (double) ((float) rand.nextGaussian() * offset + 0.2F);
|
||||
entityitem.motionZ = (double) ((float) rand.nextGaussian() * offset);
|
||||
par1World.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(par1World, x, y, z, par5, meta);
|
||||
}
|
||||
|
||||
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,115 @@
|
||||
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.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 tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.FurnaceLogic;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventorySlab;
|
||||
import tconstruct.library.util.IActiveLogic;
|
||||
import tconstruct.library.util.IFacingLogic;
|
||||
|
||||
public class FurnaceSlab extends InventorySlab
|
||||
{
|
||||
|
||||
public FurnaceSlab(int id, Material material)
|
||||
{
|
||||
super(id, material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setHardness(3.5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
switch (metadata % 8)
|
||||
{
|
||||
case 0:
|
||||
return new FurnaceLogic();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
return TProxyCommon.furnaceID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "furnaceslab_front", "furnaceslab_front_active", "furnaceslab_side", "furnace_top" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[(meta % 8) * 3 + getTextureIndex(side)];
|
||||
}
|
||||
|
||||
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) % 8;
|
||||
|
||||
if (meta == 0)
|
||||
{
|
||||
if (side == direction)
|
||||
{
|
||||
if (((IActiveLogic) logic).getActive())
|
||||
return icons[1];
|
||||
else
|
||||
return icons[0];
|
||||
}
|
||||
else if (side > 1)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
return icons[3];
|
||||
}
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
public int getTextureIndex (int side)
|
||||
{
|
||||
if (side == 0 || side == 1)
|
||||
return 3;
|
||||
if (side == 3)
|
||||
return 0;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
String[] textureNames = getTextureNames();
|
||||
this.icons = new Icon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
if (i == 3)
|
||||
this.icons[i] = iconRegister.registerIcon("minecraft:" + textureNames[i]);
|
||||
else
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,637 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.*;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
/** @author fuj1n
|
||||
*
|
||||
*/
|
||||
|
||||
public class GlassBlockConnected extends Block
|
||||
{
|
||||
protected 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;
|
||||
setHardness(0.3F);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
//For FMP support
|
||||
public Icon[] getIcons ()
|
||||
{
|
||||
return icons;
|
||||
}
|
||||
|
||||
@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 par1IBlockAccess.getBlockMetadata(par2, par3, par4) == 15 ? icons[0] : getConnectedBlockTexture(par1IBlockAccess, par2, par3, par4, par5, icons);
|
||||
}
|
||||
|
||||
public Icon getConnectedBlockTexture (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5, Icon[] icons)
|
||||
{
|
||||
if (PHConstruct.connectedTexturesMode == 0)
|
||||
{
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceTorchOnTop (World world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
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;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/** @author fuj1n
|
||||
*
|
||||
*/
|
||||
|
||||
public class GlassBlockConnectedMeta extends GlassBlockConnected
|
||||
{
|
||||
public String[] textures;
|
||||
public Icon[][] icons;
|
||||
boolean ignoreMetaForConnectedGlass = PHConstruct.connectedTexturesMode == 2;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceTorchOnTop (World world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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,697 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
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;
|
||||
// return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getBlockTexture (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (par5 == 0 || par5 == 1)
|
||||
{
|
||||
return par1IBlockAccess.getBlockId(par2, par3 - 1, par4) == this.blockID && par5 == 0 ? icons[15]
|
||||
: par1IBlockAccess.getBlockId(par2, par3 + 1, par4) == this.blockID && par5 == 1 ? icons[15] : getSideTextureIndex();
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.getBlockTexture(par1IBlockAccess, par2, par3, par4, par5);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getConnectedBlockTexture (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5, Icon[] icons)
|
||||
{
|
||||
if (par5 == 0 || par5 == 1)
|
||||
{
|
||||
return getSideTextureIndex();
|
||||
}
|
||||
|
||||
if (PHConstruct.connectedTexturesMode == 0)
|
||||
{
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
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 void addCollisionBoxesToList (World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
|
||||
{
|
||||
boolean flag = this.canPaneConnectTo(par1World, par2, par3, par4, ForgeDirection.NORTH);
|
||||
boolean flag1 = this.canPaneConnectTo(par1World, par2, par3, par4, ForgeDirection.SOUTH);
|
||||
boolean flag2 = this.canPaneConnectTo(par1World, par2, par3, par4, ForgeDirection.WEST);
|
||||
boolean flag3 = this.canPaneConnectTo(par1World, par2, par3, par4, ForgeDirection.EAST);
|
||||
|
||||
if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1))
|
||||
{
|
||||
if (flag2 && !flag3)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.4375F, 0.5F, 1.0F, 0.5625F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
else if (!flag2 && flag3)
|
||||
{
|
||||
this.setBlockBounds(0.5F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
|
||||
if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1))
|
||||
{
|
||||
if (flag && !flag1)
|
||||
{
|
||||
this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 0.5F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
else if (!flag && flag1)
|
||||
{
|
||||
this.setBlockBounds(0.4375F, 0.0F, 0.5F, 0.5625F, 1.0F, 1.0F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsForItemRender ()
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
float f = 0.4375F;
|
||||
float f1 = 0.5625F;
|
||||
float f2 = 0.4375F;
|
||||
float f3 = 0.5625F;
|
||||
boolean flag = this.canPaneConnectTo(par1IBlockAccess, par2, par3, par4, ForgeDirection.NORTH);
|
||||
boolean flag1 = this.canPaneConnectTo(par1IBlockAccess, par2, par3, par4, ForgeDirection.SOUTH);
|
||||
boolean flag2 = this.canPaneConnectTo(par1IBlockAccess, par2, par3, par4, ForgeDirection.WEST);
|
||||
boolean flag3 = this.canPaneConnectTo(par1IBlockAccess, par2, par3, par4, ForgeDirection.EAST);
|
||||
|
||||
if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1))
|
||||
{
|
||||
if (flag2 && !flag3)
|
||||
{
|
||||
f = 0.0F;
|
||||
}
|
||||
else if (!flag2 && flag3)
|
||||
{
|
||||
f1 = 1.0F;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
f = 0.0F;
|
||||
f1 = 1.0F;
|
||||
}
|
||||
|
||||
if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1))
|
||||
{
|
||||
if (flag && !flag1)
|
||||
{
|
||||
f2 = 0.0F;
|
||||
}
|
||||
else if (!flag && flag1)
|
||||
{
|
||||
f3 = 1.0F;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
f2 = 0.0F;
|
||||
f3 = 1.0F;
|
||||
}
|
||||
|
||||
this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
|
||||
}
|
||||
|
||||
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("tinker: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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
// if(par5 == 0 || par5 == 1){
|
||||
// return par1IBlockAccess.getBlockId(par2, par3, par4) != this.blockID;
|
||||
// }else{
|
||||
// return true;
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped (int par1)
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GlueBlock extends TConstructBlock {
|
||||
|
||||
public GlueBlock(int id)
|
||||
{
|
||||
super(id, Material.ground, 4.0f, new String[]{"glue"});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
entity.motionX *= 0.1;
|
||||
entity.motionZ *= 0.1;
|
||||
|
||||
if (entity instanceof EntityLivingBase) {
|
||||
EntityLivingBase lvb = (EntityLivingBase)entity;
|
||||
// Well you'd feel ill too standing on glue...
|
||||
if (lvb.isPotionActive(Potion.hunger)) {
|
||||
lvb.getActivePotionEffect(Potion.hunger).duration = 20;
|
||||
} else {
|
||||
lvb.addPotionEffect(new PotionEffect(Potion.hunger.getId(), 20, 4));
|
||||
}
|
||||
|
||||
// Glue is sticky stuff
|
||||
if (lvb.isPotionActive(Potion.moveSlowdown)) {
|
||||
lvb.getActivePotionEffect(Potion.moveSlowdown).duration = 30;
|
||||
} else {
|
||||
lvb.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), 30, 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
return Block.slowSand.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.BlockFluidFinite;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
public class GlueFluid extends BlockFluidFinite {
|
||||
|
||||
Icon stillIcon;
|
||||
Icon flowIcon;
|
||||
|
||||
public GlueFluid(int id, Fluid fluid, Material material)
|
||||
{
|
||||
super(id, fluid, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
stillIcon = iconRegister.registerIcon("tinker:liquid_glue");
|
||||
flowIcon = iconRegister.registerIcon("tinker:liquid_glue_flow");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
if (side == 0 || side == 1)
|
||||
return stillIcon;
|
||||
return flowIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
|
||||
entity.motionX *= 0.1;
|
||||
entity.motionZ *= 0.1;
|
||||
|
||||
if (entity instanceof EntityLivingBase) {
|
||||
EntityLivingBase lvb = (EntityLivingBase)entity;
|
||||
// Well you'd feel ill too standing in glue...
|
||||
if (lvb.isPotionActive(Potion.hunger)) {
|
||||
lvb.getActivePotionEffect(Potion.hunger).duration = 20;
|
||||
} else {
|
||||
lvb.addPotionEffect(new PotionEffect(Potion.hunger.getId(), 20, 4));
|
||||
}
|
||||
|
||||
// Glue is sticky stuff
|
||||
if (lvb.isPotionActive(Potion.moveSlowdown)) {
|
||||
lvb.getActivePotionEffect(Potion.moveSlowdown).duration = 30;
|
||||
} else {
|
||||
lvb.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), 30, 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,76 @@
|
||||
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,318 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.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 tconstruct.blocks.logic.LavaTankLogic;
|
||||
import tconstruct.client.block.TankRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
|
||||
public class LavaTankBlock extends BlockContainer
|
||||
{
|
||||
public Icon[] icons;
|
||||
String texturePrefix = "";
|
||||
|
||||
public LavaTankBlock(int id)
|
||||
{
|
||||
super(id, Material.rock);
|
||||
setHardness(3F);
|
||||
setResistance(20F);
|
||||
setCreativeTab(TConstructRegistry.blockTab);
|
||||
setUnlocalizedName("TConstruct.LavaTank");
|
||||
setStepSound(Block.soundGlassFootstep);
|
||||
}
|
||||
|
||||
public LavaTankBlock(int id, String prefix)
|
||||
{
|
||||
this(id);
|
||||
texturePrefix = prefix;
|
||||
}
|
||||
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "lavatank_side", "lavatank_top", "searedgague_top", "searedgague_side", "searedgague_bottom", "searedwindow_top", "searedwindow_side", "searedwindow_bottom" };
|
||||
|
||||
if (!texturePrefix.equals(""))
|
||||
for (int i = 0; i < textureNames.length; i++)
|
||||
textureNames[i] = texturePrefix+"_"+textureNames[i];
|
||||
|
||||
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 >= 3)
|
||||
meta = 0;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeBlockByPlayer (World world, EntityPlayer player, int x, int y, int z)
|
||||
{
|
||||
player.addExhaustion(0.025F);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
ItemStack stack = new ItemStack(this.blockID, 1, meta);
|
||||
LavaTankLogic logic = (LavaTankLogic) world.getBlockTileEntity(x, y, z);
|
||||
FluidStack liquid = logic.tank.getFluid();
|
||||
if (liquid != null)
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
NBTTagCompound liquidTag = new NBTTagCompound();
|
||||
liquid.writeToNBT(liquidTag);
|
||||
tag.setCompoundTag("Fluid", liquidTag);
|
||||
stack.setTagCompound(tag);
|
||||
}
|
||||
if (!player.capabilities.isCreativeMode || player.isSneaking())
|
||||
dropTankBlock(world, x, y, z, stack);
|
||||
|
||||
return world.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
protected void dropTankBlock (World world, int x, int y, int z, ItemStack stack)
|
||||
{
|
||||
if (!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops"))
|
||||
{
|
||||
float f = 0.7F;
|
||||
double d0 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
double d1 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
double d2 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
EntityItem entityitem = new EntityItem(world, (double) x + d0, (double) y + d1, (double) z + d2, stack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
|
||||
public void harvestBlock (World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound liquidTag = stack.getTagCompound().getCompoundTag("Fluid");
|
||||
if (liquidTag != null)
|
||||
{
|
||||
FluidStack liquid = FluidStack.loadFluidStackFromNBT(liquidTag);
|
||||
LavaTankLogic logic = (LavaTankLogic) world.getBlockTileEntity(x, y, z);
|
||||
logic.tank.setFluid(liquid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
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 int getRenderBlockPass ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@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,190 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class MeatBlock extends Block
|
||||
{
|
||||
public Icon[] icons;
|
||||
public String[] textureNames = new String[] { "ham_skin", "ham_bone" };
|
||||
|
||||
public MeatBlock(int id)
|
||||
{
|
||||
super(id, Material.sponge);
|
||||
this.setHardness(1.0F);
|
||||
this.setStepSound(Block.soundWoodFootstep);
|
||||
//setBurnProperties(this.blockID, 5, 20);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon (int side, int metadata)
|
||||
{
|
||||
int tex = (metadata % 4) * 2;
|
||||
int orientation = metadata / 4;
|
||||
|
||||
switch (orientation)
|
||||
//Ends of logs
|
||||
{
|
||||
case 0:
|
||||
if (side == 0 || side == 1)
|
||||
return icons[tex + 1];
|
||||
break;
|
||||
case 1:
|
||||
if (side == 4 || side == 5)
|
||||
return icons[tex + 1];
|
||||
break;
|
||||
case 2:
|
||||
if (side == 2 || side == 3)
|
||||
return icons[tex + 1];
|
||||
break;
|
||||
}
|
||||
|
||||
return icons[tex];
|
||||
}
|
||||
|
||||
@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]);
|
||||
}
|
||||
}
|
||||
|
||||
public int idDropped (int par1, Random par2Random, int par3)
|
||||
{
|
||||
return this.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)
|
||||
{
|
||||
byte b0 = 4;
|
||||
int j1 = b0 + 1;
|
||||
|
||||
if (par1World.checkChunksExist(par2 - j1, par3 - j1, par4 - j1, par2 + j1, par3 + j1, par4 + j1))
|
||||
{
|
||||
for (int k1 = -b0; k1 <= b0; ++k1)
|
||||
{
|
||||
for (int l1 = -b0; l1 <= b0; ++l1)
|
||||
{
|
||||
for (int i2 = -b0; i2 <= b0; ++i2)
|
||||
{
|
||||
int j2 = par1World.getBlockId(par2 + k1, par3 + l1, par4 + i2);
|
||||
|
||||
if (Block.blocksList[j2] != null)
|
||||
{
|
||||
Block.blocksList[j2].beginLeavesDecay(par1World, par2 + k1, par3 + l1, par4 + i2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 & 3;
|
||||
byte b0 = 0;
|
||||
|
||||
switch (par5)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
b0 = 0;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
b0 = 8;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
b0 = 4;
|
||||
}
|
||||
|
||||
return j1 | b0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the damage on the item the block drops. Used in cloth and wood.
|
||||
*/
|
||||
public int damageDropped (int par1)
|
||||
{
|
||||
return par1 & 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a number between 0 and 3
|
||||
*/
|
||||
public static int limitToValidMetadata (int par0)
|
||||
{
|
||||
return par0 & 3;
|
||||
}
|
||||
|
||||
protected ItemStack createStackedBlock (int par1)
|
||||
{
|
||||
return new ItemStack(this.blockID, 1, limitToValidMetadata(par1));
|
||||
}
|
||||
|
||||
public boolean isBlockReplaceable (World world, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*public void onBlockHarvested (World world, int x, int y, int z, int meta, EntityPlayer player)
|
||||
{
|
||||
if (meta % 4 == 1)
|
||||
{
|
||||
if (world.difficultySetting > 2)
|
||||
world.createExplosion(null, x, y, z, 1.75f, false);
|
||||
else
|
||||
world.createExplosion(null, x, y, z, 2f, false);
|
||||
}
|
||||
}*/
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubBlocks (int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for (int i = 0; i < icons.length / 2; i++)
|
||||
par3List.add(new ItemStack(par1, 1, i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSustainLeaves (World world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWood (World world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isBeaconBase (World worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -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, random.nextInt(3) + 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,351 @@
|
||||
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(3F);
|
||||
setResistance(20F);
|
||||
setStepSound(soundMetalFootstep);
|
||||
}
|
||||
|
||||
public SearedBlock(int id, String texture)
|
||||
{
|
||||
this(id);
|
||||
this.texturePrefix = texture;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
String texturePrefix = "";
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "castingtable_top", "castingtable_side", "castingtable_bottom", "faucet", "blockcast_top", "blockcast_side", "blockcast_bottom" };
|
||||
|
||||
if (!texturePrefix.equals(""))
|
||||
for (int i = 0; i < textureNames.length; i++)
|
||||
textureNames[i] = texturePrefix+"_"+textureNames[i];
|
||||
|
||||
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,107 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.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 tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SlabBase extends Block
|
||||
{
|
||||
Block modelBlock;
|
||||
int startingMeta;
|
||||
int totalSize;
|
||||
|
||||
public SlabBase(int id, Material material)
|
||||
{
|
||||
super(id, material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
public SlabBase(int id, Material material, Block model, int meta, int totalSize)
|
||||
{
|
||||
super(id, material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.modelBlock = model;
|
||||
this.startingMeta = meta;
|
||||
this.totalSize = totalSize;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
meta = meta % 8 + startingMeta;
|
||||
return modelBlock.getIcon(side, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < totalSize; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
public int damageDropped (int meta)
|
||||
{
|
||||
return meta % 8;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
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.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityTNTPrimed;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.entity.item.ExplosivePrimed;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SlimeExplosive extends TConstructBlock
|
||||
{
|
||||
|
||||
public SlimeExplosive(int id)
|
||||
{
|
||||
super(id, Material.tnt, 0f, getTextureNames());
|
||||
}
|
||||
|
||||
static String[] getTextureNames ()
|
||||
{
|
||||
String[] names = new String[6];
|
||||
String[] types = new String[] { "green", "blue" };
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
names[i * 3 + 0] = "sdx_bottom_" + types[i];
|
||||
names[i * 3 + 1] = "sdx_side_" + types[i];
|
||||
names[i * 3 + 2] = "sdx_top_" + types[i];
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[(meta / 2) * 3 + getSideTextureIndex(side)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 2; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter * 2));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
super.onBlockAdded(par1World, par2, par3, par4);
|
||||
|
||||
if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
|
||||
{
|
||||
this.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange (World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
|
||||
{
|
||||
this.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDestroyedByExplosion (World par1World, int par2, int par3, int par4, Explosion par5Explosion)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
ExplosivePrimed entitytntprimed = new ExplosivePrimed(par1World, (double) ((float) par2 + 0.5F), (double) ((float) par3 + 0.5F), (double) ((float) par4 + 0.5F),
|
||||
par5Explosion.getExplosivePlacedBy());
|
||||
entitytntprimed.fuse = par1World.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8;
|
||||
par1World.spawnEntityInWorld(entitytntprimed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDestroyedByPlayer (World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
this.primeTnt(par1World, par2, par3, par4, par5, (EntityLivingBase) null);
|
||||
}
|
||||
|
||||
public void primeTnt (World par1World, int par2, int par3, int par4, int par5, EntityLivingBase par6EntityLivingBase)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
if ((par5 % 2) == 1)
|
||||
{
|
||||
ExplosivePrimed entitytntprimed = new ExplosivePrimed(par1World, (double) ((float) par2 + 0.5F), (double) ((float) par3 + 0.5F), (double) ((float) par4 + 0.5F), par6EntityLivingBase);
|
||||
par1World.spawnEntityInWorld(entitytntprimed);
|
||||
par1World.playSoundAtEntity(entitytntprimed, "random.fuse", 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated (World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (par5EntityPlayer.getCurrentEquippedItem() != null && par5EntityPlayer.getCurrentEquippedItem().itemID == Item.flintAndSteel.itemID)
|
||||
{
|
||||
this.primeTnt(par1World, par2, par3, par4, 1, par5EntityPlayer);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
par5EntityPlayer.getCurrentEquippedItem().damageItem(1, par5EntityPlayer);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
if (par5Entity instanceof EntityArrow && !par1World.isRemote)
|
||||
{
|
||||
EntityArrow entityarrow = (EntityArrow) par5Entity;
|
||||
|
||||
if (entityarrow.isBurning())
|
||||
{
|
||||
this.primeTnt(par1World, par2, par3, par4, 1, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase) entityarrow.shootingEntity : null);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropFromExplosion (Explosion par1Explosion)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
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.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.client.block.SlimePadRender;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SlimePad extends Block
|
||||
{
|
||||
|
||||
public SlimePad(int par1, Material par2Material)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.625F, 0.875F);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (!world.isBlockIndirectlyGettingPowered(x, y, z))
|
||||
{
|
||||
double moveX = 0;
|
||||
double moveZ = 0;
|
||||
|
||||
double speed = 0.25;
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta % 8)
|
||||
{
|
||||
case 6:
|
||||
moveX += speed;
|
||||
break;
|
||||
case 7:
|
||||
moveX += speed;
|
||||
moveZ += speed;
|
||||
break;
|
||||
case 0:
|
||||
moveZ += speed;
|
||||
break;
|
||||
case 1:
|
||||
moveZ += speed;
|
||||
moveX -= speed;
|
||||
break;
|
||||
case 2:
|
||||
moveX -= speed;
|
||||
break;
|
||||
case 3:
|
||||
moveX -= speed;
|
||||
moveZ -= speed;
|
||||
break;
|
||||
case 4:
|
||||
moveZ -= speed;
|
||||
break;
|
||||
case 5:
|
||||
moveZ -= speed;
|
||||
moveX += speed;
|
||||
break;
|
||||
}
|
||||
|
||||
if (entity instanceof EntityItem)
|
||||
{
|
||||
entity.posY += 1;
|
||||
}
|
||||
entity.addVelocity(moveX, speed * 2, moveZ);
|
||||
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, this.stepSound.getStepSound(), (this.stepSound.getVolume()) / 2.0F, this.stepSound.getPitch() * 0.65F);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBlockReplaceable (World world, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack)
|
||||
{
|
||||
int face = MathHelper.floor_double((double) (entity.rotationYaw * 8.0F / 360.0F) + 0.5D) + (entity.isSneaking() ? 4 : 0) & 7;
|
||||
int meta = world.getBlockMetadata(x, y, z) & 8;
|
||||
world.setBlockMetadataWithNotify(x, y, z, face | meta, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return SlimePadRender.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
return TContent.slimeGel.getIcon(side, 1);
|
||||
}
|
||||
|
||||
public Icon getFluidIcon (int meta)
|
||||
{
|
||||
return TContent.slimeChannel.getIcon(2, 0);
|
||||
}
|
||||
|
||||
public Icon getNubIcon (int meta)
|
||||
{
|
||||
return TContent.slimeGel.getIcon(0, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
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.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.AdaptiveSmelteryLogic;
|
||||
import tconstruct.blocks.logic.MultiServantLogic;
|
||||
import tconstruct.blocks.logic.AdaptiveDrainLogic;
|
||||
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 tconstruct.util.config.PHConstruct;
|
||||
|
||||
public class SmelteryBlock extends InventoryBlock
|
||||
{
|
||||
Random rand;
|
||||
String texturePrefix = "";
|
||||
|
||||
public SmelteryBlock(int id)
|
||||
{
|
||||
super(id, Material.rock);
|
||||
setHardness(3F);
|
||||
setResistance(20F);
|
||||
setStepSound(soundMetalFootstep);
|
||||
rand = new Random();
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setUnlocalizedName("tconstruct.Smeltery");
|
||||
}
|
||||
|
||||
public SmelteryBlock(int id, String prefix)
|
||||
{
|
||||
this(id);
|
||||
texturePrefix = prefix;
|
||||
}
|
||||
|
||||
/* Rendering */
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return PHConstruct.newSmeltery ? 0 : 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" };
|
||||
|
||||
if (!texturePrefix.equals(""))
|
||||
for (int i = 0; i < textureNames.length; i++)
|
||||
textureNames[i] = texturePrefix+"_"+textureNames[i];
|
||||
|
||||
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 -1;
|
||||
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 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
|
||||
{
|
||||
//world.markBlockForUpdate(x, y, z);
|
||||
player.openGui(getModInstance(), integer, world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
if (PHConstruct.newSmeltery)
|
||||
return new AdaptiveSmelteryLogic();
|
||||
else
|
||||
return new SmelteryLogic();
|
||||
|
||||
case 1:
|
||||
if (PHConstruct.newSmeltery)
|
||||
return new AdaptiveDrainLogic();
|
||||
else
|
||||
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 && !PHConstruct.newSmeltery)
|
||||
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 */
|
||||
@Override
|
||||
public void onNeighborBlockChange (World world, int x, int y, int z, int nBlockID)
|
||||
{
|
||||
//System.out.println("Neighbor changed");
|
||||
TileEntity logic = world.getBlockTileEntity(x, y, z);
|
||||
if (logic instanceof IServantLogic)
|
||||
{
|
||||
((IServantLogic) logic).notifyMasterOfChange();
|
||||
}
|
||||
else if (logic instanceof IMasterLogic)
|
||||
{
|
||||
((IMasterLogic) logic).notifyChange(null, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock (World world, int x, int y, int z, int blockID, int meta)
|
||||
{
|
||||
TileEntity logic = world.getBlockTileEntity(x, y, z);
|
||||
if (logic instanceof IServantLogic)
|
||||
{
|
||||
((IServantLogic) logic).notifyMasterOfChange();
|
||||
}
|
||||
super.breakBlock(world, x, y, z, blockID, meta);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.EnumCreatureAttribute;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
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", "slimedirt_blue", "nether_grout" };
|
||||
|
||||
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 EntityLivingBase)
|
||||
{
|
||||
EntityLivingBase living = ((EntityLivingBase) 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 onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta < 3)
|
||||
{
|
||||
entity.motionX *= 0.4;
|
||||
entity.motionZ *= 0.4;
|
||||
if (meta != 1 && entity instanceof EntityLivingBase)
|
||||
{
|
||||
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.weakness.id, 1));
|
||||
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.jump.id, 1, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float getBlockHardness (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 5)
|
||||
return Block.dirt.blockHardness;
|
||||
return this.blockHardness;
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
return Block.slowSand.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
}
|
||||
|
||||
/*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,97 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 tconstruct.common.TContent;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
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,37 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.BlockLadder;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
public class StoneLadder extends BlockLadder
|
||||
{
|
||||
|
||||
// Override ladder material
|
||||
public final Material blockMaterial = Material.rock;
|
||||
|
||||
private Icon icon;
|
||||
|
||||
// Use the normally protected constructor
|
||||
public StoneLadder(int id)
|
||||
{
|
||||
super(id);
|
||||
this.setUnlocalizedName("decoration.stoneladder");
|
||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons (IconRegister register)
|
||||
{
|
||||
icon = register.registerIcon("tinker:ladder_stone");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon (int meta, int side)
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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,73 @@
|
||||
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 meta < icons.length ? icons[meta] : icons[0];
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSideTextureIndex (int side)
|
||||
{
|
||||
if (side == 0)
|
||||
return 2;
|
||||
if (side == 1)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@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,50 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraftforge.fluids.BlockFluidClassic;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
public class TConstructFluid extends BlockFluidClassic
|
||||
{
|
||||
String texture;
|
||||
boolean alpha;
|
||||
public Icon stillIcon;
|
||||
public Icon flowIcon;
|
||||
|
||||
public TConstructFluid(int id, Fluid fluid, Material material, String texture)
|
||||
{
|
||||
super(id, fluid, material);
|
||||
this.texture = texture;
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
public TConstructFluid(int id, Fluid fluid, Material material, String texture, boolean alpha)
|
||||
{
|
||||
this(id, fluid, material, texture);
|
||||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return alpha ? 1 : 0;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -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", "compressed_ender" };
|
||||
|
||||
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,107 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.AxisAlignedBB;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import tconstruct.blocks.logic.TankAirLogic;
|
||||
import tconstruct.client.block.TankAirRender;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TankAirBlock extends BlockContainer
|
||||
{
|
||||
|
||||
public TankAirBlock(int id, Material material)
|
||||
{
|
||||
super(id, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world)
|
||||
{
|
||||
return new TankAirLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return TankAirRender.model;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister par1IconRegister)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
TankAirLogic tank = (TankAirLogic) world.getBlockTileEntity(x, y, z);
|
||||
if (tank != null && tank.hasItem())
|
||||
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public MovingObjectPosition collisionRayTrace (World world, int x, int y, int z, Vec3 par5Vec3, Vec3 par6Vec3)
|
||||
{
|
||||
TankAirLogic tank = (TankAirLogic) world.getBlockTileEntity(x, y, z);
|
||||
if (tank.hasItem())
|
||||
return super.collisionRayTrace(world, x, y, z, par5Vec3, par6Vec3);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock (MovingObjectPosition target, World world, int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockReplaceable (World world, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock (EntityPlayer player, int meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAirBlock (World world, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import static net.minecraftforge.common.ForgeDirection.DOWN;
|
||||
import static net.minecraftforge.common.ForgeDirection.UP;
|
||||
|
||||
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.BlockFarmland;
|
||||
import net.minecraft.block.BlockHalfSlab;
|
||||
import net.minecraft.block.BlockHopper;
|
||||
import net.minecraft.block.BlockPoweredOre;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
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;
|
||||
|
||||
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 boolean isBlockSolidOnSide (World world, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
return side == ForgeDirection.UP;
|
||||
}
|
||||
|
||||
@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.toolForgeID;
|
||||
//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,214 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.PartBuilderLogic;
|
||||
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.config.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;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
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 boolean isBlockSolidOnSide (World world, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
return side == ForgeDirection.UP;
|
||||
}
|
||||
|
||||
@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 PartBuilderLogic();
|
||||
case 2:
|
||||
return new PartBuilderLogic();
|
||||
case 3:
|
||||
return new PartBuilderLogic();
|
||||
case 4:
|
||||
return new PartBuilderLogic();
|
||||
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));
|
||||
}
|
||||
}
|
||||
super.onBlockPlacedBy(world, x, y, z, par5EntityLiving, par6ItemStack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockBaseRailLogic;
|
||||
import net.minecraft.block.BlockRailBase;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.item.EntityMinecart;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class WoodRail extends BlockRailBase
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
private Icon theIcon;
|
||||
|
||||
public WoodRail(int par1)
|
||||
{
|
||||
super(par1, false);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon (int par1, int par2)
|
||||
{
|
||||
return par2 >= 6 ? this.theIcon : this.blockIcon;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons (IconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon("tinker:woodrail");
|
||||
this.theIcon = par1IconRegister.registerIcon("tinker:woodrail_turn");
|
||||
}
|
||||
|
||||
protected void func_94358_a (World par1World, int par2, int par3, int par4, int par5, int par6, int par7)
|
||||
{
|
||||
if (par7 > 0 && Block.blocksList[par7].canProvidePower() && (new BlockBaseRailLogic(this, par1World, par2, par3, par4)).getNumberOfAdjacentTracks() == 3)
|
||||
{
|
||||
this.refreshTrackShape(par1World, par2, par3, par4, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRailMaxSpeed (World world, EntityMinecart cart, int y, int x, int z)
|
||||
{
|
||||
return 0.3f;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
package tconstruct.blocks.component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import tconstruct.blocks.logic.AdaptiveSmelteryLogic;
|
||||
import tconstruct.library.component.LogicComponent;
|
||||
import tconstruct.library.component.MultiFluidTank;
|
||||
import tconstruct.library.crafting.Smeltery;
|
||||
import tconstruct.library.util.CoordTuple;
|
||||
|
||||
public class SmelteryComponent extends LogicComponent
|
||||
{
|
||||
final AdaptiveSmelteryLogic master;
|
||||
final SmelteryScan structure;
|
||||
final MultiFluidTank multitank;
|
||||
int maxTemp;
|
||||
|
||||
public int fuelTicks;
|
||||
public int fuelGague;
|
||||
public int fuelAmount;
|
||||
boolean inUse;
|
||||
|
||||
public int[] activeTemps = new int[0];
|
||||
public int[] meltingTemps = new int[0];
|
||||
|
||||
CoordTuple activeLavaTank;
|
||||
|
||||
public SmelteryComponent(AdaptiveSmelteryLogic inventory, SmelteryScan structure, MultiFluidTank multitank, int maxTemp)
|
||||
{
|
||||
master = inventory;
|
||||
this.structure = structure;
|
||||
this.multitank = multitank;
|
||||
this.maxTemp = maxTemp;
|
||||
}
|
||||
|
||||
public void update ()
|
||||
{
|
||||
/*if (useTime > 0 && inUse)
|
||||
useTime -= 3;*/
|
||||
if (activeTemps.length == 0)
|
||||
inUse = false;
|
||||
|
||||
updateFuelGague();
|
||||
}
|
||||
|
||||
public void adjustSize (int size, boolean forceAdjust)
|
||||
{
|
||||
if (size != activeTemps.length || forceAdjust)
|
||||
{
|
||||
int[] tempActive = activeTemps;
|
||||
activeTemps = new int[size];
|
||||
int activeLength = tempActive.length > activeTemps.length ? activeTemps.length : tempActive.length;
|
||||
System.arraycopy(tempActive, 0, activeTemps, 0, activeLength);
|
||||
|
||||
int[] tempMelting = meltingTemps;
|
||||
meltingTemps = new int[size];
|
||||
int meltingLength = tempMelting.length > meltingTemps.length ? meltingTemps.length : tempMelting.length;
|
||||
System.arraycopy(tempMelting, 0, meltingTemps, 0, meltingLength);
|
||||
|
||||
if (activeTemps.length > 0 && activeTemps.length > tempActive.length)
|
||||
{
|
||||
for (int i = tempActive.length; i < activeTemps.length; i++)
|
||||
{
|
||||
activeTemps[i] = 20;
|
||||
meltingTemps[i] = 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTemperatures ()
|
||||
{
|
||||
inUse = true;
|
||||
for (int i = 0; i < meltingTemps.length; i++)
|
||||
{
|
||||
meltingTemps[i] = Smeltery.instance.getLiquifyTemperature(master.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void heatItems ()
|
||||
{
|
||||
if (fuelTicks > 0)
|
||||
{
|
||||
boolean hasUse = false;
|
||||
for (int i = 0; i < meltingTemps.length; i++)
|
||||
{
|
||||
fuelTicks--;
|
||||
if (fuelTicks <= 0)
|
||||
break;
|
||||
|
||||
ItemStack slot = master.getStackInSlot(i);
|
||||
if (meltingTemps[i] > 20 && slot != null)
|
||||
{
|
||||
hasUse = true;
|
||||
if (activeTemps[i] < maxTemp && activeTemps[i] < meltingTemps[i])
|
||||
{
|
||||
activeTemps[i] += 1;
|
||||
}
|
||||
else if (activeTemps[i] >= meltingTemps[i] && !world.isRemote)
|
||||
{
|
||||
FluidStack result = getResultFor(slot);
|
||||
if (result != null)
|
||||
{
|
||||
if (multitank.addFluidToTank(result, false))
|
||||
{
|
||||
master.setInventorySlotContents(i, null);
|
||||
activeTemps[i] = 20;
|
||||
ArrayList alloys = Smeltery.mixMetals(multitank.fluidlist);
|
||||
for (int al = 0; al < alloys.size(); al++)
|
||||
{
|
||||
FluidStack liquid = (FluidStack) alloys.get(al);
|
||||
multitank.addFluidToTank(liquid, true);
|
||||
}
|
||||
master.onInventoryChanged();
|
||||
master.setUpdateFluids();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
activeTemps[i] = 20;
|
||||
}
|
||||
inUse = hasUse;
|
||||
}
|
||||
}
|
||||
|
||||
void updateFuelGague ()
|
||||
{
|
||||
if (activeLavaTank == null || fuelTicks > 0 || structure.lavaTanks.size() < 1)
|
||||
return;
|
||||
|
||||
if (!world.blockExists(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z))
|
||||
{
|
||||
fuelAmount = 0;
|
||||
fuelGague = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntity tankContainer = world.getBlockTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z);
|
||||
if (tankContainer == null)
|
||||
{
|
||||
fuelAmount = 0;
|
||||
fuelGague = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (tankContainer instanceof IFluidHandler && inUse)
|
||||
{
|
||||
FluidStack liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, drainFuelAmount(), false);
|
||||
if (liquid != null && liquid.getFluid().getBlockID() == Block.lavaStill.blockID)
|
||||
{
|
||||
liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, drainFuelAmount(), true);
|
||||
fuelTicks += liquid.amount * 15;
|
||||
|
||||
FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN);
|
||||
liquid = info[0].fluid;
|
||||
int capacity = info[0].capacity;
|
||||
if (liquid != null)
|
||||
{
|
||||
fuelAmount = liquid.amount;
|
||||
fuelGague = liquid.amount * 52 / capacity;
|
||||
}
|
||||
else
|
||||
{
|
||||
fuelAmount = 0;
|
||||
fuelGague = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean foundTank = false;
|
||||
int iter = 0;
|
||||
while (!foundTank)
|
||||
{
|
||||
CoordTuple possibleTank = structure.lavaTanks.get(iter);
|
||||
TileEntity newTankContainer = world.getBlockTileEntity(possibleTank.x, possibleTank.y, possibleTank.z);
|
||||
if (newTankContainer instanceof IFluidHandler)
|
||||
{
|
||||
FluidStack newliquid = ((IFluidHandler) newTankContainer).drain(ForgeDirection.UNKNOWN, drainFuelAmount(), false);
|
||||
if (newliquid != null && newliquid.getFluid().getBlockID() == Block.lavaStill.blockID && newliquid.amount > 0)
|
||||
{
|
||||
foundTank = true;
|
||||
setActiveLavaTank(possibleTank);
|
||||
iter = structure.lavaTanks.size();
|
||||
|
||||
FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN);
|
||||
liquid = info[0].fluid;
|
||||
int capacity = info[0].capacity;
|
||||
if (liquid != null)
|
||||
{
|
||||
fuelAmount = liquid.amount;
|
||||
fuelGague = liquid.amount * 52 / capacity;
|
||||
}
|
||||
else
|
||||
{
|
||||
fuelAmount = 0;
|
||||
fuelGague = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
iter++;
|
||||
if (iter >= structure.lavaTanks.size())
|
||||
foundTank = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setActiveLavaTank (CoordTuple coord)
|
||||
{
|
||||
activeLavaTank = coord;
|
||||
}
|
||||
|
||||
private int drainFuelAmount ()
|
||||
{
|
||||
if (activeTemps.length == 0)
|
||||
return 0;
|
||||
|
||||
int amount = activeTemps.length / 3;
|
||||
if (amount < 150)
|
||||
amount = 150;
|
||||
return amount;
|
||||
}
|
||||
|
||||
public FluidStack getResultFor (ItemStack stack)
|
||||
{
|
||||
return Smeltery.instance.getSmelteryResult(stack);
|
||||
}
|
||||
|
||||
public int getInternalTemperature ()
|
||||
{
|
||||
return maxTemp;
|
||||
}
|
||||
|
||||
public int getTempForSlot (int slot)
|
||||
{
|
||||
return activeTemps[slot];
|
||||
}
|
||||
|
||||
public int getMeltingPointForSlot (int slot)
|
||||
{
|
||||
return meltingTemps[slot];
|
||||
}
|
||||
|
||||
public int getScaledFuelGague (int scale)
|
||||
{
|
||||
int ret = (fuelGague * scale) / 52;
|
||||
if (ret < 1)
|
||||
ret = 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
public void readNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
activeTemps = tags.getIntArray("Temperature");
|
||||
meltingTemps = tags.getIntArray("Melting");
|
||||
fuelAmount = tags.getInteger("Fuel");
|
||||
int[] tank = tags.getIntArray("LavaTank");
|
||||
if (tank.length > 0)
|
||||
activeLavaTank = new CoordTuple(tank[0], tank[1], tank[2]);
|
||||
}
|
||||
|
||||
public void writeNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setIntArray("Temperature", activeTemps);
|
||||
tags.setIntArray("Melting", meltingTemps);
|
||||
tags.setInteger("Fuel", fuelAmount);
|
||||
if (activeLavaTank != null)
|
||||
tags.setIntArray("LavaTank", new int[] { activeLavaTank.x, activeLavaTank.y, activeLavaTank.z });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package tconstruct.blocks.component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagIntArray;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.component.TankLayerScan;
|
||||
import tconstruct.library.util.CoordTuple;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
|
||||
public class SmelteryScan extends TankLayerScan
|
||||
{
|
||||
public ArrayList<CoordTuple> lavaTanks = new ArrayList<CoordTuple>();
|
||||
|
||||
public SmelteryScan(TileEntity te, Block... id)
|
||||
{
|
||||
super(te, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkValidStructure ()
|
||||
{
|
||||
lavaTanks.clear();
|
||||
super.checkValidStructure();
|
||||
}
|
||||
|
||||
protected boolean checkAir (int x, int y, int z)
|
||||
{
|
||||
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
||||
if (block == null || block.isAirBlock(world, x, y, z) || block == TContent.tankAir)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkServant (int x, int y, int z)
|
||||
{
|
||||
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
||||
if (block == null || block.isAirBlock(world, x, y, z) || !isValidBlock(x, y, z))
|
||||
return false;
|
||||
|
||||
if (!block.hasTileEntity(world.getBlockMetadata(x, y, z)))
|
||||
return false;
|
||||
|
||||
TileEntity be = world.getBlockTileEntity(x, y, z);
|
||||
if (be instanceof IServantLogic)
|
||||
{
|
||||
boolean ret = ((IServantLogic) be).setPotentialMaster(this.imaster, this.world, x, y, z);
|
||||
if (ret && block == TContent.lavaTank)
|
||||
lavaTanks.add(new CoordTuple(x, y, z));
|
||||
return ret;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalizeStructure ()
|
||||
{
|
||||
super.finalizeStructure();
|
||||
if (lavaTanks.size() < 1)
|
||||
completeStructure = false;
|
||||
else
|
||||
{
|
||||
for (CoordTuple coord : airCoords)
|
||||
{
|
||||
if (world.getBlockId(coord.x, coord.y, coord.z) != TContent.tankAir.blockID)
|
||||
{
|
||||
world.setBlock(coord.x, coord.y, coord.z, TContent.tankAir.blockID);
|
||||
IServantLogic servant = (IServantLogic) world.getBlockTileEntity(coord.x, coord.y, coord.z);
|
||||
servant.verifyMaster(imaster, world, master.xCoord, master.yCoord, master.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void invalidateStructure ()
|
||||
{
|
||||
super.invalidateStructure();
|
||||
for (CoordTuple coord : airCoords)
|
||||
{
|
||||
TileEntity servant = world.getBlockTileEntity(coord.x, coord.y, coord.z);
|
||||
if (servant instanceof IServantLogic)
|
||||
((IServantLogic) servant).invalidateMaster(imaster, world, master.xCoord, master.yCoord, master.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void invalidateBlocksAbove (int height)
|
||||
{
|
||||
for (CoordTuple coord : airCoords)
|
||||
{
|
||||
if (coord.y < height)
|
||||
continue;
|
||||
|
||||
TileEntity servant = world.getBlockTileEntity(coord.x, coord.y, coord.z);
|
||||
if (servant instanceof IServantLogic)
|
||||
((IServantLogic) servant).invalidateMaster(imaster, world, master.xCoord, master.yCoord, master.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup ()
|
||||
{
|
||||
super.cleanup();
|
||||
Iterator i = airCoords.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
CoordTuple coord = (CoordTuple) i.next();
|
||||
TileEntity te = world.getBlockTileEntity(coord.x, coord.y, coord.z);
|
||||
if (te != null && te instanceof IServantLogic)
|
||||
{
|
||||
((IServantLogic) te).invalidateMaster(imaster, world, master.xCoord, master.yCoord, master.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Sync lava tanks for fuel values
|
||||
@Override
|
||||
public void readNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readNetworkNBT(tags);
|
||||
|
||||
NBTTagList tanks = tags.getTagList("Tanks");
|
||||
if (tanks != null)
|
||||
{
|
||||
lavaTanks.clear();
|
||||
|
||||
for (int i = 0; i < tanks.tagCount(); ++i)
|
||||
{
|
||||
NBTTagIntArray tag = (NBTTagIntArray) tanks.tagAt(i);
|
||||
int[] coord = tag.intArray;
|
||||
layerAirCoords.add(new CoordTuple(coord[0], coord[1], coord[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeNetworkNBT(tags);
|
||||
|
||||
NBTTagList tanks = new NBTTagList();
|
||||
for (CoordTuple coord : lavaTanks)
|
||||
{
|
||||
tanks.appendTag(new NBTTagIntArray("coord", new int[] { coord.x, coord.y, coord.z }));
|
||||
}
|
||||
tags.setTag("Tanks", tanks);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package tconstruct.blocks.component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import tconstruct.library.component.MultiFluidTank;
|
||||
|
||||
public class TankAirComponent extends MultiFluidTank
|
||||
{
|
||||
public TankAirComponent()
|
||||
{
|
||||
}
|
||||
|
||||
public TankAirComponent(int i)
|
||||
{
|
||||
super(i);
|
||||
}
|
||||
|
||||
public void overrideFluids (ArrayList<FluidStack> fluids)
|
||||
{
|
||||
fluidlist = fluids;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.crafting.AlloyMix;
|
||||
import tconstruct.library.util.IFacingLogic;
|
||||
import tconstruct.library.util.IMasterLogic;
|
||||
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.minecraft.world.World;
|
||||
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 AdaptiveDrainLogic extends MultiServantLogic implements IFluidHandler, IFacingLogic//, ISwitchableMaster
|
||||
{
|
||||
byte direction;
|
||||
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setPotentialMaster (IMasterLogic master, World world, int x, int y, int z)
|
||||
{
|
||||
// TConstruct.logger.info("Master: "+master);
|
||||
return (master instanceof AdaptiveSmelteryLogic || master instanceof AdaptiveDrainLogic) && !hasMaster;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (hasValidMaster() && canDrain(from, null))
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
return smeltery.fill(from, resource, doFill);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
// TConstruct.logger.info("Attempting drain " + hasValidMaster());
|
||||
if (hasValidMaster() && canDrain(from, null))
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
// TConstruct.logger.info("Found master");
|
||||
return smeltery.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
if (hasValidMaster() && canDrain(from, null))
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
return smeltery.drain(from, resource, doDrain);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
if (hasValidMaster())
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
return smeltery.getFillState() < 2;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
if (hasValidMaster())
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
return smeltery.getFillState() > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo (ForgeDirection from)
|
||||
{
|
||||
if (hasValidMaster() && (from == getForgeDirection() || from == getForgeDirection().getOpposite() || from == ForgeDirection.UNKNOWN))
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
return smeltery.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
}
|
||||
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.data);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,586 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
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;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.component.SmelteryComponent;
|
||||
import tconstruct.blocks.component.SmelteryScan;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.inventory.AdaptiveSmelteryContainer;
|
||||
import tconstruct.library.blocks.AdaptiveInventoryLogic;
|
||||
import tconstruct.library.component.IComponentHolder;
|
||||
import tconstruct.library.component.LogicComponent;
|
||||
import tconstruct.library.component.MultiFluidTank;
|
||||
import tconstruct.library.util.CoordTuple;
|
||||
import tconstruct.library.util.IActiveLogic;
|
||||
import tconstruct.library.util.IMasterLogic;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
|
||||
public class AdaptiveSmelteryLogic extends AdaptiveInventoryLogic implements IActiveLogic, IMasterLogic, IComponentHolder, IFluidHandler
|
||||
{
|
||||
byte direction;
|
||||
boolean updateFluids = false;
|
||||
boolean recheckStructure = false;
|
||||
boolean updateAir = false;
|
||||
SmelteryScan structure = new SmelteryScan(this, TContent.smeltery, TContent.lavaTank);
|
||||
MultiFluidTank multitank = new MultiFluidTank();
|
||||
SmelteryComponent smeltery = new SmelteryComponent(this, structure, multitank, 800);
|
||||
HashMap<CoordTuple, LiquidDataInstance> airUpdates = new HashMap<CoordTuple, LiquidDataInstance>();
|
||||
int tick = 0;
|
||||
|
||||
public MultiFluidTank getMultiTank ()
|
||||
{
|
||||
return multitank;
|
||||
}
|
||||
|
||||
public SmelteryComponent getSmeltery ()
|
||||
{
|
||||
return smeltery;
|
||||
}
|
||||
|
||||
public void updateEntity ()
|
||||
{
|
||||
tick++;
|
||||
if (tick % 4 == 0)
|
||||
smeltery.heatItems();
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (tick % 20 == 0)
|
||||
{
|
||||
if (structure.isComplete())
|
||||
smeltery.update();
|
||||
|
||||
if (updateFluids)
|
||||
{
|
||||
distributeFluids();
|
||||
updateFluids = false;
|
||||
}
|
||||
|
||||
if (updateAir)
|
||||
{
|
||||
updateAir();
|
||||
updateAir = false;
|
||||
}
|
||||
|
||||
if (recheckStructure)
|
||||
{
|
||||
structure.recheckStructure();
|
||||
recheckStructure = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (tick >= 60)
|
||||
{
|
||||
if (!structure.isComplete())
|
||||
{
|
||||
structure.checkValidStructure();
|
||||
if (structure.isComplete())
|
||||
{
|
||||
validateSmeltery();
|
||||
}
|
||||
}
|
||||
tick = 0;
|
||||
}
|
||||
|
||||
if (airUpdates.size() > 0)
|
||||
updateFluidBlocks();
|
||||
}
|
||||
}
|
||||
|
||||
public void setUpdateFluids ()
|
||||
{
|
||||
updateFluids = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogicComponent> getComponents ()
|
||||
{
|
||||
ArrayList<LogicComponent> ret = new ArrayList<LogicComponent>(3);
|
||||
ret.add(structure);
|
||||
ret.add(multitank);
|
||||
ret.add(smeltery);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Structure */
|
||||
|
||||
@Override
|
||||
public void setWorldObj (World world)
|
||||
{
|
||||
super.setWorldObj(world);
|
||||
structure.setWorld(world);
|
||||
smeltery.setWorld(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyChange (IServantLogic servant, int x, int y, int z)
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
//System.out.println("Notifying of change from "+new CoordTuple(x, y, z));
|
||||
recheckStructure = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeBlock (EntityLivingBase entity, ItemStack itemstack)
|
||||
{
|
||||
structure.checkValidStructure();
|
||||
if (structure.isComplete())
|
||||
{
|
||||
validateSmeltery();
|
||||
}
|
||||
}
|
||||
|
||||
void validateSmeltery ()
|
||||
{
|
||||
adjustInventory(structure.getAirSize(), true);
|
||||
smeltery.adjustSize(structure.getAirSize(), true);
|
||||
multitank.setCapacity(structure.getAirSize() * (TConstruct.ingotLiquidValue * 18));
|
||||
smeltery.setActiveLavaTank(structure.lavaTanks.get(0));
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBlock ()
|
||||
{
|
||||
structure.cleanup();
|
||||
}
|
||||
|
||||
/* Direction */
|
||||
|
||||
@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)
|
||||
{
|
||||
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 boolean getActive ()
|
||||
{
|
||||
return structure.isComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive (boolean flag)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* Inventory */
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
inventory[slot] = itemstack;
|
||||
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
itemstack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
updateWorldBlock(slot, itemstack);
|
||||
updateAir = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
if (inventory[slot] != null)
|
||||
{
|
||||
if (inventory[slot].stackSize <= quantity)
|
||||
{
|
||||
ItemStack stack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
updateWorldBlock(slot, inventory[slot]);
|
||||
return stack;
|
||||
}
|
||||
ItemStack split = inventory[slot].splitStack(quantity);
|
||||
if (inventory[slot].stackSize == 0)
|
||||
{
|
||||
inventory[slot] = null;
|
||||
}
|
||||
|
||||
updateWorldBlock(slot, inventory[slot]);
|
||||
return split;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryChanged ()
|
||||
{
|
||||
smeltery.updateTemperatures();
|
||||
updateAir = true;
|
||||
super.onInventoryChanged();
|
||||
}
|
||||
|
||||
void updateWorldBlock (int slot, ItemStack itemstack)
|
||||
{
|
||||
CoordTuple air = structure.getAirByIndex(slot);
|
||||
if (air != null)
|
||||
{
|
||||
TileEntity te = worldObj.getBlockTileEntity(air.x, air.y, air.z);
|
||||
if (te != null && te instanceof TankAirLogic)
|
||||
{
|
||||
((TankAirLogic) te).setInventorySlotContents(0, itemstack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static final int pixelLayer = 162;
|
||||
|
||||
//Do the Monster Mash~
|
||||
public void distributeFluids ()
|
||||
{
|
||||
//Calculate liquids in each block
|
||||
int size = structure.getAirLayerSize();
|
||||
//HashMap<CoordTuple, LiquidDataInstance> blocks = new HashMap<CoordTuple, LiquidDataInstance>();
|
||||
|
||||
for (FluidStack fluid : multitank.fluidlist)
|
||||
{
|
||||
//Base calculations per liquid
|
||||
LiquidData data = new LiquidData(fluid.amount, size);
|
||||
int baseY = structure.airCoords.get(0).y;
|
||||
int layerSize = structure.getAirLayerSize();
|
||||
|
||||
//Calculate where to distribute liquids
|
||||
for (int i = 0; i < structure.airCoords.size(); i++)
|
||||
{
|
||||
LiquidDataInstance instance;
|
||||
CoordTuple coord = structure.airCoords.get(i);
|
||||
int height = 16 * (coord.y - baseY);
|
||||
int position = i % layerSize;
|
||||
|
||||
if (!airUpdates.containsKey(coord))
|
||||
{
|
||||
instance = new LiquidDataInstance();
|
||||
airUpdates.put(coord, instance);
|
||||
}
|
||||
else
|
||||
{
|
||||
instance = airUpdates.get(coord);
|
||||
}
|
||||
|
||||
if (instance.openLayers() > 0) //This is capable of sending negative liquid sizes to blocks without the stopgap check
|
||||
{
|
||||
if (position > data.blocksWithExtra)
|
||||
{
|
||||
//Calculate open layers
|
||||
int open = data.layers - height + 1;
|
||||
if (open < 1) //Temporary stopgap check
|
||||
continue;
|
||||
if (open > instance.openLayers())
|
||||
open = instance.openLayers();
|
||||
|
||||
//Copy fluid
|
||||
FluidStack newFluid = fluid.copy();
|
||||
newFluid.amount = pixelLayer * open;
|
||||
instance.addFluid(open, newFluid);
|
||||
|
||||
//Subtract from total
|
||||
data.totalAmount -= newFluid.amount;
|
||||
if (data.totalAmount <= 0)
|
||||
break;
|
||||
}
|
||||
else if (position == data.blocksWithExtra && data.leftovers > 0)
|
||||
{
|
||||
//Calculate open layers
|
||||
int open = data.layers - height + 1;
|
||||
if (open < 1) //Temporary stopgap check
|
||||
continue;
|
||||
boolean full = false;
|
||||
if (open > instance.openLayers())
|
||||
{
|
||||
open = instance.openLayers();
|
||||
full = true;
|
||||
}
|
||||
|
||||
//Copy fluid
|
||||
FluidStack newFluid = fluid.copy();
|
||||
newFluid.amount = pixelLayer * open;
|
||||
if (!full)
|
||||
newFluid.amount += data.leftovers;
|
||||
instance.addFluid(open, newFluid);
|
||||
|
||||
//Subtract from total
|
||||
data.totalAmount -= newFluid.amount;
|
||||
if (data.totalAmount <= 0)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Calculate open layers
|
||||
int open = data.layers - height;
|
||||
if (open < 1) //Temporary stopgap check
|
||||
continue;
|
||||
if (open > instance.openLayers())
|
||||
open = instance.openLayers();
|
||||
|
||||
//Copy fluid
|
||||
FluidStack newFluid = fluid.copy();
|
||||
newFluid.amount = pixelLayer * open;
|
||||
instance.addFluid(open, newFluid);
|
||||
|
||||
//Subtract from total
|
||||
data.totalAmount -= newFluid.amount;
|
||||
if (data.totalAmount <= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Distribute liquids to each block
|
||||
}
|
||||
|
||||
protected void updateFluidBlocks ()
|
||||
{
|
||||
Iterator iter = airUpdates.entrySet().iterator();
|
||||
byte count = 0;
|
||||
while (iter.hasNext() && count < 40)
|
||||
{
|
||||
Map.Entry pairs = (Map.Entry) iter.next();
|
||||
CoordTuple coord = (CoordTuple) pairs.getKey();
|
||||
TileEntity te = worldObj.getBlockTileEntity(coord.x, coord.y, coord.z);
|
||||
if (te instanceof TankAirLogic)
|
||||
{
|
||||
((TankAirLogic) te).overrideFluids(((LiquidDataInstance) pairs.getValue()).fluids);
|
||||
}
|
||||
iter.remove();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAir ()
|
||||
{
|
||||
for (CoordTuple loc : structure.airCoords)
|
||||
worldObj.markBlockForUpdate(loc.x, loc.y, loc.z);
|
||||
}
|
||||
|
||||
class LiquidData
|
||||
{
|
||||
public int totalAmount;
|
||||
public int layers;
|
||||
public int leftovers;
|
||||
public int blocksWithExtra;
|
||||
|
||||
LiquidData(int amount, int blocks)
|
||||
{
|
||||
totalAmount = amount;
|
||||
int layerAmount = pixelLayer * blocks;
|
||||
layers = amount / layerAmount;
|
||||
leftovers = amount % pixelLayer;
|
||||
blocksWithExtra = (amount % layerAmount) / pixelLayer;
|
||||
}
|
||||
}
|
||||
|
||||
class LiquidDataInstance
|
||||
{
|
||||
public ArrayList<FluidStack> fluids = new ArrayList<FluidStack>();
|
||||
int layers = 0;
|
||||
|
||||
public int openLayers ()
|
||||
{
|
||||
return 16 - layers;
|
||||
}
|
||||
|
||||
public void addFluid (int l, FluidStack fluid)
|
||||
{
|
||||
layers += l;
|
||||
fluids.add(fluid);
|
||||
}
|
||||
}
|
||||
|
||||
/* Gui */
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new AdaptiveSmelteryContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
public int getTempForSlot (int slot)
|
||||
{
|
||||
return smeltery.activeTemps[slot];
|
||||
}
|
||||
|
||||
public int getMeltingPointForSlot (int slot)
|
||||
{
|
||||
return smeltery.meltingTemps[slot];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "crafters.Smeltery";
|
||||
}
|
||||
|
||||
/* Fluids */
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
return multitank.fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return multitank.drain(resource.amount, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return multitank.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@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 multitank.getMultiTankInfo();
|
||||
}
|
||||
|
||||
public int getFillState ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readNetworkNBT(tags);
|
||||
|
||||
structure.readFromNBT(tags);
|
||||
multitank.readFromNBT(tags);
|
||||
smeltery.readFromNBT(tags);
|
||||
}
|
||||
|
||||
public void readNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
direction = tags.getByte("Direction");
|
||||
adjustInventory(tags.getInteger("InvSize"), false);
|
||||
super.readInventoryFromNBT(tags);
|
||||
|
||||
structure.readNetworkNBT(tags);
|
||||
multitank.readNetworkNBT(tags);
|
||||
smeltery.readNetworkNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeNetworkNBT(tags);
|
||||
|
||||
structure.writeToNBT(tags);
|
||||
multitank.writeToNBT(tags);
|
||||
smeltery.writeToNBT(tags);
|
||||
}
|
||||
|
||||
public void writeNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setByte("Direction", direction);
|
||||
tags.setInteger("InvSize", inventory.length);
|
||||
super.writeInventoryToNBT(tags);
|
||||
|
||||
structure.writeNetworkNBT(tags);
|
||||
multitank.writeNetworkNBT(tags);
|
||||
smeltery.writeNetworkNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readNetworkNBT(packet.data);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeNetworkNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
}
|
||||
@@ -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,430 @@
|
||||
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);
|
||||
}
|
||||
|
||||
TConstruct.logger.info("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 == null ? null : 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)
|
||||
{
|
||||
//TConstruct.logger.info("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();
|
||||
this.castingDelay = tags.getInteger("castingDelay");
|
||||
}
|
||||
|
||||
@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);
|
||||
tags.setInteger("castingDelay", castingDelay);
|
||||
}
|
||||
|
||||
/* 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.data);
|
||||
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,671 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
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.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;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.util.IActiveLogic;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* @author BluSunrize
|
||||
*/
|
||||
|
||||
public class CastingChannelLogic extends TileEntity implements IFluidTank, IFluidHandler, IActiveLogic
|
||||
{
|
||||
public final static int fillMax = TConstruct.ingotLiquidValue*5;
|
||||
public final static int outputMax = TConstruct.ingotLiquidValue;
|
||||
public FluidStack liquid;
|
||||
public ForgeDirection lastProvider;
|
||||
private int ticks = 0;
|
||||
private int ticksLPReset = 0;
|
||||
public int recentlyFilledDelay;
|
||||
boolean pullingLiquids;
|
||||
|
||||
public CastingChannelLogic()
|
||||
{
|
||||
recentlyFilledDelay = 0;
|
||||
lastProvider = ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (this.worldObj.isRemote)
|
||||
return;
|
||||
ticks++;
|
||||
ticksLPReset++;
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (this.pullingLiquids)
|
||||
pullLiquids();
|
||||
}
|
||||
//this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
if (ticks == 20)
|
||||
{
|
||||
if (recentlyFilledDelay != 0)
|
||||
recentlyFilledDelay--;
|
||||
if (recentlyFilledDelay == 0)
|
||||
moveLiquidToTanks();
|
||||
ticks = 0;
|
||||
}
|
||||
if (ticksLPReset == 60)
|
||||
{
|
||||
this.lastProvider = ForgeDirection.UNKNOWN;
|
||||
ticksLPReset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void pullLiquids ()
|
||||
{
|
||||
if (pullLiquid(xCoord + 1, yCoord, zCoord, ForgeDirection.EAST) || pullLiquid(xCoord - 1, yCoord, zCoord, ForgeDirection.WEST) || pullLiquid(xCoord, yCoord, zCoord + 1, ForgeDirection.NORTH)
|
||||
|| pullLiquid(xCoord, yCoord, zCoord - 1, ForgeDirection.SOUTH))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
pullingLiquids = false;
|
||||
}
|
||||
}
|
||||
|
||||
boolean pullLiquid (int x, int y, int z, ForgeDirection direction)
|
||||
{
|
||||
TileEntity tank = worldObj.getBlockTileEntity(x, y, z);
|
||||
if (tank instanceof IFluidHandler && !(tank instanceof CastingChannelLogic))
|
||||
{
|
||||
FluidStack templiquid = ((IFluidHandler) tank).drain(direction, 3, false);
|
||||
if (templiquid != null)
|
||||
{
|
||||
if (this.liquid == null)
|
||||
{
|
||||
if (templiquid.amount > fillMax)
|
||||
templiquid.amount = fillMax;
|
||||
this.liquid = ((IFluidHandler) tank).drain(direction, templiquid.amount, true);
|
||||
return true;
|
||||
}
|
||||
else if (this.liquid.isFluidEqual(templiquid))
|
||||
{
|
||||
if (templiquid.amount + this.liquid.amount > fillMax)
|
||||
templiquid.amount = fillMax - this.liquid.amount;
|
||||
liquid.amount += ((IFluidHandler) tank).drain(direction, templiquid.amount, true).amount;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void moveLiquidToChannels ()
|
||||
{
|
||||
if (this.liquid == null || this.liquid.amount <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
TileEntity tankXplus = null;
|
||||
TileEntity tankXminus = null;
|
||||
TileEntity tankZplus = null;
|
||||
TileEntity tankZminus = null;
|
||||
TileEntity tankYminus = null;
|
||||
HashMap tankMap = this.getOutputs();
|
||||
if (tankMap.size() <= 0)
|
||||
{
|
||||
//TConstruct.logger.info("Nope, no connections to go to");
|
||||
return;
|
||||
}
|
||||
boolean yFilled = false;
|
||||
if (tankMap.containsKey("yMinus"))
|
||||
{
|
||||
tankYminus = (TileEntity) tankMap.get("yMinus");
|
||||
FluidStack liquidToPush = this.drain(24, false);
|
||||
if ((liquidToPush != null) && (liquidToPush.amount > 0))
|
||||
{
|
||||
int filled = ((IFluidHandler) tankYminus).fill(ForgeDirection.UP, liquidToPush, true);
|
||||
if (filled > 0)
|
||||
{
|
||||
yFilled = true;
|
||||
this.drain(filled, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!yFilled)
|
||||
{
|
||||
int divisionSurplus = (this.liquid.amount % tankMap.size());
|
||||
int amountXp = (this.outputMax / tankMap.size());
|
||||
int amountXm = (this.outputMax / tankMap.size());
|
||||
int amountZp = (this.outputMax / tankMap.size());
|
||||
int amountZm = (this.outputMax / tankMap.size());
|
||||
if (divisionSurplus > 0)
|
||||
amountXp++;
|
||||
if (divisionSurplus > 1)
|
||||
amountXm++;
|
||||
if (divisionSurplus > 2)
|
||||
amountZp++;
|
||||
|
||||
if (tankMap.containsKey("xPlus"))
|
||||
{
|
||||
tankXplus = (TileEntity) tankMap.get("xPlus");
|
||||
FluidStack liquidToPush = this.drain(amountXp, false);
|
||||
if ((liquidToPush != null) && (liquidToPush.amount > 0))
|
||||
{
|
||||
int filled = ((IFluidHandler) tankXplus).fill(ForgeDirection.WEST, liquidToPush, true);
|
||||
this.drain(filled, true);
|
||||
}
|
||||
}
|
||||
if (tankMap.containsKey("xMinus"))
|
||||
{
|
||||
tankXminus = (TileEntity) tankMap.get("xMinus");
|
||||
FluidStack liquidToPush = this.drain(amountXm, false);
|
||||
if ((liquidToPush != null) && (liquidToPush.amount > 0))
|
||||
{
|
||||
int filled = ((IFluidHandler) tankXminus).fill(ForgeDirection.EAST, liquidToPush, true);
|
||||
this.drain(filled, true);
|
||||
}
|
||||
}
|
||||
if (tankMap.containsKey("zPlus"))
|
||||
{
|
||||
tankZplus = (TileEntity) tankMap.get("zPlus");
|
||||
FluidStack liquidToPush = this.drain(amountZp, false);
|
||||
if ((liquidToPush != null) && (liquidToPush.amount > 0))
|
||||
{
|
||||
int filled = ((IFluidHandler) tankZplus).fill(ForgeDirection.NORTH, liquidToPush, true);
|
||||
this.drain(filled, true);
|
||||
}
|
||||
}
|
||||
if (tankMap.containsKey("zMinus"))
|
||||
{
|
||||
tankZminus = (TileEntity) tankMap.get("zMinus");
|
||||
FluidStack liquidToPush = this.drain(amountZm, false);
|
||||
if ((liquidToPush != null) && (liquidToPush.amount > 0))
|
||||
{
|
||||
int filled = ((IFluidHandler) tankZminus).fill(ForgeDirection.SOUTH, liquidToPush, true);
|
||||
this.drain(filled, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void moveLiquidToTanks ()
|
||||
{
|
||||
if (this.liquid == null || this.liquid.amount <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
TileEntity tankXplus = null;
|
||||
TileEntity tankXminus = null;
|
||||
TileEntity tankZplus = null;
|
||||
TileEntity tankZminus = null;
|
||||
TileEntity tankYminus = null;
|
||||
HashMap tankMap = this.getOutputs();
|
||||
if (tankMap.size() <= 0)
|
||||
{
|
||||
//TConstruct.logger.info("Nope, no connections to go to");
|
||||
return;
|
||||
}
|
||||
boolean yFilled = false;
|
||||
if (tankMap.containsKey("yMinus"))
|
||||
{
|
||||
tankYminus = (TileEntity) tankMap.get("yMinus");
|
||||
FluidStack liquidToPush = this.drain(24, false);
|
||||
if ((liquidToPush != null) && (liquidToPush.amount > 0))
|
||||
{
|
||||
int filled = ((IFluidHandler) tankYminus).fill(ForgeDirection.UP, liquidToPush, true);
|
||||
if (filled > 0)
|
||||
{
|
||||
yFilled = true;
|
||||
this.drain(filled, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!yFilled)
|
||||
{
|
||||
int divisionSurplus = (this.liquid.amount % tankMap.size());
|
||||
int amountXp = (this.outputMax / tankMap.size());
|
||||
int amountXm = (this.outputMax / tankMap.size());
|
||||
int amountZp = (this.outputMax / tankMap.size());
|
||||
int amountZm = (this.outputMax / tankMap.size());
|
||||
if (divisionSurplus > 0)
|
||||
amountXp++;
|
||||
if (divisionSurplus > 1)
|
||||
amountXm++;
|
||||
if (divisionSurplus > 2)
|
||||
amountZp++;
|
||||
|
||||
if (tankMap.containsKey("xPlus"))
|
||||
{
|
||||
tankXplus = (TileEntity) tankMap.get("xPlus");
|
||||
FluidStack liquidToPush = this.drain(amountXp, false);
|
||||
if ((liquidToPush != null) && (liquidToPush.amount > 0))
|
||||
{
|
||||
int filled = ((IFluidHandler) tankXplus).fill(ForgeDirection.WEST, liquidToPush, true);
|
||||
this.drain(filled, true);
|
||||
}
|
||||
}
|
||||
if (tankMap.containsKey("xMinus"))
|
||||
{
|
||||
tankXminus = (TileEntity) tankMap.get("xMinus");
|
||||
FluidStack liquidToPush = this.drain(amountXm, false);
|
||||
if ((liquidToPush != null) && (liquidToPush.amount > 0))
|
||||
{
|
||||
int filled = ((IFluidHandler) tankXminus).fill(ForgeDirection.EAST, liquidToPush, true);
|
||||
this.drain(filled, true);
|
||||
}
|
||||
}
|
||||
if (tankMap.containsKey("zPlus"))
|
||||
{
|
||||
tankZplus = (TileEntity) tankMap.get("zPlus");
|
||||
FluidStack liquidToPush = this.drain(amountZp, false);
|
||||
if ((liquidToPush != null) && (liquidToPush.amount > 0))
|
||||
{
|
||||
int filled = ((IFluidHandler) tankZplus).fill(ForgeDirection.NORTH, liquidToPush, true);
|
||||
this.drain(filled, true);
|
||||
}
|
||||
}
|
||||
if (tankMap.containsKey("zMinus"))
|
||||
{
|
||||
tankZminus = (TileEntity) tankMap.get("zMinus");
|
||||
FluidStack liquidToPush = this.drain(amountZm, false);
|
||||
if ((liquidToPush != null) && (liquidToPush.amount > 0))
|
||||
{
|
||||
int filled = ((IFluidHandler) tankZminus).fill(ForgeDirection.SOUTH, liquidToPush, true);
|
||||
this.drain(filled, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float tankBelow ()
|
||||
{
|
||||
TileEntity te = this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord - 1, this.zCoord);
|
||||
if (te instanceof CastingChannelLogic)
|
||||
return -0.5f;
|
||||
if (te instanceof LavaTankLogic)
|
||||
return -1.0f;
|
||||
if (te instanceof CastingBasinLogic)
|
||||
return -0.75f;
|
||||
if (te instanceof CastingTableLogic)
|
||||
return -0.125f;
|
||||
if (te instanceof IFluidHandler)
|
||||
return 0f;
|
||||
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
public boolean hasChannelConnected (ForgeDirection dir)
|
||||
{
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
return (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord - 1, this.zCoord) instanceof CastingChannelLogic);
|
||||
case NORTH:
|
||||
return (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord - 1) instanceof CastingChannelLogic);
|
||||
case SOUTH:
|
||||
return (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord + 1) instanceof CastingChannelLogic);
|
||||
case WEST:
|
||||
return (this.worldObj.getBlockTileEntity(this.xCoord - 1, this.yCoord, this.zCoord) instanceof CastingChannelLogic);
|
||||
case EAST:
|
||||
return (this.worldObj.getBlockTileEntity(this.xCoord + 1, this.yCoord, this.zCoord) instanceof CastingChannelLogic);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasTankConnected (ForgeDirection dir)
|
||||
{
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
return (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord - 1, this.zCoord) instanceof IFluidHandler);
|
||||
case NORTH:
|
||||
return (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord - 1) instanceof IFluidHandler);
|
||||
case SOUTH:
|
||||
return (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord + 1) instanceof IFluidHandler);
|
||||
case WEST:
|
||||
return (this.worldObj.getBlockTileEntity(this.xCoord - 1, this.yCoord, this.zCoord) instanceof IFluidHandler);
|
||||
case EAST:
|
||||
return (this.worldObj.getBlockTileEntity(this.xCoord + 1, this.yCoord, this.zCoord) instanceof IFluidHandler);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap getOutputs ()
|
||||
{
|
||||
HashMap map = new HashMap();
|
||||
TileEntity tankXplus = this.worldObj.getBlockTileEntity(this.xCoord + 1, this.yCoord, this.zCoord);
|
||||
TileEntity tankXminus = this.worldObj.getBlockTileEntity(this.xCoord - 1, this.yCoord, this.zCoord);
|
||||
TileEntity tankZplus = this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord + 1);
|
||||
TileEntity tankZminus = this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord - 1);
|
||||
TileEntity tankYminus = this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord - 1, this.zCoord);
|
||||
|
||||
if (this.pullingLiquids)
|
||||
{
|
||||
if (this.hasChannelConnected(ForgeDirection.EAST) && (this.lastProvider != ForgeDirection.EAST))
|
||||
{
|
||||
map.put("xPlus", tankXplus);
|
||||
}
|
||||
if (this.hasChannelConnected(ForgeDirection.WEST) && (this.lastProvider != ForgeDirection.WEST))
|
||||
{
|
||||
map.put("xMinus", tankXminus);
|
||||
}
|
||||
if (this.hasChannelConnected(ForgeDirection.SOUTH) && (this.lastProvider != ForgeDirection.SOUTH))
|
||||
{
|
||||
map.put("zPlus", tankZplus);
|
||||
}
|
||||
if (this.hasChannelConnected(ForgeDirection.NORTH) && (this.lastProvider != ForgeDirection.NORTH))
|
||||
{
|
||||
map.put("zMinus", tankZminus);
|
||||
}
|
||||
if (this.hasChannelConnected(ForgeDirection.DOWN) && (this.lastProvider != ForgeDirection.DOWN))
|
||||
{
|
||||
map.put("yMinus", tankYminus);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.hasTankConnected(ForgeDirection.EAST) && (this.lastProvider != ForgeDirection.EAST))
|
||||
{
|
||||
map.put("xPlus", tankXplus);
|
||||
}
|
||||
if (this.hasTankConnected(ForgeDirection.WEST) && (this.lastProvider != ForgeDirection.WEST))
|
||||
{
|
||||
map.put("xMinus", tankXminus);
|
||||
}
|
||||
if (this.hasTankConnected(ForgeDirection.SOUTH) && (this.lastProvider != ForgeDirection.SOUTH))
|
||||
{
|
||||
map.put("zPlus", tankZplus);
|
||||
}
|
||||
if (this.hasTankConnected(ForgeDirection.NORTH) && (this.lastProvider != ForgeDirection.NORTH))
|
||||
{
|
||||
map.put("zMinus", tankZminus);
|
||||
}
|
||||
if (this.hasTankConnected(ForgeDirection.DOWN) && (this.lastProvider != ForgeDirection.DOWN))
|
||||
{
|
||||
map.put("yMinus", tankYminus);
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
public int fill (FluidStack stack, boolean doFill)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (this.liquid == null)
|
||||
{
|
||||
FluidStack transfered = stack.copy();
|
||||
|
||||
if (transfered.amount > this.fillMax)
|
||||
{
|
||||
transfered.amount = this.fillMax;
|
||||
}
|
||||
|
||||
if (doFill)
|
||||
{
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
this.liquid = transfered;
|
||||
}
|
||||
recentlyFilledDelay = 2;
|
||||
if (this.lastProvider == ForgeDirection.UP)
|
||||
recentlyFilledDelay = 3;
|
||||
return transfered.amount;
|
||||
}
|
||||
|
||||
if (stack.isFluidEqual(this.liquid))
|
||||
{
|
||||
if (stack.amount + this.liquid.amount >= this.fillMax)
|
||||
{
|
||||
int spaceInTank = this.fillMax - this.liquid.amount;
|
||||
if ((doFill) && (spaceInTank > 0))
|
||||
{
|
||||
this.liquid.amount = this.fillMax;
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
return spaceInTank;
|
||||
}
|
||||
|
||||
if (doFill)
|
||||
{
|
||||
this.liquid.amount += stack.amount;
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
return stack.amount;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
this.lastProvider = from;
|
||||
ticksLPReset = 0;
|
||||
int filled = fill(resource, doFill);
|
||||
if (from == ForgeDirection.UP)
|
||||
moveLiquidToTanks();
|
||||
return filled;
|
||||
}
|
||||
|
||||
public FluidStack drain (int maxDrain, boolean doDrain)
|
||||
{
|
||||
if ((this.liquid == null))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (this.liquid.amount <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
int toDrain = maxDrain;
|
||||
if (this.liquid.amount < toDrain)
|
||||
{
|
||||
toDrain = this.liquid.amount;
|
||||
}
|
||||
if (doDrain)
|
||||
{
|
||||
this.liquid.amount -= toDrain;
|
||||
}
|
||||
|
||||
FluidStack drained = new FluidStack(liquid.fluidID, toDrain);
|
||||
|
||||
if (this.liquid.amount <= 0)
|
||||
{
|
||||
this.liquid = null;
|
||||
}
|
||||
if (doDrain)
|
||||
{
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(drained, this.worldObj, this.xCoord, this.yCoord, this.zCoord, this));
|
||||
}
|
||||
return drained;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return this.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return this.drain(resource.amount, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity ()
|
||||
{
|
||||
return this.fillMax;
|
||||
}
|
||||
|
||||
public int getLiquidAmount ()
|
||||
{
|
||||
return this.liquid.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
pullingLiquids = tags.getBoolean("PullingLiquids");
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
if (tags.getBoolean("hasLiquid"))
|
||||
{
|
||||
this.liquid = FluidStack.loadFluidStackFromNBT(tags.getCompoundTag("Fluid"));
|
||||
}
|
||||
else
|
||||
this.liquid = null;
|
||||
this.recentlyFilledDelay = tags.getInteger("recentlyFilledDelay");
|
||||
this.lastProvider = this.convertIntToFD(tags.getInteger("LastProvider"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
tags.setBoolean("PullingLiquids", pullingLiquids);
|
||||
}
|
||||
|
||||
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.setInteger("LastProvider", this.convertFDToInt(this.lastProvider));
|
||||
tags.setInteger("recentlyFilledDelay", this.recentlyFilledDelay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readCustomNBT(packet.data);
|
||||
this.worldObj.markBlockForRenderUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
|
||||
public int convertFDToInt (ForgeDirection dir)
|
||||
{
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
return 0;
|
||||
case UP:
|
||||
return 1;
|
||||
case NORTH:
|
||||
return 2;
|
||||
case SOUTH:
|
||||
return 3;
|
||||
case WEST:
|
||||
return 4;
|
||||
case EAST:
|
||||
return 5;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public ForgeDirection convertIntToFD (int i)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
return ForgeDirection.DOWN;
|
||||
case 1:
|
||||
return ForgeDirection.UP;
|
||||
case 2:
|
||||
return ForgeDirection.NORTH;
|
||||
case 3:
|
||||
return ForgeDirection.SOUTH;
|
||||
case 4:
|
||||
return ForgeDirection.WEST;
|
||||
case 5:
|
||||
return ForgeDirection.EAST;
|
||||
default:
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive ()
|
||||
{
|
||||
return pullingLiquids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive (boolean flag)
|
||||
{
|
||||
//pullingLiquids = flag;
|
||||
pullingLiquids = !pullingLiquids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return liquid == null || (liquid.amount < fillMax);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo (ForgeDirection from)
|
||||
{
|
||||
return new FluidTankInfo[] { getInfo() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluid ()
|
||||
{
|
||||
return liquid == null ? null : liquid.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidAmount ()
|
||||
{
|
||||
return liquid == null ? 0 : liquid.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo getInfo ()
|
||||
{
|
||||
FluidTankInfo info = new FluidTankInfo(this);
|
||||
return info;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,428 @@
|
||||
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);
|
||||
}
|
||||
|
||||
TConstruct.logger.info("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 == null ? null : 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)
|
||||
{
|
||||
//TConstruct.logger.info("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"));
|
||||
}
|
||||
else
|
||||
this.liquid = null;
|
||||
|
||||
if (tags.getBoolean("Initialized"))
|
||||
this.capacity = tags.getInteger("Capacity");
|
||||
else
|
||||
this.capacity = updateCapacity();
|
||||
this.castingDelay = tags.getInteger("castingDelay");
|
||||
}
|
||||
|
||||
@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);
|
||||
tags.setInteger("castingDelay", castingDelay);
|
||||
}
|
||||
|
||||
/* 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.data);
|
||||
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,104 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.inventory.CraftingStationContainer;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
|
||||
public class CraftingStationLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
public WeakReference<IInventory> chest; //TODO: These are prototypes
|
||||
public WeakReference<IInventory> doubleChest;
|
||||
public WeakReference<IInventory> patternChest;
|
||||
public WeakReference<IInventory> furnace;
|
||||
public boolean tinkerTable;
|
||||
public boolean stencilTable;
|
||||
|
||||
public CraftingStationLogic()
|
||||
{
|
||||
super(17); //9 for crafting, 1 for output, 6 for extensions, 1 for plans
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
chest = null;
|
||||
doubleChest = null;
|
||||
patternChest = null;
|
||||
furnace = null;
|
||||
tinkerTable = false;
|
||||
for (int yPos = y - 1; yPos <= y + 1; yPos++)
|
||||
{
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(xPos, yPos, zPos);
|
||||
if (chest == null && tile instanceof TileEntityChest)
|
||||
{
|
||||
chest = new WeakReference(tile);
|
||||
checkForChest(world, xPos + 1, yPos, zPos);
|
||||
checkForChest(world, xPos - 1, yPos, zPos);
|
||||
checkForChest(world, xPos, yPos, zPos + 1);
|
||||
checkForChest(world, xPos, yPos, zPos - 1);
|
||||
}
|
||||
else if (patternChest == null && tile instanceof PatternChestLogic)
|
||||
patternChest = new WeakReference(tile);
|
||||
else if (furnace == null && (tile instanceof TileEntityFurnace || tile instanceof FurnaceLogic))
|
||||
furnace = new WeakReference(tile);
|
||||
else if (tinkerTable == false && tile instanceof ToolStationLogic)
|
||||
tinkerTable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new CraftingStationContainer(inventoryplayer, this, x, y, z);
|
||||
}
|
||||
|
||||
void checkForChest (World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
if (tile instanceof TileEntityChest)
|
||||
doubleChest = new WeakReference(tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultName ()
|
||||
{
|
||||
return "crafters.CraftingStation";
|
||||
}
|
||||
|
||||
public boolean canDropInventorySlot (int slot)
|
||||
{
|
||||
if (slot == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int var1)
|
||||
{
|
||||
return new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return i != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -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, 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 (!worldObj.isRemote && 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)
|
||||
{
|
||||
currentTime = tags.getInteger("Time");
|
||||
maxTime = tags.getInteger("MaxTime");
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setInteger("Time", currentTime);
|
||||
tags.setInteger("MaxTime", 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.data);
|
||||
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,58 @@
|
||||
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 void setInventorySlotContents (int slot, ItemStack stack)
|
||||
{
|
||||
if (slot == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
super.setInventorySlotContents(slot, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot (int slot)
|
||||
{
|
||||
return slot != 0 ? inventory[slot] : null;
|
||||
}
|
||||
|
||||
public boolean isStackInSlot (int slot)
|
||||
{
|
||||
return slot != 0 ? inventory[slot] != null : false;
|
||||
}
|
||||
}
|
||||
@@ -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.data);
|
||||
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,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.player, this);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public boolean canDropInventorySlot(int slot)
|
||||
{
|
||||
if (slot == 0)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
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.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.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;
|
||||
import tconstruct.inventory.FurnaceContainer;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import tconstruct.library.util.IActiveLogic;
|
||||
import tconstruct.library.util.IFacingLogic;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
/* Slots
|
||||
* 0: Input
|
||||
* 1: Fuel
|
||||
* 2: Output
|
||||
* 3-16: Chest
|
||||
*/
|
||||
|
||||
public class FurnaceLogic extends InventoryLogic implements IActiveLogic, IFacingLogic
|
||||
{
|
||||
boolean active;
|
||||
public int fuel;
|
||||
public int fuelGague;
|
||||
public int progress;
|
||||
public int fuelScale = 200;
|
||||
byte direction;
|
||||
|
||||
public FurnaceLogic()
|
||||
{
|
||||
super(3);
|
||||
active = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "container.furnace";
|
||||
}
|
||||
|
||||
@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) / fuelScale;
|
||||
}
|
||||
|
||||
public int gaugeFuelScaled (int scale)
|
||||
{
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
fuelGague = fuel;
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
fuelGague = fuelScale;
|
||||
}
|
||||
}
|
||||
return (fuel * scale) / fuelGague;
|
||||
}
|
||||
|
||||
/* Item cooking */
|
||||
public void updateEntity ()
|
||||
{
|
||||
boolean burning = isBurning();
|
||||
boolean updateInventory = false;
|
||||
if (fuel <= 0 && canSmelt())
|
||||
{
|
||||
fuel = fuelGague = (int) (getItemBurnTime(inventory[1]));
|
||||
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() && canSmelt())
|
||||
{
|
||||
progress++;
|
||||
if (progress >= fuelScale)
|
||||
{
|
||||
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 (this.canSmelt())
|
||||
{
|
||||
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]);
|
||||
|
||||
if (this.inventory[2] == null)
|
||||
{
|
||||
this.inventory[2] = itemstack.copy();
|
||||
}
|
||||
else if (this.inventory[2].isItemEqual(itemstack))
|
||||
{
|
||||
inventory[2].stackSize += itemstack.stackSize;
|
||||
}
|
||||
|
||||
--this.inventory[0].stackSize;
|
||||
|
||||
if (this.inventory[0].stackSize <= 0)
|
||||
{
|
||||
this.inventory[0] = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean canSmelt ()
|
||||
{
|
||||
if (inventory[0] == null) //Nothing here!
|
||||
return false;
|
||||
else
|
||||
{
|
||||
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]);
|
||||
if (itemstack == null)
|
||||
return false;
|
||||
if (this.inventory[2] == null)
|
||||
return true;
|
||||
if (!this.inventory[2].isItemEqual(itemstack))
|
||||
return false;
|
||||
int result = inventory[2].stackSize + itemstack.stackSize;
|
||||
return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBurning ()
|
||||
{
|
||||
return fuel > 0;
|
||||
}
|
||||
|
||||
public ItemStack getResultFor (ItemStack stack)
|
||||
{
|
||||
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
|
||||
if (result != null) //Only valid for food
|
||||
return result.copy();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getItemBurnTime (ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = stack.getItem().itemID;
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (stack.getItem() instanceof ItemBlock && Block.blocksList[i] != null)
|
||||
{
|
||||
Block block = Block.blocksList[i];
|
||||
|
||||
if (block == Block.woodSingleSlab)
|
||||
{
|
||||
return 150;
|
||||
}
|
||||
|
||||
if (block == Block.wood)
|
||||
{
|
||||
return 1200;
|
||||
}
|
||||
|
||||
if (block.blockMaterial == Material.wood)
|
||||
{
|
||||
return 300;
|
||||
}
|
||||
|
||||
if (block == Block.coalBlock)
|
||||
{
|
||||
return 16000;
|
||||
}
|
||||
}
|
||||
|
||||
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 (i == Item.stick.itemID)
|
||||
return 100;
|
||||
if (i == Item.coal.itemID)
|
||||
return 1600;
|
||||
if (i == Item.bucketLava.itemID)
|
||||
return 20000;
|
||||
if (i == Block.sapling.blockID)
|
||||
return 100;
|
||||
if (i == 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");
|
||||
readNetworkNBT(tags);
|
||||
}
|
||||
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
tags.setBoolean("Active", active);
|
||||
tags.setInteger("Fuel", fuel);
|
||||
tags.setInteger("FuelGague", fuelGague);
|
||||
writeNetworkNBT(tags);
|
||||
}
|
||||
|
||||
public void readNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
direction = tags.getByte("Direction");
|
||||
}
|
||||
|
||||
public void writeNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setByte("Direction", direction);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeNetworkNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readNetworkNBT(packet.data);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new FurnaceContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getRenderDirection ()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getForgeDirection ()
|
||||
{
|
||||
return ForgeDirection.VALID_DIRECTIONS[direction];
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setDirection (int side)
|
||||
{
|
||||
//Nope!
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.data);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
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.tileentity.TileEntity;
|
||||
import tconstruct.TConstruct;
|
||||
|
||||
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)
|
||||
{
|
||||
TConstruct.logger.info("SUBTRACT WHY");
|
||||
if (supply == null || supply.itemID >= 512 || cost[supply.itemID] == 0)
|
||||
{
|
||||
worldObj.playSoundAtEntity(Minecraft.getMinecraft().thePlayer, "mob.blaze.death", 1.0F, 0.5F);
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage("I require more souls...");
|
||||
return false;
|
||||
}
|
||||
int j = cost[supply.itemID];
|
||||
int k = souls[supply.itemID];
|
||||
int l = (supply.stackSize / j) * k;
|
||||
TConstruct.logger.info((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(Minecraft.getMinecraft().thePlayer, "mob.blaze.death", 1.0F, 0.5F);
|
||||
Minecraft.getMinecraft().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,157 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import tconstruct.util.landmine.behavior.Behavior;
|
||||
import tconstruct.util.landmine.behavior.stackCombo.SpecialStackHandler;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* This logic is designed only for blocks having TileEntityLandmine as their
|
||||
* tileEntity(otherwise ClassCastException will be awarded)
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class LandmineExplodeLogic
|
||||
{
|
||||
|
||||
private final World worldObj;
|
||||
private final Entity triggerer;
|
||||
private final TileEntityLandmine tileEntity;
|
||||
private final int x, y, z;
|
||||
|
||||
public LandmineExplodeLogic(World par1World, int par2, int par3, int par4, Entity entity)
|
||||
{
|
||||
worldObj = par1World;
|
||||
this.tileEntity = (TileEntityLandmine) par1World.getBlockTileEntity(par2, par3, par4);
|
||||
this.x = par2;
|
||||
this.y = par3;
|
||||
this.z = par4;
|
||||
this.triggerer = entity;
|
||||
}
|
||||
|
||||
public void explode ()
|
||||
{
|
||||
if (triggerer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean preventExplode = false;
|
||||
boolean isOffensive = true;
|
||||
boolean cancelDefault = false;
|
||||
|
||||
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
boolean hasExploded = false;
|
||||
|
||||
if (tileEntity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tileEntity.isExploding = true;
|
||||
|
||||
for (int i = 0; i < tileEntity.getSizeTriggerInventory(); i++)
|
||||
{
|
||||
ItemStack currentStack = tileEntity.getStackInSlot(i);
|
||||
Behavior b = Behavior.getBehaviorFromStack(currentStack);
|
||||
if (b != null)
|
||||
{
|
||||
|
||||
if (b.doesBehaviorPreventRemovalOfBlock(currentStack))
|
||||
{
|
||||
preventExplode = true;
|
||||
}
|
||||
|
||||
if (!b.isBehaviorExchangableWithOffensive(currentStack))
|
||||
{
|
||||
isOffensive = false;
|
||||
}
|
||||
|
||||
if (b.overridesDefault())
|
||||
{
|
||||
cancelDefault = true;
|
||||
}
|
||||
|
||||
if (!stacks.isEmpty() && Behavior.arrayContainsEqualStack(stacks, currentStack) && b.effectStacks())
|
||||
{
|
||||
stacks.get(Behavior.arrayIndexOfStack(stacks, currentStack)).stackSize += currentStack.stackSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
stacks.add(currentStack.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LandmineSpecialStackLogic specialStacks = new LandmineSpecialStackLogic(worldObj, x, y, z, triggerer, isOffensive, stacks);
|
||||
specialStacks.handleSpecialStacks();
|
||||
|
||||
Iterator<ItemStack> i1 = stacks.iterator();
|
||||
while (i1.hasNext())
|
||||
{
|
||||
ItemStack currentStack = i1.next();
|
||||
Behavior b = Behavior.getBehaviorFromStack(currentStack);
|
||||
if (b != null)
|
||||
{
|
||||
if (isOffensive || !b.isOffensive(currentStack))
|
||||
{
|
||||
b.executeLogic(worldObj, x, y, z, currentStack, triggerer, !preventExplode);
|
||||
if (b.shouldItemBeRemoved(currentStack, !preventExplode))
|
||||
{
|
||||
if (b.effectStacks())
|
||||
{
|
||||
for (int i = 0; i < tileEntity.getSizeTriggerInventory(); i++)
|
||||
{
|
||||
if (tileEntity.getStackInSlot(i) != null)
|
||||
{
|
||||
if (tileEntity.getStackInSlot(i).isItemEqual(currentStack))
|
||||
{
|
||||
tileEntity.setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean hasRemoved = false;
|
||||
|
||||
for (int i = 0; i < tileEntity.getSizeTriggerInventory() && !hasRemoved; i++)
|
||||
{
|
||||
if (tileEntity.getStackInSlot(i) != null)
|
||||
{
|
||||
if (tileEntity.getStackInSlot(i).isItemEqual(currentStack))
|
||||
{
|
||||
tileEntity.setInventorySlotContents(i, null);
|
||||
hasRemoved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Behavior defBeh = Behavior.getDefaulBehavior();
|
||||
if (defBeh != null && isOffensive && !cancelDefault)
|
||||
{
|
||||
defBeh.executeLogic(worldObj, x, y, z, null, triggerer, !preventExplode);
|
||||
}
|
||||
|
||||
if (hasExploded || defBeh != null && !preventExplode)
|
||||
{
|
||||
worldObj.removeBlockTileEntity(x, y, z);
|
||||
worldObj.setBlockToAir(x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
tileEntity.isExploding = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import tconstruct.util.landmine.behavior.stackCombo.SpecialStackHandler;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class LandmineSpecialStackLogic
|
||||
{
|
||||
|
||||
private final World worldObj;
|
||||
private final Entity triggerer;
|
||||
private final TileEntityLandmine tileEntity;
|
||||
private final int x, y, z;
|
||||
private final boolean isOffensive;
|
||||
private final ArrayList<ItemStack> stackEffects;
|
||||
|
||||
public LandmineSpecialStackLogic(World par1World, int par2, int par3, int par4, Entity entity, boolean mayHurtPlayer, ArrayList<ItemStack> items)
|
||||
{
|
||||
worldObj = par1World;
|
||||
this.tileEntity = (TileEntityLandmine) par1World.getBlockTileEntity(par2, par3, par4);
|
||||
this.x = par2;
|
||||
this.y = par3;
|
||||
this.z = par4;
|
||||
this.triggerer = entity;
|
||||
this.isOffensive = mayHurtPlayer;
|
||||
this.stackEffects = items;
|
||||
}
|
||||
|
||||
public void handleSpecialStacks ()
|
||||
{
|
||||
Iterator<SpecialStackHandler> i1 = SpecialStackHandler.handlers.iterator();
|
||||
|
||||
while (i1.hasNext())
|
||||
{
|
||||
SpecialStackHandler h = i1.next();
|
||||
if (isOffensive || !h.isOffensive(stackEffects))
|
||||
{
|
||||
h.checkStack(worldObj, x, y, z, triggerer, stackEffects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.data);
|
||||
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.data);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
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;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.util.CoordTuple;
|
||||
import tconstruct.library.util.IMasterLogic;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean verifyMaster (IMasterLogic logic, 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;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setPotentialMaster (IMasterLogic master, World world, int x, int y, int z)
|
||||
{
|
||||
return !hasMaster;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyMaster (IMasterLogic logic, World world, int x, int y, int z)
|
||||
{
|
||||
if (hasMaster)
|
||||
{
|
||||
return hasValidMaster();
|
||||
}
|
||||
else
|
||||
{
|
||||
overrideMaster(x, y, z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateMaster (IMasterLogic master, World world, int x, int y, int z)
|
||||
{
|
||||
hasMaster = false;
|
||||
master = null;
|
||||
}
|
||||
|
||||
public void notifyMasterOfChange ()
|
||||
{
|
||||
if (hasValidMaster())
|
||||
{
|
||||
IMasterLogic logic = (IMasterLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
logic.notifyChange(this, xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
hasMaster = tags.getBoolean("TiedToMaster");
|
||||
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("TiedToMaster", 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.data);
|
||||
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 PartBuilderLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
boolean craftedTop;
|
||||
boolean craftedBottom;
|
||||
|
||||
public PartBuilderLogic()
|
||||
{
|
||||
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.data);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.library.crafting.AlloyMix;
|
||||
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 int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (hasValidMaster() && resource != null && canFill(from, resource.getFluid()))
|
||||
{
|
||||
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() && canDrain(from, null))
|
||||
{
|
||||
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 true;
|
||||
//return from == getForgeDirection();//.getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
// Check that the drain is coming from the from the front of the block
|
||||
// and that the fluid to be drained is in the smeltery.
|
||||
boolean containsFluid = fluid == null;
|
||||
if (fluid != null)
|
||||
{
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
for (FluidStack fstack : smeltery.moltenMetal)
|
||||
{
|
||||
if (fstack.fluidID == fluid.getID())
|
||||
{
|
||||
containsFluid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//return from == getForgeDirection().getOpposite() && containsFluid;
|
||||
return containsFluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo (ForgeDirection from)
|
||||
{
|
||||
if (hasValidMaster() && (from == getForgeDirection() || from == getForgeDirection().getOpposite() || from == ForgeDirection.UNKNOWN))
|
||||
{
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
|
||||
return smeltery.getMultiTankInfo();
|
||||
//return new FluidTankInfo[] { smeltery.getInfo() };
|
||||
}
|
||||
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.data);
|
||||
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() == TContent.blankPattern)//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,194 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.nbt.NBTTagList;
|
||||
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.fluids.FluidStack;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.component.TankAirComponent;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import tconstruct.library.util.CoordTuple;
|
||||
import tconstruct.library.util.IMasterLogic;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
|
||||
public class TankAirLogic extends InventoryLogic implements IServantLogic, ISidedInventory
|
||||
{
|
||||
TankAirComponent multitank = new TankAirComponent(TConstruct.ingotLiquidValue * 18);
|
||||
CoordTuple master;
|
||||
|
||||
public TankAirLogic()
|
||||
{
|
||||
super(1);
|
||||
}
|
||||
|
||||
public void overrideFluids (ArrayList<FluidStack> fluids)
|
||||
{
|
||||
/*multitank.overrideFluids(fluids);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);*/
|
||||
}
|
||||
|
||||
public boolean hasItem ()
|
||||
{
|
||||
return inventory[0] != null;
|
||||
}
|
||||
|
||||
public boolean hasFluids ()
|
||||
{
|
||||
return multitank.fluidlist.size() > 0;
|
||||
}
|
||||
|
||||
public List<FluidStack> getFluids ()
|
||||
{
|
||||
return multitank.fluidlist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
/*inventory[slot] = itemstack;
|
||||
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
itemstack.stackSize = getInventoryStackLimit();
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, itemstack.getItemDamage(), 3);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return null; //Not a gui block
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultName ()
|
||||
{
|
||||
return null; //Not a gui block
|
||||
}
|
||||
|
||||
@Override
|
||||
public CoordTuple getMasterPosition ()
|
||||
{
|
||||
return master;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyMasterOfChange ()
|
||||
{
|
||||
//Probably not useful here
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setPotentialMaster (IMasterLogic master, World world, int xMaster, int yMaster, int zMaster)
|
||||
{
|
||||
return false; //Master should be verified right after placement
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyMaster (IMasterLogic logic, World world, int xMaster, int yMaster, int zMaster)
|
||||
{
|
||||
/*if (master != null) //Is this even needed?
|
||||
return false;*/
|
||||
|
||||
master = new CoordTuple(xMaster, yMaster, zMaster);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateMaster (IMasterLogic master, World world, int xMaster, int yMaster, int zMaster)
|
||||
{
|
||||
world.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int var1)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return false;
|
||||
}*/
|
||||
|
||||
//DELETE
|
||||
public void updateEntity ()
|
||||
{
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
//Keep TE regardless of metadata
|
||||
public boolean shouldRefresh (int oldID, int newID, int oldMeta, int newMeta, World world, int x, int y, int z)
|
||||
{
|
||||
return oldID != newID;
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readNetworkNBT(tags);
|
||||
multitank.readFromNBT(tags);
|
||||
}
|
||||
|
||||
public void readNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
multitank.readNetworkNBT(tags);
|
||||
super.readInventoryFromNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeNetworkNBT(tags);
|
||||
multitank.writeToNBT(tags);
|
||||
}
|
||||
|
||||
public void writeNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
multitank.writeNetworkNBT(tags);
|
||||
super.writeInventoryToNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readNetworkNBT(packet.data);
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeNetworkNBT(tag);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
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.tileentity.TileEntityFurnace;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class TileEntityLandmine extends TileEntity implements IInventory
|
||||
{
|
||||
|
||||
private ItemStack[] inventory = new ItemStack[getSizeInventory()];
|
||||
private String containerName;
|
||||
|
||||
public int soundcountythingmax = 10;
|
||||
public int soundcountything = 0;
|
||||
|
||||
private boolean shouldUpdateLogic = true;
|
||||
|
||||
public int triggerType;
|
||||
public boolean isExploding = false;
|
||||
|
||||
public int getSizeTriggerInventory ()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory ()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < this.inventory.length; ++i)
|
||||
{
|
||||
if (this.inventory[i] != null)
|
||||
{
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("Slot", (byte) i);
|
||||
this.inventory[i].writeToNBT(nbttagcompound1);
|
||||
nbttaglist.appendTag(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
par1NBTTagCompound.setTag("Items", nbttaglist);
|
||||
|
||||
par1NBTTagCompound.setInteger("triggerType", triggerType);
|
||||
|
||||
if (this.isInvNameLocalized())
|
||||
{
|
||||
par1NBTTagCompound.setString("CustomName", this.containerName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items");
|
||||
this.inventory = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < nbttaglist.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
|
||||
byte b0 = nbttagcompound1.getByte("Slot");
|
||||
|
||||
if (b0 >= 0 && b0 < this.inventory.length)
|
||||
{
|
||||
this.inventory[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
triggerType = par1NBTTagCompound.getInteger("triggerType");
|
||||
|
||||
if (par1NBTTagCompound.hasKey("CustomName"))
|
||||
{
|
||||
this.containerName = par1NBTTagCompound.getString("CustomName");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 0, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
|
||||
{
|
||||
readFromNBT(packet.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot (int i)
|
||||
{
|
||||
if (i < inventory.length)
|
||||
{
|
||||
return inventory[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int par1, int par2)
|
||||
{
|
||||
if (par1 < inventory.length)
|
||||
{
|
||||
if (inventory[par1] != null)
|
||||
{
|
||||
ItemStack itemstack;
|
||||
|
||||
if (inventory[par1].stackSize <= par2)
|
||||
{
|
||||
itemstack = inventory[par1];
|
||||
inventory[par1] = null;
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemstack = inventory[par1].splitStack(par2);
|
||||
|
||||
if (inventory[par1].stackSize == 0)
|
||||
{
|
||||
inventory[par1] = null;
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing (int i)
|
||||
{
|
||||
if (i < inventory.length && this.inventory[i] != null)
|
||||
{
|
||||
ItemStack itemstack = this.inventory[i];
|
||||
this.inventory[i] = null;
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int i, ItemStack itemstack)
|
||||
{
|
||||
if (i < inventory.length)
|
||||
{
|
||||
inventory[i] = itemstack;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName ()
|
||||
{
|
||||
return this.isInvNameLocalized() ? this.containerName : "Landmine";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized ()
|
||||
{
|
||||
return containerName != null && containerName.length() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
public void setGuiDisplayName (String par1Str)
|
||||
{
|
||||
this.containerName = par1Str;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer (EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D,
|
||||
(double) this.zCoord + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryChanged ()
|
||||
{
|
||||
super.onInventoryChanged();
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot (int i, ItemStack itemstack)
|
||||
{
|
||||
//Should automatic camo insertion be allowed.
|
||||
if (i == 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Here for mDiyo to decide if he wants automation for insertion/extraction of the items to be an option.
|
||||
//Would be useful for building automated mine laying machines.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setSoundPlayed ()
|
||||
{
|
||||
soundcountythingmax = 35;
|
||||
soundcountything = soundcountythingmax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (shouldUpdateLogic)
|
||||
{
|
||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
shouldUpdateLogic = false;
|
||||
}
|
||||
if (soundcountything > 0)
|
||||
{
|
||||
soundcountything--;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 "crafters.ToolForge";
|
||||
}
|
||||
|
||||
@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 "crafters.ToolStation";
|
||||
}
|
||||
|
||||
@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.markTileEntityChunkModified(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,18 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import tconstruct.library.blocks.AdaptiveInventoryLogic;
|
||||
import tconstruct.library.util.IActiveLogic;
|
||||
import tconstruct.library.util.IFacingLogic;
|
||||
import tconstruct.library.util.IMasterLogic;
|
||||
|
||||
//Not actually abstract
|
||||
public abstract class TowerFurnaceLogic extends AdaptiveInventoryLogic implements IActiveLogic, IFacingLogic, IMasterLogic
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package tconstruct.blocks.slime;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
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.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.BlockFluidClassic;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import tconstruct.entity.BlueSlime;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SlimeFluid extends BlockFluidClassic
|
||||
{
|
||||
Icon stillIcon;
|
||||
Icon flowIcon;
|
||||
|
||||
public SlimeFluid(int id, Fluid fluid, Material material)
|
||||
{
|
||||
super(id, fluid, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
stillIcon = iconRegister.registerIcon("tinker:slime_blue");
|
||||
flowIcon = iconRegister.registerIcon("tinker:slime_blue_flow");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
if (side == 0 || side == 1)
|
||||
return stillIcon;
|
||||
return flowIcon;
|
||||
}
|
||||
|
||||
public void updateTick (World world, int x, int y, int z, Random rand)
|
||||
{
|
||||
super.updateTick(world, x, y, z, rand);
|
||||
if (rand.nextInt(100) == 0 && world.getBlockMetadata(x, y, z) == 0 && world.checkNoEntityCollision(AxisAlignedBB.getBoundingBox(x - 1, y - 1, z - 1, x + 2, y + 2, z + 2)))
|
||||
{
|
||||
BlueSlime entityslime = new BlueSlime(world);
|
||||
entityslime.setPosition((double) x + 0.5D, (double) y + 1.5D, (double) z + 0.5D);
|
||||
world.spawnEntityInWorld(entityslime);
|
||||
}
|
||||
}
|
||||
|
||||
public void getSubBlocks (int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package tconstruct.blocks.slime;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.blocks.TConstructBlock;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SlimeGel extends TConstructBlock
|
||||
{
|
||||
public SlimeGel(int id)
|
||||
{
|
||||
super(id, Material.sponge, 0.5f, new String[] { "slimeblock_blue", "slimeblock_green", "slimeblock_purple" });
|
||||
setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
public boolean getEnableStats ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getMobilityFlag ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int damageDropped (int meta)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (entity.motionY < 0)
|
||||
{
|
||||
if (entity.motionY < -0.08F)
|
||||
{
|
||||
Block var9 = Block.blocksList[this.blockID];
|
||||
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, var9.stepSound.getStepSound(), (var9.stepSound.getVolume()) / 2.0F, var9.stepSound.getPitch() * 0.65F);
|
||||
}
|
||||
entity.motionY *= -1.2F;
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.jump.id, 1, 2));
|
||||
}
|
||||
}
|
||||
entity.fallDistance = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 0.625D, (double) z + 1.0D);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
/**
|
||||
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||
*/
|
||||
public void getSubBlocks (int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, 0));
|
||||
par3List.add(new ItemStack(par1, 1, 1));
|
||||
//par3List.add(new ItemStack(par1, 1, 2));
|
||||
}
|
||||
|
||||
public boolean canSustainLeaves (World world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package tconstruct.blocks.slime;
|
||||
|
||||
import java.util.List;
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SlimeGrass extends Block
|
||||
{
|
||||
public String[] textureNames = { "slimegrass_green_top", "slimedirt_blue", "slimegrass_green_blue_side", "slimegrass_green_dirt_side" };//green, purple
|
||||
public Icon[] icons;
|
||||
|
||||
public SlimeGrass(int id)
|
||||
{
|
||||
super(id, Material.grass);
|
||||
setHardness(0.6f);
|
||||
this.setTickRandomly(true);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped (int meta)
|
||||
{
|
||||
if (meta == 1) //dirt
|
||||
return 0;
|
||||
|
||||
else
|
||||
//slime dirt
|
||||
return 5;
|
||||
}
|
||||
|
||||
@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)
|
||||
{
|
||||
if (meta >= 2)
|
||||
meta = 0;
|
||||
|
||||
if (side == 0)
|
||||
{
|
||||
return meta % 2 == 1 ? Block.dirt.getIcon(0, 0) : icons[1];
|
||||
}
|
||||
else if (side == 1)
|
||||
{
|
||||
return icons[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return icons[meta + 2];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 1; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSustainPlant (World world, int x, int y, int z, ForgeDirection direction, IPlantable plant)
|
||||
{
|
||||
EnumPlantType plantType = plant.getPlantType(world, x, y + 1, z);
|
||||
return plantType == EnumPlantType.Plains && plant.getPlantID(world, x, y + 1, z) != Block.tallGrass.blockID;
|
||||
}
|
||||
|
||||
public void onPlantGrow (World world, int x, int y, int z, int sourceX, int sourceY, int sourceZ)
|
||||
{
|
||||
world.setBlock(x, y, z, TContent.craftedSoil.blockID, 5, 3);
|
||||
}
|
||||
|
||||
public void updateTick (World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
if (par1World.getBlockLightValue(par2, par3 + 1, par4) < 4 && par1World.getBlockLightOpacity(par2, par3 + 1, par4) > 2)
|
||||
{
|
||||
par1World.setBlock(par2, par3, par4, TContent.craftedSoil.blockID, 5, 3);
|
||||
}
|
||||
else if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)
|
||||
{
|
||||
for (int l = 0; l < 4; ++l)
|
||||
{
|
||||
int posX = par2 + par5Random.nextInt(3) - 1;
|
||||
int posY = par3 + par5Random.nextInt(5) - 3;
|
||||
int posZ = par4 + par5Random.nextInt(3) - 1;
|
||||
int l1 = par1World.getBlockId(posX, posY + 1, posZ);
|
||||
|
||||
if (par1World.getBlockLightValue(posX, posY + 1, posZ) >= 4 && par1World.getBlockLightOpacity(posX, posY + 1, posZ) <= 2)
|
||||
{
|
||||
int blockID = par1World.getBlockId(posX, posY, posZ);
|
||||
if (blockID == Block.dirt.blockID)
|
||||
{
|
||||
par1World.setBlock(posX, posY, posZ, this.blockID, 1, 3);
|
||||
return;
|
||||
}
|
||||
int blockMeta = par1World.getBlockMetadata(posX, posY, posZ);
|
||||
if (blockID == TContent.craftedSoil.blockID)
|
||||
{
|
||||
if (blockMeta == 5)
|
||||
par1World.setBlock(posX, posY, posZ, this.blockID, 0, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int idDropped (int metadata, Random random, int fortune)
|
||||
{
|
||||
if (metadata == 1)
|
||||
return Block.dirt.blockID;
|
||||
else
|
||||
return TContent.craftedSoil.blockID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package tconstruct.blocks.slime;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
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;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SlimeLeaves extends BlockLeaves
|
||||
{
|
||||
private static final String[] fastLeaves = new String[] { "slimeleaves_blue_fast" };
|
||||
private static final String[] fancyLeaves = new String[] { "slimeleaves_blue_fancy" };
|
||||
@SideOnly(Side.CLIENT)
|
||||
private Icon[] fastIcons;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private Icon[] fancyIcons;
|
||||
|
||||
public SlimeLeaves(int id)
|
||||
{
|
||||
super(id);
|
||||
setCreativeTab(TConstructRegistry.blockTab);
|
||||
setLightOpacity(1);
|
||||
this.setHardness(0.3f);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getBlockColor ()
|
||||
{
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderColor (int par1)
|
||||
{
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int colorMultiplier (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
this.fastIcons = new Icon[fastLeaves.length];
|
||||
this.fancyIcons = new Icon[fancyLeaves.length];
|
||||
|
||||
for (int i = 0; i < this.fastIcons.length; i++)
|
||||
{
|
||||
this.fastIcons[i] = iconRegister.registerIcon("tinker:" + fastLeaves[i]);
|
||||
this.fancyIcons[i] = iconRegister.registerIcon("tinker:" + fancyLeaves[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
int tex = meta % 4;
|
||||
|
||||
if (this.graphicsLevel)
|
||||
return fancyIcons[tex];
|
||||
else
|
||||
return fastIcons[tex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < fastIcons.length; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeaves (World world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Drops */
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped (int par1, Random par2Random, int par3)
|
||||
{
|
||||
return TContent.slimeSapling.blockID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the block items with a specified chance of dropping the specified items
|
||||
*/
|
||||
public void dropBlockAsItemWithChance (World world, int x, int y, int z, int meta, float chance, int fortune)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
int dropChance = 35;
|
||||
|
||||
/*if ((meta & 3) == 3)
|
||||
{
|
||||
j1 = 40;
|
||||
}*/
|
||||
|
||||
if (fortune > 0)
|
||||
{
|
||||
dropChance -= 2 << fortune;
|
||||
|
||||
if (dropChance < 15)
|
||||
{
|
||||
dropChance = 15;
|
||||
}
|
||||
}
|
||||
|
||||
if (world.rand.nextInt(dropChance) == 0)
|
||||
{
|
||||
int k1 = this.idDropped(meta, world.rand, fortune);
|
||||
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(k1, 1, this.damageDropped(meta)));
|
||||
}
|
||||
|
||||
dropChance = 80;
|
||||
|
||||
if (fortune > 0)
|
||||
{
|
||||
dropChance -= 10 << fortune;
|
||||
|
||||
if (dropChance < 20)
|
||||
{
|
||||
dropChance = 20;
|
||||
}
|
||||
}
|
||||
|
||||
if ((meta & 3) == 0 && world.rand.nextInt(dropChance) == 0)
|
||||
{
|
||||
this.dropBlockAsItem_do(world, x, y, z, new ItemStack(TContent.strangeFood, 1, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package tconstruct.blocks.slime;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSapling;
|
||||
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.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.worldgen.SlimeTreeGen;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SlimeSapling extends BlockSapling
|
||||
{
|
||||
public Icon[] icons;
|
||||
public String[] textureNames = new String[] { "blue" };
|
||||
|
||||
public SlimeSapling(int id)
|
||||
{
|
||||
super(id);
|
||||
float f = 0.4F;
|
||||
setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
|
||||
this.setHardness(0.0F);
|
||||
this.setStepSound(Block.soundGrassFootstep);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
@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:slimesapling_" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canThisPlantGrowOnThisBlockID (int id)
|
||||
{
|
||||
return id == Block.grass.blockID || id == Block.dirt.blockID || id == TContent.slimeGrass.blockID || id == TContent.craftedSoil.blockID;
|
||||
}
|
||||
|
||||
public void updateTick (World world, int x, int y, int z, Random random)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
super.updateTick(world, x, y, z, random);
|
||||
int md = world.getBlockMetadata(x, y, z);
|
||||
if (random.nextInt(10) == 0 && world.getBlockLightValue(x, y + 1, z) >= 9)
|
||||
{
|
||||
if ((md & 8) == 0)
|
||||
world.setBlockMetadataWithNotify(x, y, z, md | 8, 4);
|
||||
|
||||
else
|
||||
growTree(world, x, y, z, random);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[meta % 8];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markOrGrowMarked (World world, int x, int y, int z, Random random)
|
||||
{
|
||||
boneFertilize(world, x, y, z, random, null);
|
||||
}
|
||||
|
||||
public boolean boneFertilize (World world, int x, int y, int z, Random random, EntityPlayer player)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if (meta % 8 == 0 && (player == null || !player.capabilities.isCreativeMode))
|
||||
return false;
|
||||
|
||||
if ((meta & 8) == 0)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.growTree(world, x, y, z, random);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void growTree (World world, int x, int y, int z, Random random)
|
||||
{
|
||||
int md = world.getBlockMetadata(x, y, z) % 8;
|
||||
world.setBlock(x, y, z, 0);
|
||||
WorldGenerator obj = null;
|
||||
|
||||
obj = new SlimeTreeGen(true, 5, 4, 1, 0);
|
||||
|
||||
if (!(obj.generate(world, random, x, y, z)))
|
||||
world.setBlock(x, y, z, blockID, md + 8, 3);
|
||||
}
|
||||
|
||||
public int damageDropped (int i)
|
||||
{
|
||||
return i % 8;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubBlocks (int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for (int i = 0; i < 1; i++)
|
||||
par3List.add(new ItemStack(par1, 1, i));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package tconstruct.blocks.slime;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockFlower;
|
||||
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;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.IShearable;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SlimeTallGrass extends BlockFlower implements IShearable
|
||||
{
|
||||
private static final String[] grassTypes = new String[] { "slimegrass_blue_tall" };
|
||||
@SideOnly(Side.CLIENT)
|
||||
private Icon[] iconArray;
|
||||
|
||||
public SlimeTallGrass(int par1)
|
||||
{
|
||||
super(par1, Material.vine);
|
||||
float f = 0.4F;
|
||||
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
|
||||
setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
/*if (meta >= this.iconArray.length)
|
||||
{
|
||||
meta = 0;
|
||||
}*/
|
||||
|
||||
return this.iconArray[meta];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped (int par1, Random par2Random, int par3)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the usual quantity dropped by the block plus a bonus of 1 to 'i' (inclusive).
|
||||
*/
|
||||
public int quantityDroppedWithBonus (int par1, Random par2Random)
|
||||
{
|
||||
return 1 + par2Random.nextInt(par1 * 2 + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the block's damage value (for use with pick block).
|
||||
*/
|
||||
public int getDamageValue (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return par1World.getBlockMetadata(par2, par3, par4);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
/**
|
||||
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
|
||||
*/
|
||||
public void getSubBlocks (int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for (int j = 0; j < 1; ++j)
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, j));
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerIcons (IconRegister par1IconRegister)
|
||||
{
|
||||
this.iconArray = new Icon[grassTypes.length];
|
||||
|
||||
for (int i = 0; i < this.iconArray.length; ++i)
|
||||
{
|
||||
this.iconArray[i] = par1IconRegister.registerIcon("tinker:" + grassTypes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getBlockDropped (World world, int x, int y, int z, int meta, int fortune)
|
||||
{
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
if (world.rand.nextInt(8) != 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ItemStack item = ForgeHooks.getGrassSeed(world);
|
||||
if (item != null)
|
||||
{
|
||||
ret.add(item);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShearable (ItemStack item, World world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> onSheared (ItemStack item, World world, int x, int y, int z, int fortune)
|
||||
{
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z)));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package tconstruct.blocks.traps;
|
||||
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.client.block.BarricadeRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BarricadeBlock extends Block
|
||||
{
|
||||
Block modelBlock;
|
||||
int modelMeta;
|
||||
|
||||
public BarricadeBlock(int blockID, Block model, int meta)
|
||||
{
|
||||
super(blockID, Material.wood);
|
||||
this.modelBlock = model;
|
||||
this.modelMeta = meta;
|
||||
setHardness(4.0F);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
public Icon getIcon (int side, int meta)
|
||||
{
|
||||
return modelBlock.getIcon(2, modelMeta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons (IconRegister par1IconRegister)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockExploded (World world, int x, int y, int z, Explosion explosion)
|
||||
{
|
||||
double distance = (x - explosion.explosionX) + (y - explosion.explosionY) + (z - explosion.explosionZ);
|
||||
distance = Math.abs(distance);
|
||||
double power = (explosion.explosionSize * 2) / distance;
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
int trueMeta = meta % 4;
|
||||
trueMeta -= power;
|
||||
if (trueMeta < 0)
|
||||
world.setBlockToAir(x, y, z);
|
||||
else
|
||||
world.setBlockMetadataWithNotify(x, y, z, (int) (meta - power), 3);
|
||||
onBlockDestroyedByExplosion(world, x, y, z, explosion);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
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,121 @@
|
||||
package tconstruct.blocks.traps;
|
||||
|
||||
import java.util.List;
|
||||
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.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.client.block.PunjiRender;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class Punji extends Block
|
||||
{
|
||||
|
||||
public Punji(int id)
|
||||
{
|
||||
super(id, Material.plants);
|
||||
this.setBlockBounds(0.125f, 0, 0.125f, 0.875f, 0.375f, 0.875f);
|
||||
this.setStepSound(Block.soundGrassFootstep);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setHardness(3.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
int damage = world.getBlockMetadata(x, y, z) / 2 + 1;
|
||||
if (entity.fallDistance > 0)
|
||||
damage += ((entity.fallDistance) * 1.5 + 2);
|
||||
entity.attackEntityFrom(DamageSource.cactus, damage);
|
||||
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 20, 1));
|
||||
}
|
||||
}
|
||||
|
||||
/* Right-click adds sticks */
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
/*if (world.isRemote)
|
||||
return false;*/
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta < 4)
|
||||
{
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack != null && stack.itemID == TContent.punji.blockID)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta + 1, 3);
|
||||
world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), this.stepSound.getPlaceSound(),
|
||||
(this.stepSound.getVolume() + 1.0F) / 2.0F, this.stepSound.getPitch() * 0.8F);
|
||||
player.swingItem();
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.stackSize--;
|
||||
if (stack.stackSize <= 0)
|
||||
player.destroyCurrentEquippedItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped (int meta, int fortune, Random random)
|
||||
{
|
||||
return meta + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 int getRenderType ()
|
||||
{
|
||||
return PunjiRender.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
this.blockIcon = iconRegister.registerIcon("tinker:punji");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
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;
|
||||
}
|
||||
TextureManager texturemanager = this.mc.getTextureManager();
|
||||
texturemanager.bindTexture(texturemanager.getResourceLocation(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.getIconWidth(), icon.getIconHeight(), 0.0625F);
|
||||
|
||||
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.bindEntityTexture(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.getResourceLocation(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().getTextureManager();
|
||||
ResourceLocation resourcelocation = texturemanager.getResourceLocation(par1EntityItem.getEntityItem().getItemSpriteNumber());
|
||||
par2Icon = ((TextureMap) texturemanager.getTexture(resourcelocation)).getAtlasSprite("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.bindTexture(TextureMap.locationBlocksTexture);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.bindTexture(TextureMap.locationItemsTexture);
|
||||
}
|
||||
|
||||
GL11.glColor4f(par5, par6, par7, 1.0F);
|
||||
ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, ((Icon) par2Icon).getIconWidth(), ((Icon) par2Icon).getIconHeight(), f12);
|
||||
|
||||
if (itemstack.hasEffect(pass))
|
||||
{
|
||||
GL11.glDepthFunc(GL11.GL_EQUAL);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
this.renderManager.renderEngine.bindTexture(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.getItem() == null ? null : par3ItemStack.getIconIndex();
|
||||
float f;
|
||||
int i1;
|
||||
float f1;
|
||||
float f2;
|
||||
|
||||
Block block = (k < Block.blocksList.length ? Block.blocksList[k] : null);
|
||||
if (block != null && par3ItemStack.getItemSpriteNumber() == 0 && RenderBlocks.renderItemIn3d(Block.blocksList[k].getRenderType()))
|
||||
{
|
||||
par2TextureManager.bindTexture(TextureMap.locationBlocksTexture);
|
||||
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] != null && Item.itemsList[k].requiresMultipleRenderPasses())
|
||||
{
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
for (int j1 = 0; j1 < Item.itemsList[k].getRenderPasses(l); ++j1)
|
||||
{
|
||||
par2TextureManager.bindTexture(par3ItemStack.getItemSpriteNumber() == 0 ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture);
|
||||
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.getResourceLocation(par3ItemStack.getItemSpriteNumber());
|
||||
par2TextureManager.bindTexture(resourcelocation);
|
||||
|
||||
if (object == null)
|
||||
{
|
||||
object = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(resourcelocation)).getAtlasSprite("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.bindTexture(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.bindTexture(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 getEntityTexture (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,30 @@
|
||||
package tconstruct.client;
|
||||
|
||||
import net.minecraft.block.StepSound;
|
||||
|
||||
public class StepSoundSlime extends StepSound
|
||||
{
|
||||
|
||||
public StepSoundSlime(String par1Str, float par2, float par3)
|
||||
{
|
||||
super(par1Str, par2, par3);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* Used when a block breaks, EXA: Player break, Shep eating grass, etc..
|
||||
*/
|
||||
public String getBreakSound ()
|
||||
{
|
||||
return this.stepSoundName + ".big";
|
||||
}
|
||||
|
||||
/**
|
||||
* Used when a entity walks over, or otherwise interacts with the block.
|
||||
*/
|
||||
public String getStepSound ()
|
||||
{
|
||||
return this.stepSoundName + ".small";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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,309 @@
|
||||
package tconstruct.client;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeInstance;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.GuiIngameForge;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.client.armor.WingModel;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.util.player.TPlayerStats;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TClientEvents
|
||||
{
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
/* Sounds */
|
||||
|
||||
boolean initSounds;
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onSound (SoundLoadEvent event)
|
||||
{
|
||||
if (!initSounds)
|
||||
{
|
||||
initSounds = true;
|
||||
try
|
||||
{
|
||||
SoundManager soundmanager = event.manager;
|
||||
soundmanager.addSound("tinker:frypan_hit.ogg");
|
||||
soundmanager.addSound("tinker:little_saw.ogg");
|
||||
soundmanager.addSound("tinker:launcher_clank.ogg");
|
||||
TConstruct.logger.info("Successfully loaded sounds.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TConstruct.logger.warning("Failed to register one or more sounds");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Liquids */
|
||||
|
||||
Icon[] stillIcons = new Icon[2];
|
||||
Icon[] flowIcons = new Icon[2];
|
||||
|
||||
@ForgeSubscribe
|
||||
public void preStitch (TextureStitchEvent.Pre event)
|
||||
{
|
||||
TextureMap register = event.map;
|
||||
if (register.textureType == 0)
|
||||
{
|
||||
stillIcons[0] = register.registerIcon("tinker:liquid_pigiron");
|
||||
flowIcons[0] = register.registerIcon("tinker:liquid_pigiron");
|
||||
}
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void postStitch (TextureStitchEvent.Post event)
|
||||
{
|
||||
if (event.map.textureType == 0)
|
||||
{
|
||||
for (int i = 0; i < TContent.fluidBlocks.length; i++)
|
||||
{
|
||||
TContent.fluids[i].setIcons(TContent.fluidBlocks[i].getIcon(0, 0), TContent.fluidBlocks[i].getIcon(2, 0));
|
||||
}
|
||||
TContent.pigIronFluid.setIcons(stillIcons[0], flowIcons[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static final ResourceLocation hearts = new ResourceLocation("tinker", "textures/gui/newhearts.png");
|
||||
private static final ResourceLocation icons = new ResourceLocation("textures/gui/icons.png");
|
||||
Random rand = new Random();
|
||||
int updateCounter = 0;
|
||||
|
||||
boolean tukmc = Loader.isModLoaded("tukmc_Vz");
|
||||
GameSettings gs = Minecraft.getMinecraft().gameSettings;
|
||||
/* HUD */
|
||||
@ForgeSubscribe
|
||||
public void renderHealthbar (RenderGameOverlayEvent.Pre event)
|
||||
{
|
||||
if (!tukmc)// Loader check to avoid conflicting with a GUI mod (thanks Vazkii!)
|
||||
{
|
||||
if (event.type == ElementType.HEALTH)
|
||||
{
|
||||
updateCounter++;
|
||||
|
||||
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);
|
||||
|
||||
boolean highlight = mc.thePlayer.hurtResistantTime / 3 % 2 == 1;
|
||||
|
||||
if (mc.thePlayer.hurtResistantTime < 10)
|
||||
{
|
||||
highlight = false;
|
||||
}
|
||||
|
||||
AttributeInstance attrMaxHealth = this.mc.thePlayer.getEntityAttribute(SharedMonsterAttributes.maxHealth);
|
||||
int health = MathHelper.ceiling_float_int(mc.thePlayer.getHealth());
|
||||
int healthLast = MathHelper.ceiling_float_int(mc.thePlayer.prevHealth);
|
||||
float healthMax = (float) attrMaxHealth.getAttributeValue();
|
||||
if (healthMax > 20)
|
||||
healthMax = 20;
|
||||
float absorb = this.mc.thePlayer.getAbsorptionAmount();
|
||||
|
||||
int healthRows = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F / 10.0F);
|
||||
int rowHeight = Math.max(10 - (healthRows - 2), 3);
|
||||
|
||||
this.rand.setSeed((long) (updateCounter * 312871));
|
||||
|
||||
int left = scaledWidth / 2 - 91;
|
||||
int top = scaledHeight - GuiIngameForge.left_height;
|
||||
|
||||
int regen = -1;
|
||||
if (mc.thePlayer.isPotionActive(Potion.regeneration))
|
||||
{
|
||||
regen = updateCounter % 25;
|
||||
}
|
||||
|
||||
final int TOP = 9 * (mc.theWorld.getWorldInfo().isHardcoreModeEnabled() ? 5 : 0);
|
||||
final int BACKGROUND = (highlight ? 25 : 16);
|
||||
int MARGIN = 16;
|
||||
if (mc.thePlayer.isPotionActive(Potion.poison))
|
||||
MARGIN += 36;
|
||||
else if (mc.thePlayer.isPotionActive(Potion.wither))
|
||||
MARGIN += 72;
|
||||
float absorbRemaining = absorb;
|
||||
|
||||
for (int i = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F) - 1; i >= 0; --i)
|
||||
{
|
||||
int b0 = (highlight ? 1 : 0);
|
||||
int row = MathHelper.ceiling_float_int((float) (i + 1) / 10.0F) - 1;
|
||||
int x = left + i % 10 * 8;
|
||||
int y = top - row * rowHeight;
|
||||
|
||||
if (health <= 4)
|
||||
y += rand.nextInt(2);
|
||||
if (i == regen)
|
||||
y -= 2;
|
||||
|
||||
drawTexturedModalRect(x, y, BACKGROUND, TOP, 9, 9);
|
||||
|
||||
if (highlight)
|
||||
{
|
||||
if (i * 2 + 1 < healthLast)
|
||||
drawTexturedModalRect(x, y, MARGIN + 54, TOP, 9, 9); //6
|
||||
else if (i * 2 + 1 == healthLast)
|
||||
drawTexturedModalRect(x, y, MARGIN + 63, TOP, 9, 9); //7
|
||||
}
|
||||
|
||||
if (absorbRemaining > 0.0F)
|
||||
{
|
||||
if (absorbRemaining == absorb && absorb % 2.0F == 1.0F)
|
||||
drawTexturedModalRect(x, y, MARGIN + 153, TOP, 9, 9); //17
|
||||
else
|
||||
drawTexturedModalRect(x, y, MARGIN + 144, TOP, 9, 9); //16
|
||||
absorbRemaining -= 2.0F;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i * 2 + 1 < health)
|
||||
drawTexturedModalRect(x, y, MARGIN + 36, TOP, 9, 9); //4
|
||||
else if (i * 2 + 1 == health)
|
||||
drawTexturedModalRect(x, y, MARGIN + 45, TOP, 9, 9); //5
|
||||
}
|
||||
}
|
||||
|
||||
PotionEffect potion = mc.thePlayer.getActivePotionEffect(Potion.wither);
|
||||
if (potion != null)
|
||||
return;
|
||||
potion = mc.thePlayer.getActivePotionEffect(Potion.poison);
|
||||
if (potion != null)
|
||||
return;
|
||||
|
||||
//Extra hearts
|
||||
this.mc.getTextureManager().bindTexture(hearts);
|
||||
|
||||
int hp = MathHelper.ceiling_float_int(this.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.getTextureManager().bindTexture(icons);
|
||||
GuiIngameForge.left_height += 10;
|
||||
if (absorb > 0)
|
||||
GuiIngameForge.left_height += 10;
|
||||
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
if (event.type == ElementType.CROSSHAIRS && gs.thirdPersonView != 0)
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
/*@ForgeSubscribe
|
||||
public void getFOV(FOVUpdateEvent event)
|
||||
{
|
||||
float f = 1.0F;
|
||||
|
||||
if (event.entity.capabilities.isFlying)
|
||||
{
|
||||
f *= 1.1F;
|
||||
}
|
||||
|
||||
if (event.entity.isUsingItem() && event.entity.getItemInUse().itemID == Item.bow.itemID)
|
||||
{
|
||||
int i = event.entity.getItemInUseDuration();
|
||||
float f1 = (float) i / 20.0F;
|
||||
|
||||
if (f1 > 1.0F)
|
||||
{
|
||||
f1 = 1.0F;
|
||||
}
|
||||
else
|
||||
{
|
||||
f1 *= f1;
|
||||
}
|
||||
|
||||
f *= 1.0F - f1 * 0.15F;
|
||||
}
|
||||
event.newfov = f;
|
||||
}*/
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 537 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user