removed more errors
This commit is contained in:
parent
485ca799d8
commit
c961f3634e
12 changed files with 221 additions and 721 deletions
|
@ -1,100 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (c) SpaceToad, 2011
|
|
||||||
* http://www.mod-buildcraft.com
|
|
||||||
*
|
|
||||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
|
||||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
|
||||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
|
||||||
*/
|
|
||||||
|
|
||||||
package dark.core.hydraulic.helpers;
|
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
public class EntityBlock extends Entity
|
|
||||||
{
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public Icon texture;
|
|
||||||
public float shadowSize = 0;
|
|
||||||
|
|
||||||
public float rotationX = 0;
|
|
||||||
public float rotationY = 0;
|
|
||||||
public float rotationZ = 0;
|
|
||||||
|
|
||||||
public double iSize, jSize, kSize;
|
|
||||||
|
|
||||||
public EntityBlock(World world)
|
|
||||||
{
|
|
||||||
super(world);
|
|
||||||
preventEntitySpawning = false;
|
|
||||||
noClip = true;
|
|
||||||
isImmuneToFire = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityBlock(World world, double xPos, double yPos, double zPos)
|
|
||||||
{
|
|
||||||
super(world);
|
|
||||||
setPositionAndRotation(xPos, yPos, zPos, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityBlock(World world, double i, double j, double k, double iSize, double jSize, double kSize)
|
|
||||||
{
|
|
||||||
this(world);
|
|
||||||
this.iSize = iSize;
|
|
||||||
this.jSize = jSize;
|
|
||||||
this.kSize = kSize;
|
|
||||||
setPositionAndRotation(i, j, k, 0, 0);
|
|
||||||
this.motionX = 0.0;
|
|
||||||
this.motionY = 0.0;
|
|
||||||
this.motionZ = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPosition(double d, double d1, double d2)
|
|
||||||
{
|
|
||||||
super.setPosition(d, d1, d2);
|
|
||||||
boundingBox.minX = posX;
|
|
||||||
boundingBox.minY = posY;
|
|
||||||
boundingBox.minZ = posZ;
|
|
||||||
|
|
||||||
boundingBox.maxX = posX + iSize;
|
|
||||||
boundingBox.maxY = posY + jSize;
|
|
||||||
boundingBox.maxZ = posZ + kSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void moveEntity(double d, double d1, double d2)
|
|
||||||
{
|
|
||||||
setPosition(posX + d, posY + d1, posZ + d2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void entityInit()
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void readEntityFromNBT(NBTTagCompound nbttagcompound)
|
|
||||||
{
|
|
||||||
iSize = nbttagcompound.getDouble("iSize");
|
|
||||||
jSize = nbttagcompound.getDouble("jSize");
|
|
||||||
kSize = nbttagcompound.getDouble("kSize");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeEntityToNBT(NBTTagCompound nbttagcompound)
|
|
||||||
{
|
|
||||||
nbttagcompound.setDouble("iSize", iSize);
|
|
||||||
nbttagcompound.setDouble("jSize", jSize);
|
|
||||||
nbttagcompound.setDouble("kSize", kSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,175 +1,50 @@
|
||||||
package dark.core.hydraulic.helpers;
|
package dark.core.hydraulic.helpers;
|
||||||
|
|
||||||
|
import universalelectricity.core.vector.Vector3;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.IFluidBlock;
|
import net.minecraftforge.fluids.IFluidBlock;
|
||||||
import universalelectricity.core.vector.Vector3;
|
|
||||||
|
|
||||||
public class FluidHelper
|
public class FluidHelper
|
||||||
{
|
{
|
||||||
/** The default built in flow rate of the liquid threw the pipes. Will correct this later to use
|
|
||||||
* a visc value instead of flow value so that the size of the pipe can play a factor in flow */
|
|
||||||
public static int getDefaultFlowRate(FluidStack stack)
|
|
||||||
{
|
|
||||||
if (stack != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
String stackName = LiquidDictionary.findLiquidName(stack);
|
|
||||||
if (stackName.equalsIgnoreCase("UraniumHexafluoride"))
|
|
||||||
{
|
|
||||||
return 1000;
|
|
||||||
}
|
|
||||||
else if (stackName.equalsIgnoreCase("steam"))
|
|
||||||
{
|
|
||||||
return 1000;
|
|
||||||
}
|
|
||||||
else if (stackName.equalsIgnoreCase("methane"))
|
|
||||||
{
|
|
||||||
return 1000;
|
|
||||||
}
|
|
||||||
else if (stackName.equalsIgnoreCase("lava"))
|
|
||||||
{
|
|
||||||
return 250;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Creates a new LiquidStack using the sample stack
|
/** Gets the block's fluid if it has one
|
||||||
*
|
*
|
||||||
* @param stack - liquidLiquid being used to create the stack
|
* @param world - world we are working in
|
||||||
* @param vol - amount or volume of the stack
|
* @param vector - 3D location in world
|
||||||
* @return a new @LiquidStack */
|
* @return @Fluid that the block is */
|
||||||
public static LiquidStack getStack(LiquidStack stack, int vol)
|
public static Fluid getLiquidFromBlock(World world, Vector3 vector)
|
||||||
{
|
{
|
||||||
if (stack == null)
|
return FluidHelper.getFluidFromBlockID(vector.getBlockID(world));
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new LiquidStack(stack.itemID, vol, stack.itemMeta);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Consumes one item of a the ItemStack */
|
/** Gets a fluid from blockID */
|
||||||
public static ItemStack consumeItem(ItemStack stack)
|
public static Fluid getFluidFromBlockID(int id)
|
||||||
{
|
|
||||||
if (stack.stackSize == 1)
|
|
||||||
{
|
|
||||||
if (stack.getItem().hasContainerItem())
|
|
||||||
{
|
|
||||||
return stack.getItem().getContainerItemStack(stack);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stack.splitStack(1);
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** gets the blockID/ItemID of the Still liquid
|
|
||||||
*
|
|
||||||
* @param id - blockID
|
|
||||||
* @return will return -1 if its not a valid liquid Block */
|
|
||||||
public static int getLiquidId(int id)
|
|
||||||
{
|
{
|
||||||
if (id == Block.waterStill.blockID || id == Block.waterMoving.blockID)
|
if (id == Block.waterStill.blockID || id == Block.waterMoving.blockID)
|
||||||
{
|
{
|
||||||
return Block.waterStill.blockID;
|
return FluidRegistry.getFluid("water");
|
||||||
}
|
}
|
||||||
else if (id == Block.lavaStill.blockID || id == Block.lavaMoving.blockID)
|
else if (id == Block.lavaStill.blockID || id == Block.lavaMoving.blockID)
|
||||||
{
|
{
|
||||||
return Block.lavaStill.blockID;
|
return FluidRegistry.getFluid("lava");
|
||||||
}
|
}
|
||||||
else if (Block.blocksList[id] instanceof IFluidBlock)
|
else if (Block.blocksList[id] instanceof IFluidBlock)
|
||||||
{
|
{
|
||||||
return ((IFluidBlock) Block.blocksList[id]).getFluid().getBlockID();
|
return ((IFluidBlock) Block.blocksList[id]).getFluid();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** gets the liquidStack of the block
|
|
||||||
*
|
|
||||||
* @param id - block's ID */
|
|
||||||
public static LiquidStack getLiquidFromBlockId(int id)
|
|
||||||
{
|
|
||||||
if (id == Block.waterStill.blockID || id == Block.waterMoving.blockID)
|
|
||||||
{
|
|
||||||
return new LiquidStack(Block.waterStill.blockID, LiquidContainerRegistry.BUCKET_VOLUME, 0);
|
|
||||||
}
|
|
||||||
else if (id == Block.lavaStill.blockID || id == Block.lavaMoving.blockID)
|
|
||||||
{
|
|
||||||
return new LiquidStack(Block.lavaStill.blockID, LiquidContainerRegistry.BUCKET_VOLUME, 0);
|
|
||||||
}
|
|
||||||
else if (Block.blocksList[id] instanceof ILiquid)
|
|
||||||
{
|
|
||||||
ILiquid liquid = (ILiquid) Block.blocksList[id];
|
|
||||||
if (liquid.isMetaSensitive())
|
|
||||||
{
|
|
||||||
return new LiquidStack(liquid.stillLiquidId(), LiquidContainerRegistry.BUCKET_VOLUME, liquid.stillLiquidMeta());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new LiquidStack(liquid.stillLiquidId(), LiquidContainerRegistry.BUCKET_VOLUME, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Is the location a liquid source block */
|
public static FluidStack getStack(FluidStack stack, int amount)
|
||||||
public static boolean isSourceBlock(World world, Vector3 vec)
|
|
||||||
{
|
{
|
||||||
LiquidStack liquid = FluidHelper.getLiquidFromBlockId(vec.getBlockID(world));
|
if(stack != null)
|
||||||
if ((liquid != null && vec.getBlockMetadata(world) == 0))
|
|
||||||
{
|
{
|
||||||
return true;
|
return new FluidStack(stack.getFluid(), amount);
|
||||||
}
|
}
|
||||||
return false;
|
return stack;
|
||||||
}
|
|
||||||
|
|
||||||
/** Gets the number of source liquids blocks around the locaiton */
|
|
||||||
public static int getConnectedSources(World world, Vector3 vec)
|
|
||||||
{
|
|
||||||
int sources = 0;
|
|
||||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
|
||||||
{
|
|
||||||
Vector3 pos = vec.clone().modifyPositionFromSide(direction);
|
|
||||||
if (isSourceBlock(world, pos))
|
|
||||||
{
|
|
||||||
sources++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sources;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Gets the number of liquid fillable blocks around the location */
|
|
||||||
public static int getConnectedFillables(World world, Vector3 vec)
|
|
||||||
{
|
|
||||||
int sources = 0;
|
|
||||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
|
||||||
{
|
|
||||||
Vector3 pos = vec.clone().modifyPositionFromSide(direction);
|
|
||||||
LiquidStack liquid = FluidHelper.getLiquidFromBlockId(pos.getBlockID(world));
|
|
||||||
if ((liquid != null || pos.getBlockID(world) == 0) && getConnectedSources(world, pos) > 0)
|
|
||||||
{
|
|
||||||
sources++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sources;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,6 @@ public class FluidRestrictionHandler
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return FluidRestrictionHandler.hasRestrictedStack(color.ordinal()) && FluidRestrictionHandler.getStackForColor(color).isLiquidEqual(stack);
|
return FluidRestrictionHandler.hasRestrictedStack(color.ordinal()) && FluidRestrictionHandler.getStackForColor(color).isEqual(stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,192 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
|
||||||
*
|
|
||||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
|
||||||
* 1.0, or MMPL. Please check the contents of the license located in
|
|
||||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
|
||||||
*/
|
|
||||||
package dark.core.hydraulic.helpers;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.client.renderer.GLAllocation;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.liquids.LiquidDictionary;
|
|
||||||
import net.minecraftforge.liquids.LiquidStack;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import dark.core.hydraulic.helpers.RenderEntityBlock.BlockInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author CovertJaguar <railcraft.wikispaces.com>
|
|
||||||
*/
|
|
||||||
public class LiquidRenderer
|
|
||||||
{
|
|
||||||
|
|
||||||
private static Map<LiquidStack, int[]> flowingRenderCache = new HashMap<LiquidStack, int[]>();
|
|
||||||
private static Map<LiquidStack, int[]> stillRenderCache = new HashMap<LiquidStack, int[]>();
|
|
||||||
public static final int DISPLAY_STAGES = 100;
|
|
||||||
private static final BlockInterface liquidBlock = new BlockInterface();
|
|
||||||
|
|
||||||
public static class LiquidTextureException extends RuntimeException
|
|
||||||
{
|
|
||||||
|
|
||||||
private final LiquidStack liquid;
|
|
||||||
|
|
||||||
public LiquidTextureException(LiquidStack liquid)
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
this.liquid = liquid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage()
|
|
||||||
{
|
|
||||||
String liquidName = LiquidDictionary.findLiquidName(liquid);
|
|
||||||
if (liquidName == null)
|
|
||||||
{
|
|
||||||
liquidName = String.format("ID: %d Meta: %d", liquid.itemID, liquid.itemMeta);
|
|
||||||
}
|
|
||||||
return String.format("Liquid %s has no icon. Please contact the author of the mod the liquid came from.", liquidName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class LiquidCanonException extends RuntimeException
|
|
||||||
{
|
|
||||||
|
|
||||||
private final LiquidStack liquid;
|
|
||||||
|
|
||||||
public LiquidCanonException(LiquidStack liquid)
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
this.liquid = liquid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage()
|
|
||||||
{
|
|
||||||
String liquidName = LiquidDictionary.findLiquidName(liquid);
|
|
||||||
if (liquidName == null)
|
|
||||||
{
|
|
||||||
liquidName = String.format("ID: %d Meta: %d", liquid.itemID, liquid.itemMeta);
|
|
||||||
}
|
|
||||||
return String.format("Liquid %s is not registered with the Liquid Dictionary. Please contact the author of the mod the liquid came from.", liquidName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Icon getLiquidTexture(LiquidStack liquid)
|
|
||||||
{
|
|
||||||
if (liquid == null || liquid.itemID <= 0)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
LiquidStack canon = liquid.canonical();
|
|
||||||
if (canon == null)
|
|
||||||
{
|
|
||||||
throw new LiquidCanonException(liquid);
|
|
||||||
}
|
|
||||||
Icon icon = canon.getRenderingIcon();
|
|
||||||
if (icon == null)
|
|
||||||
{
|
|
||||||
throw new LiquidTextureException(liquid);
|
|
||||||
}
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getLiquidSheet(LiquidStack liquid)
|
|
||||||
{
|
|
||||||
if (liquid == null || liquid.itemID <= 0)
|
|
||||||
{
|
|
||||||
return "/terrain.png";
|
|
||||||
}
|
|
||||||
LiquidStack canon = liquid.canonical();
|
|
||||||
if (canon == null)
|
|
||||||
{
|
|
||||||
throw new LiquidCanonException(liquid);
|
|
||||||
}
|
|
||||||
return canon.getTextureSheet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int[] getLiquidDisplayLists(LiquidStack liquid, World world, boolean flowing)
|
|
||||||
{
|
|
||||||
if (liquid == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
liquid = liquid.canonical();
|
|
||||||
if (liquid == null)
|
|
||||||
{
|
|
||||||
throw new LiquidCanonException(liquid);
|
|
||||||
}
|
|
||||||
Map<LiquidStack, int[]> cache = flowing ? flowingRenderCache : stillRenderCache;
|
|
||||||
int[] diplayLists = cache.get(liquid);
|
|
||||||
if (diplayLists != null)
|
|
||||||
{
|
|
||||||
return diplayLists;
|
|
||||||
}
|
|
||||||
|
|
||||||
diplayLists = new int[DISPLAY_STAGES];
|
|
||||||
|
|
||||||
if (liquid.itemID < Block.blocksList.length && Block.blocksList[liquid.itemID] != null)
|
|
||||||
{
|
|
||||||
liquidBlock.baseBlock = Block.blocksList[liquid.itemID];
|
|
||||||
if (!flowing)
|
|
||||||
{
|
|
||||||
liquidBlock.texture = getLiquidTexture(liquid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Item.itemsList[liquid.itemID] != null)
|
|
||||||
{
|
|
||||||
liquidBlock.baseBlock = Block.waterStill;
|
|
||||||
liquidBlock.texture = getLiquidTexture(liquid);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
cache.put(liquid, diplayLists);
|
|
||||||
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glDisable(GL11.GL_BLEND);
|
|
||||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
|
||||||
ItemStack stack = liquid.asItemStack();
|
|
||||||
int color = stack.getItem().getColorFromItemStack(stack, 0);
|
|
||||||
float c1 = (float) (color >> 16 & 255) / 255.0F;
|
|
||||||
float c2 = (float) (color >> 8 & 255) / 255.0F;
|
|
||||||
float c3 = (float) (color & 255) / 255.0F;
|
|
||||||
GL11.glColor4f(c1, c2, c3, 1);
|
|
||||||
for (int s = 0; s < DISPLAY_STAGES; ++s)
|
|
||||||
{
|
|
||||||
diplayLists[s] = GLAllocation.generateDisplayLists(1);
|
|
||||||
GL11.glNewList(diplayLists[s], 4864 /* GL_COMPILE */);
|
|
||||||
|
|
||||||
liquidBlock.minX = 0.01f;
|
|
||||||
liquidBlock.minY = 0;
|
|
||||||
liquidBlock.minZ = 0.01f;
|
|
||||||
|
|
||||||
liquidBlock.maxX = 0.99f;
|
|
||||||
liquidBlock.maxY = (float) s / (float) DISPLAY_STAGES;
|
|
||||||
liquidBlock.maxZ = 0.99f;
|
|
||||||
|
|
||||||
RenderEntityBlock.renderBlock(liquidBlock, world, 0, 0, 0, false, true);
|
|
||||||
|
|
||||||
GL11.glEndList();
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glColor4f(1, 1, 1, 1);
|
|
||||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
|
|
||||||
return diplayLists;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,229 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (c) SpaceToad, 2011
|
|
||||||
* http://www.mod-buildcraft.com
|
|
||||||
*
|
|
||||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
|
||||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
|
||||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
|
||||||
*/
|
|
||||||
|
|
||||||
package dark.core.hydraulic.helpers;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
|
||||||
import net.minecraft.client.renderer.entity.Render;
|
|
||||||
import net.minecraft.client.resources.ResourceLocation;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
public class RenderEntityBlock extends Render
|
|
||||||
{
|
|
||||||
|
|
||||||
private static RenderBlocks renderBlocks = new RenderBlocks();
|
|
||||||
|
|
||||||
public static class BlockInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
public double minX;
|
|
||||||
public double minY;
|
|
||||||
public double minZ;
|
|
||||||
public double maxX;
|
|
||||||
public double maxY;
|
|
||||||
public double maxZ;
|
|
||||||
|
|
||||||
public Block baseBlock = Block.sand;
|
|
||||||
|
|
||||||
public Icon texture = null;
|
|
||||||
|
|
||||||
public Icon getBlockTextureFromSide(int i)
|
|
||||||
{
|
|
||||||
if (texture == null)
|
|
||||||
return baseBlock.getBlockTextureFromSide(i);
|
|
||||||
else
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getBlockBrightness(IBlockAccess iblockaccess, int i, int j, int k)
|
|
||||||
{
|
|
||||||
return baseBlock.getBlockBrightness(iblockaccess, i, j, k);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public RenderEntityBlock()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doRender(Entity entity, double i, double j, double k, float f, float f1)
|
|
||||||
{
|
|
||||||
doRenderBlock((EntityBlock) entity, i, j, k);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doRenderBlock(EntityBlock entity, double i, double j, double k)
|
|
||||||
{
|
|
||||||
if (entity.isDead)
|
|
||||||
return;
|
|
||||||
|
|
||||||
shadowSize = entity.shadowSize;
|
|
||||||
World world = entity.worldObj;
|
|
||||||
BlockInterface util = new BlockInterface();
|
|
||||||
util.texture = entity.texture;
|
|
||||||
ResourceLocation name = new ResourceLocation("minecraft:terrain.png");
|
|
||||||
func_110776_a(name);
|
|
||||||
|
|
||||||
for (int iBase = 0; iBase < entity.iSize; ++iBase)
|
|
||||||
{
|
|
||||||
for (int jBase = 0; jBase < entity.jSize; ++jBase)
|
|
||||||
{
|
|
||||||
for (int kBase = 0; kBase < entity.kSize; ++kBase)
|
|
||||||
{
|
|
||||||
|
|
||||||
util.minX = 0;
|
|
||||||
util.minY = 0;
|
|
||||||
util.minZ = 0;
|
|
||||||
|
|
||||||
double remainX = entity.iSize - iBase;
|
|
||||||
double remainY = entity.jSize - jBase;
|
|
||||||
double remainZ = entity.kSize - kBase;
|
|
||||||
|
|
||||||
util.maxX = (remainX > 1.0 ? 1.0 : remainX);
|
|
||||||
util.maxY = (remainY > 1.0 ? 1.0 : remainY);
|
|
||||||
util.maxZ = (remainZ > 1.0 ? 1.0 : remainZ);
|
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glTranslatef((float) i, (float) j, (float) k);
|
|
||||||
GL11.glRotatef(entity.rotationX, 1, 0, 0);
|
|
||||||
GL11.glRotatef(entity.rotationY, 0, 1, 0);
|
|
||||||
GL11.glRotatef(entity.rotationZ, 0, 0, 1);
|
|
||||||
GL11.glTranslatef(iBase, jBase, kBase);
|
|
||||||
|
|
||||||
int lightX, lightY, lightZ;
|
|
||||||
|
|
||||||
lightX = (int) (Math.floor(entity.posX) + iBase);
|
|
||||||
lightY = (int) (Math.floor(entity.posY) + jBase);
|
|
||||||
lightZ = (int) (Math.floor(entity.posZ) + kBase);
|
|
||||||
|
|
||||||
GL11.glDisable(2896 /* GL_LIGHTING */);
|
|
||||||
renderBlock(util, world, lightX, lightY, lightZ, false, true);
|
|
||||||
GL11.glEnable(2896 /* GL_LIGHTING */);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void renderBlock(BlockInterface block, IBlockAccess blockAccess, int i, int j, int k, boolean doLight, boolean doTessellating)
|
|
||||||
{
|
|
||||||
float f = 0.5F;
|
|
||||||
float f1 = 1.0F;
|
|
||||||
float f2 = 0.8F;
|
|
||||||
float f3 = 0.6F;
|
|
||||||
|
|
||||||
renderBlocks.renderMaxX = block.maxX;
|
|
||||||
renderBlocks.renderMinX = block.minX;
|
|
||||||
renderBlocks.renderMaxY = block.maxY;
|
|
||||||
renderBlocks.renderMinY = block.minY;
|
|
||||||
renderBlocks.renderMaxZ = block.maxZ;
|
|
||||||
renderBlocks.renderMinZ = block.minZ;
|
|
||||||
renderBlocks.enableAO = false;
|
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.instance;
|
|
||||||
|
|
||||||
if (doTessellating)
|
|
||||||
{
|
|
||||||
tessellator.startDrawingQuads();
|
|
||||||
}
|
|
||||||
|
|
||||||
float f4 = 0, f5 = 0;
|
|
||||||
|
|
||||||
if (doLight)
|
|
||||||
{
|
|
||||||
f4 = block.getBlockBrightness(blockAccess, i, j, k);
|
|
||||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
|
||||||
if (f5 < f4)
|
|
||||||
{
|
|
||||||
f5 = f4;
|
|
||||||
}
|
|
||||||
tessellator.setColorOpaque_F(f * f5, f * f5, f * f5);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderBlocks.renderFaceYNeg(null, 0, 0, 0, block.getBlockTextureFromSide(0));
|
|
||||||
|
|
||||||
if (doLight)
|
|
||||||
{
|
|
||||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
|
||||||
if (f5 < f4)
|
|
||||||
{
|
|
||||||
f5 = f4;
|
|
||||||
}
|
|
||||||
tessellator.setColorOpaque_F(f1 * f5, f1 * f5, f1 * f5);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderBlocks.renderFaceYPos(null, 0, 0, 0, block.getBlockTextureFromSide(1));
|
|
||||||
|
|
||||||
if (doLight)
|
|
||||||
{
|
|
||||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
|
||||||
if (f5 < f4)
|
|
||||||
{
|
|
||||||
f5 = f4;
|
|
||||||
}
|
|
||||||
tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderBlocks.renderFaceZNeg(null, 0, 0, 0, block.getBlockTextureFromSide(2));
|
|
||||||
|
|
||||||
if (doLight)
|
|
||||||
{
|
|
||||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
|
||||||
if (f5 < f4)
|
|
||||||
{
|
|
||||||
f5 = f4;
|
|
||||||
}
|
|
||||||
tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderBlocks.renderFaceZPos(null, 0, 0, 0, block.getBlockTextureFromSide(3));
|
|
||||||
|
|
||||||
if (doLight)
|
|
||||||
{
|
|
||||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
|
||||||
if (f5 < f4)
|
|
||||||
{
|
|
||||||
f5 = f4;
|
|
||||||
}
|
|
||||||
tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderBlocks.renderFaceXNeg(null, 0, 0, 0, block.getBlockTextureFromSide(4));
|
|
||||||
|
|
||||||
if (doLight)
|
|
||||||
{
|
|
||||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
|
||||||
if (f5 < f4)
|
|
||||||
{
|
|
||||||
f5 = f4;
|
|
||||||
}
|
|
||||||
tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderBlocks.renderFaceXPos(null, 0, 0, 0, block.getBlockTextureFromSide(5));
|
|
||||||
|
|
||||||
if (doTessellating)
|
|
||||||
{
|
|
||||||
tessellator.draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ResourceLocation func_110775_a(Entity entity)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,7 +8,7 @@ import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import universalelectricity.prefab.flag.NBTFileLoader;
|
import dark.library.saving.NBTFileLoader;
|
||||||
|
|
||||||
public class GlobalAccessManager
|
public class GlobalAccessManager
|
||||||
{
|
{
|
||||||
|
@ -24,13 +24,11 @@ public class GlobalAccessManager
|
||||||
/** Used to check to see if file was changed and needs saved **/
|
/** Used to check to see if file was changed and needs saved **/
|
||||||
public static boolean needsSaving = false;
|
public static boolean needsSaving = false;
|
||||||
|
|
||||||
/**
|
/** Gets or creates a userAccess list to be used for any reason
|
||||||
* Gets or creates a userAccess list to be used for any reason
|
|
||||||
*
|
*
|
||||||
* @param name - name of the access list being created or loaded
|
* @param name - name of the access list being created or loaded
|
||||||
* @param owner - the player's name to be used to create a new list
|
* @param owner - the player's name to be used to create a new list
|
||||||
* @return - UserAccess list
|
* @return - UserAccess list */
|
||||||
*/
|
|
||||||
public static List<UserAccess> getOrCreateList(String name, String owner)
|
public static List<UserAccess> getOrCreateList(String name, String owner)
|
||||||
{
|
{
|
||||||
if (name.toCharArray().length < 5 || owner.isEmpty() || name.startsWith("Default#"))
|
if (name.toCharArray().length < 5 || owner.isEmpty() || name.startsWith("Default#"))
|
||||||
|
@ -45,9 +43,7 @@ public class GlobalAccessManager
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** gets all the access list by name the user can edit */
|
||||||
* gets all the access list by name the user can edit
|
|
||||||
*/
|
|
||||||
public static List<String> getUsersLists(String username)
|
public static List<String> getUsersLists(String username)
|
||||||
{
|
{
|
||||||
List<String> lists = new ArrayList<String>();
|
List<String> lists = new ArrayList<String>();
|
||||||
|
@ -70,13 +66,11 @@ public class GlobalAccessManager
|
||||||
return lists;
|
return lists;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** creates a new user access list
|
||||||
* creates a new user access list
|
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @param owner
|
* @param owner
|
||||||
* @return
|
* @return */
|
||||||
*/
|
|
||||||
public static List<UserAccess> createList(String name, String owner)
|
public static List<UserAccess> createList(String name, String owner)
|
||||||
{
|
{
|
||||||
/*** Creates a new List if one doesn't exist ***/
|
/*** Creates a new List if one doesn't exist ***/
|
||||||
|
@ -89,12 +83,10 @@ public class GlobalAccessManager
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Loads up a UserAccess List
|
||||||
* Loads up a UserAccess List
|
|
||||||
*
|
*
|
||||||
* @param name - name of the list
|
* @param name - name of the list
|
||||||
* @return - the list
|
* @return - the list */
|
||||||
*/
|
|
||||||
public static List<UserAccess> getList(String name)
|
public static List<UserAccess> getList(String name)
|
||||||
{
|
{
|
||||||
if (globalUserLists.containsKey(name))
|
if (globalUserLists.containsKey(name))
|
||||||
|
@ -114,13 +106,11 @@ public class GlobalAccessManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** adds a user to the global list
|
||||||
* adds a user to the global list
|
|
||||||
*
|
*
|
||||||
* @param listName - name of the list
|
* @param listName - name of the list
|
||||||
* @param user - user being added as a UserAccess instance
|
* @param user - user being added as a UserAccess instance
|
||||||
* @return true if added
|
* @return true if added */
|
||||||
*/
|
|
||||||
public boolean addUser(String listName, UserAccess user)
|
public boolean addUser(String listName, UserAccess user)
|
||||||
{
|
{
|
||||||
if (user == null)
|
if (user == null)
|
||||||
|
@ -147,13 +137,11 @@ public class GlobalAccessManager
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Removes a user from the global list
|
||||||
* Removes a user from the global list
|
|
||||||
*
|
*
|
||||||
* @param listName - name of the list
|
* @param listName - name of the list
|
||||||
* @param user - user being removed
|
* @param user - user being removed
|
||||||
* @return true if removed
|
* @return true if removed */
|
||||||
*/
|
|
||||||
public boolean removeUser(String listName, UserAccess user)
|
public boolean removeUser(String listName, UserAccess user)
|
||||||
{
|
{
|
||||||
if (user == null)
|
if (user == null)
|
||||||
|
@ -177,12 +165,10 @@ public class GlobalAccessManager
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Loads a given Global user list from the master save
|
||||||
* Loads a given Global user list from the master save
|
|
||||||
*
|
*
|
||||||
* @param name - name given to the list for reference
|
* @param name - name given to the list for reference
|
||||||
* @return - the list of user access levels to be used
|
* @return - the list of user access levels to be used */
|
||||||
*/
|
|
||||||
private static List<UserAccess> loadList(String name)
|
private static List<UserAccess> loadList(String name)
|
||||||
{
|
{
|
||||||
NBTTagCompound masterSave = getMasterSaveFile();
|
NBTTagCompound masterSave = getMasterSaveFile();
|
||||||
|
@ -194,12 +180,10 @@ public class GlobalAccessManager
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Saves a given Global user list into the master save
|
||||||
* Saves a given Global user list into the master save
|
|
||||||
*
|
*
|
||||||
* @param name - name to save the list as
|
* @param name - name to save the list as
|
||||||
* @param list - list to be saved
|
* @param list - list to be saved */
|
||||||
*/
|
|
||||||
private static void saveList(String name, List<UserAccess> list)
|
private static void saveList(String name, List<UserAccess> list)
|
||||||
{
|
{
|
||||||
NBTTagCompound masterSave = getMasterSaveFile();
|
NBTTagCompound masterSave = getMasterSaveFile();
|
||||||
|
@ -211,9 +195,7 @@ public class GlobalAccessManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Loads the master save from the world folder */
|
||||||
* Loads the master save from the world folder
|
|
||||||
*/
|
|
||||||
public static NBTTagCompound getMasterSaveFile()
|
public static NBTTagCompound getMasterSaveFile()
|
||||||
{
|
{
|
||||||
if (masterSaveNbt.hasNoTags())
|
if (masterSaveNbt.hasNoTags())
|
||||||
|
|
|
@ -2,14 +2,20 @@ package dark.library.gui;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.resources.ResourceLocation;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import dark.core.DarkMain;
|
import dark.core.DarkMain;
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
public class GuiButtonArrow extends GuiButton
|
public class GuiButtonArrow extends GuiButton
|
||||||
{
|
{
|
||||||
boolean isLeft = false;
|
boolean isLeft = false;
|
||||||
|
private static final ResourceLocation gui_pic = new ResourceLocation(DarkMain.GUI_DIRECTORY + "gui@.png");
|
||||||
|
|
||||||
public GuiButtonArrow(int par1, int par2, int par3, boolean left)
|
public GuiButtonArrow(int par1, int par2, int par3, boolean left)
|
||||||
{
|
{
|
||||||
|
@ -17,14 +23,12 @@ public class GuiButtonArrow extends GuiButton
|
||||||
isLeft = left;
|
isLeft = left;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Draws this button to the screen. */
|
||||||
* Draws this button to the screen.
|
|
||||||
*/
|
|
||||||
public void drawButton(Minecraft par1Minecraft, int width, int hight)
|
public void drawButton(Minecraft par1Minecraft, int width, int hight)
|
||||||
{
|
{
|
||||||
if (this.drawButton)
|
if (this.drawButton)
|
||||||
{
|
{
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, par1Minecraft.renderEngine.getTexture(DarkMain.GUI_DIRECTORY+"gui@.png"));
|
par1Minecraft.func_110434_K().func_110577_a(gui_pic);
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
boolean var4 = width >= this.xPosition && hight >= this.yPosition && width < this.xPosition + this.width && hight < this.yPosition + this.height;
|
boolean var4 = width >= this.xPosition && hight >= this.yPosition && width < this.xPosition + this.width && hight < this.yPosition + this.height;
|
||||||
int var5 = 106;
|
int var5 = 106;
|
||||||
|
|
|
@ -7,22 +7,24 @@ import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.client.gui.GuiTextField;
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
import net.minecraft.client.resources.ResourceLocation;
|
import net.minecraft.client.resources.ResourceLocation;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.StringTranslate;
|
|
||||||
|
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import universalelectricity.core.vector.Vector2;
|
import universalelectricity.core.vector.Vector2;
|
||||||
import universalelectricity.prefab.GuiBase;
|
|
||||||
import universalelectricity.prefab.vector.Region2;
|
import universalelectricity.prefab.vector.Region2;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import dark.core.DarkMain;
|
import dark.core.DarkMain;
|
||||||
import dark.core.api.IScroll;
|
import dark.core.api.IScroll;
|
||||||
import dark.library.access.UserAccess;
|
import dark.library.access.UserAccess;
|
||||||
|
|
||||||
public class GuiGlobalList extends GuiBase implements IScroll
|
@SideOnly(Side.CLIENT)
|
||||||
|
public class GuiGlobalList extends GuiScreen implements IScroll
|
||||||
{
|
{
|
||||||
EntityPlayer player;
|
EntityPlayer player;
|
||||||
private GuiTextField stringInput;
|
private GuiTextField stringInput;
|
||||||
|
@ -50,8 +52,8 @@ public class GuiGlobalList extends GuiBase implements IScroll
|
||||||
public void initGui()
|
public void initGui()
|
||||||
{
|
{
|
||||||
super.initGui();
|
super.initGui();
|
||||||
int width = (this.width - this.xSize) / 2;
|
int width = (this.width - this.width) / 2;
|
||||||
int height = (this.height - this.ySize) / 2;
|
int height = (this.height - this.height) / 2;
|
||||||
|
|
||||||
this.stringInput = new GuiTextField(this.fontRenderer, width + 12, height + 165, 135, 11);
|
this.stringInput = new GuiTextField(this.fontRenderer, width + 12, height + 165, 135, 11);
|
||||||
this.stringInput.setMaxStringLength(30);
|
this.stringInput.setMaxStringLength(30);
|
||||||
|
@ -130,7 +132,7 @@ public class GuiGlobalList extends GuiBase implements IScroll
|
||||||
@Override
|
@Override
|
||||||
protected void drawBackgroundLayer(int x, int y, float var1)
|
protected void drawBackgroundLayer(int x, int y, float var1)
|
||||||
{
|
{
|
||||||
ResourceLocation name = new ResourceLocation(DarkMain.GUI_DIRECTORY + ":gui_access_base.png");
|
ResourceLocation name = new ResourceLocation(DarkMain.GUI_DIRECTORY + ":gui_access_base.png");
|
||||||
this.mc.renderEngine.func_110577_a(name);
|
this.mc.renderEngine.func_110577_a(name);
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
||||||
|
|
48
src/minecraft/dark/library/machine/BlockMachine.java
Normal file
48
src/minecraft/dark/library/machine/BlockMachine.java
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
package dark.library.machine;
|
||||||
|
|
||||||
|
import net.minecraft.block.ITileEntityProvider;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import universalelectricity.prefab.block.BlockAdvanced;
|
||||||
|
|
||||||
|
public class BlockMachine extends BlockAdvanced implements ITileEntityProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
protected BlockMachine(int par1, Material par2Material)
|
||||||
|
{
|
||||||
|
super(par1, par2Material);
|
||||||
|
this.isBlockContainer = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called whenever the block is added into the world. Args: world, x, y, z */
|
||||||
|
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||||
|
{
|
||||||
|
super.onBlockAdded(par1World, par2, par3, par4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ejects contained items into the world, and notifies neighbours of an update, as appropriate */
|
||||||
|
public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||||
|
{
|
||||||
|
super.breakBlock(par1World, par2, par3, par4, par5, par6);
|
||||||
|
par1World.removeBlockTileEntity(par2, par3, par4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called when the block receives a BlockEvent - see World.addBlockEvent. By default, passes it
|
||||||
|
* on to the tile entity at this location. Args: world, x, y, z, blockID, EventID, event
|
||||||
|
* parameter */
|
||||||
|
public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||||
|
{
|
||||||
|
super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6);
|
||||||
|
TileEntity tileentity = par1World.getBlockTileEntity(par2, par3, par4);
|
||||||
|
return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createNewTileEntity(World world)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -26,16 +26,20 @@ import dark.library.access.AccessLevel;
|
||||||
import dark.library.access.UserAccess;
|
import dark.library.access.UserAccess;
|
||||||
import dark.library.machine.TileEntityRunnableMachine;
|
import dark.library.machine.TileEntityRunnableMachine;
|
||||||
|
|
||||||
/**
|
/** @author Calclavia, DarkGuardsman */
|
||||||
*
|
|
||||||
* @author Calclavia, DarkGuardsman
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public abstract class TileEntityTerminal extends TileEntityRunnableMachine implements ISpecialAccess, IPacketReceiver, ITerminal
|
public abstract class TileEntityTerminal extends TileEntityRunnableMachine implements ISpecialAccess, IPacketReceiver, ITerminal
|
||||||
{
|
{
|
||||||
|
public TileEntityTerminal(int tickEnergy)
|
||||||
|
{
|
||||||
|
super(tickEnergy);
|
||||||
|
}
|
||||||
|
|
||||||
public enum PacketType
|
public enum PacketType
|
||||||
{
|
{
|
||||||
GUI_EVENT, GUI_COMMAND, TERMINAL_OUTPUT, DESCRIPTION_DATA;
|
GUI_EVENT,
|
||||||
|
GUI_COMMAND,
|
||||||
|
TERMINAL_OUTPUT,
|
||||||
|
DESCRIPTION_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A list of everything typed inside the terminal */
|
/** A list of everything typed inside the terminal */
|
||||||
|
|
109
src/minecraft/dark/library/saving/NBTFileLoader.java
Normal file
109
src/minecraft/dark/library/saving/NBTFileLoader.java
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
package dark.library.saving;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.nbt.CompressedStreamTools;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import cpw.mods.fml.common.FMLLog;
|
||||||
|
|
||||||
|
public class NBTFileLoader
|
||||||
|
{
|
||||||
|
/** Saves NBT data in the world folder.
|
||||||
|
*
|
||||||
|
* @return True on success. */
|
||||||
|
public static boolean saveData(File saveDirectory, String filename, NBTTagCompound data)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File tempFile = new File(saveDirectory, filename + "_tmp.dat");
|
||||||
|
File file = new File(saveDirectory, filename + ".dat");
|
||||||
|
|
||||||
|
CompressedStreamTools.writeCompressed(data, new FileOutputStream(tempFile));
|
||||||
|
|
||||||
|
if (file.exists())
|
||||||
|
{
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
tempFile.renameTo(file);
|
||||||
|
|
||||||
|
FMLLog.fine("Saved " + filename + " NBT data file successfully.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Failed to save " + filename + ".dat!");
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean saveData(String filename, NBTTagCompound data)
|
||||||
|
{
|
||||||
|
return saveData(getSaveDirectory(MinecraftServer.getServer().getFolderName()), filename, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reads NBT data from the world folder.
|
||||||
|
*
|
||||||
|
* @return The NBT data */
|
||||||
|
public static NBTTagCompound loadData(File saveDirectory, String filename)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File file = new File(saveDirectory, filename + ".dat");
|
||||||
|
|
||||||
|
if (file.exists())
|
||||||
|
{
|
||||||
|
FMLLog.fine("Loaded " + filename + " data.");
|
||||||
|
return CompressedStreamTools.readCompressed(new FileInputStream(file));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FMLLog.fine("Created new " + filename + " data.");
|
||||||
|
return new NBTTagCompound();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Failed to load " + filename + ".dat!");
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NBTTagCompound loadData(String filename)
|
||||||
|
{
|
||||||
|
return loadData(getSaveDirectory(MinecraftServer.getServer().getFolderName()), filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static File getSaveDirectory(String worldName)
|
||||||
|
{
|
||||||
|
File parent = getBaseDirectory();
|
||||||
|
|
||||||
|
if (FMLCommonHandler.instance().getSide().isClient())
|
||||||
|
{
|
||||||
|
parent = new File(getBaseDirectory(), "saves" + File.separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new File(parent, worldName + File.separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static File getBaseDirectory()
|
||||||
|
{
|
||||||
|
if (FMLCommonHandler.instance().getSide().isClient())
|
||||||
|
{
|
||||||
|
FMLClientHandler.instance().getClient();
|
||||||
|
return Minecraft.getMinecraft().mcDataDir;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new File(".");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,6 @@ import java.util.List;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.ForgeSubscribe;
|
import net.minecraftforge.event.ForgeSubscribe;
|
||||||
import net.minecraftforge.event.world.WorldEvent;
|
import net.minecraftforge.event.world.WorldEvent;
|
||||||
import universalelectricity.prefab.flag.NBTFileLoader;
|
|
||||||
import cpw.mods.fml.common.Mod.ServerStopping;
|
import cpw.mods.fml.common.Mod.ServerStopping;
|
||||||
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
|
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
|
||||||
|
|
||||||
|
@ -18,11 +17,9 @@ public class SaveManager
|
||||||
|
|
||||||
public static SaveManager intance = new SaveManager();
|
public static SaveManager intance = new SaveManager();
|
||||||
|
|
||||||
/**
|
/** registers a class that uses INbtSave to save data to a file in the worldSave file
|
||||||
* registers a class that uses INbtSave to save data to a file in the worldSave file
|
|
||||||
*
|
*
|
||||||
* @param saveClass
|
* @param saveClass */
|
||||||
*/
|
|
||||||
public void registerNbtSave(INbtSave saveClass)
|
public void registerNbtSave(INbtSave saveClass)
|
||||||
{
|
{
|
||||||
if (!isInitialized)
|
if (!isInitialized)
|
||||||
|
|
Loading…
Reference in a new issue