AL 0.1.7 Release
This commit is contained in:
parent
1781a35ae4
commit
f73da078df
26 changed files with 819 additions and 21 deletions
|
@ -1 +1 @@
|
|||
24
|
||||
25
|
||||
|
|
1
info.txt
1
info.txt
|
@ -19,3 +19,4 @@ Minecraft 1.4.2
|
|||
x AssemblyLine_v0.1.6.22.jar AssemblyLine_v0.1.6.22_api.zip
|
||||
x AssemblyLine_v0.1.6.23.jar AssemblyLine_v0.1.6.23_api.zip
|
||||
* AssemblyLine_v0.1.6.24.jar AssemblyLine_v0.1.6.24_api.zip
|
||||
* AssemblyLine_v0.1.7.25.jar AssemblyLine_v0.1.7.25_api.zip
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.1.6
|
||||
0.1.7
|
|
@ -1 +1 @@
|
|||
0.1.6
|
||||
0.1.7
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{
|
||||
"modid" : "AssemblyLine",
|
||||
"name" : "Assembly Line",
|
||||
"version" : "0.1.6",
|
||||
"version" : "0.1.7",
|
||||
"url" : "http://calclavia.com/universalelectricity/?m=18",
|
||||
"credits" : "",
|
||||
"authors": [
|
||||
|
|
|
@ -44,7 +44,7 @@ public class AssemblyLine
|
|||
|
||||
public static final String NAME = "Assembly Line";
|
||||
|
||||
public static final String VERSION = "0.1.6";
|
||||
public static final String VERSION = "0.1.7";
|
||||
|
||||
public static final String CHANNEL = "AssemblyLine";
|
||||
|
||||
|
@ -133,13 +133,16 @@ public class AssemblyLine
|
|||
LanguageRegistry.addName(new ItemStack(blockMulti, 1, type.metadata), type.name);
|
||||
}
|
||||
|
||||
// Crate
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockCrate, new Object[] { "SPS", "P P", "SPS", 'P', "plateSteel", 'S', Item.stick }));
|
||||
|
||||
// Conveyor Belt
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConveyorBelt, 4), new Object[] { "III", "WMW", 'I', "ingotSteel", 'W', Block.wood, 'M', "motor" }));
|
||||
|
||||
// Rejector
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockMulti, 1, MachineType.SORTER.metadata), new Object[] { "WPW", "@R@", '@', "plateSteel", 'R', Item.redstone, 'P', Block.pistonBase, 'C', "basicCircuit", 'W', "copperWire" }));
|
||||
|
||||
// Retriever
|
||||
// Manipulator
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(blockMulti, 1, MachineType.MANIPULATOR.metadata), new Object[] { Block.dispenser, "basicCircuit" }));
|
||||
|
||||
UETab.setItemStack(new ItemStack(blockConveyorBelt));
|
||||
|
|
|
@ -283,8 +283,8 @@ public class TileEntityManipulator extends TileEntityElectricityReceiver impleme
|
|||
else if (stackInInventory.isItemEqual(itemStack))
|
||||
{
|
||||
stackInInventory = stackInInventory.copy();
|
||||
int rejectedAmount = Math.max((stackInInventory.stackSize + itemStack.stackSize) - stackInInventory.getItem().getItemStackLimit(), 0);
|
||||
stackInInventory.stackSize = Math.min(Math.max((stackInInventory.stackSize + itemStack.stackSize - rejectedAmount), 0), stackInInventory.getItem().getItemStackLimit());
|
||||
int rejectedAmount = Math.max((stackInInventory.stackSize + itemStack.stackSize) - inventory.getInventoryStackLimit(), 0);
|
||||
stackInInventory.stackSize = Math.min(Math.max((stackInInventory.stackSize + itemStack.stackSize - rejectedAmount), 0), inventory.getInventoryStackLimit());
|
||||
itemStack.stackSize = rejectedAmount;
|
||||
inventory.setInventorySlotContents(slotIndex, stackInInventory);
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package assemblyline.common.machine.belt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
@ -134,13 +137,13 @@ public class BlockConveyorBelt extends BlockMachine
|
|||
if (direction.offsetX != 0)
|
||||
{
|
||||
double difference = (z + 0.5) - entity.posZ;
|
||||
entity.motionZ += difference * 0.01;
|
||||
entity.motionZ += difference * 0.015;
|
||||
// entity.posZ = z + 0.5;
|
||||
}
|
||||
else if (direction.offsetZ != 0)
|
||||
{
|
||||
double difference = (x + 0.5) - entity.posX;
|
||||
entity.motionX += difference * 0.01;
|
||||
entity.motionX += difference * 0.015;
|
||||
// entity.posX = z + 0.5;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
|
|||
public double wattsReceived = 0;
|
||||
|
||||
public float acceleration = 0.01f;
|
||||
public float maxSpeed = 0.2f;
|
||||
public float maxSpeed = 0.3f;
|
||||
|
||||
public float wheelRotation = 0;
|
||||
public boolean running = false;
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.implement.IConductor;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
|
@ -359,4 +360,29 @@ public class ElectricityNetwork
|
|||
conductor.refreshConnectedBlocks();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to find the electricity network based in a tile entity and checks to see if it is a
|
||||
* conductor. All machines should use this function to search for a connecting conductor around
|
||||
* it.
|
||||
*
|
||||
* @param conductor - The TileEntity conductor
|
||||
* @param approachDirection - The direction you are approaching this wire from.
|
||||
* @return The ElectricityNetwork or null if not found.
|
||||
*/
|
||||
public static ElectricityNetwork getNetworkFromTileEntity(TileEntity tileEntity, ForgeDirection approachDirection)
|
||||
{
|
||||
if (tileEntity != null)
|
||||
{
|
||||
if (tileEntity instanceof IConductor)
|
||||
{
|
||||
if (ElectricityConnections.isConnector(tileEntity))
|
||||
{
|
||||
if (ElectricityConnections.canConnect(tileEntity, approachDirection.getOpposite())) { return ((IConductor) tileEntity).getNetwork(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,11 +42,11 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
|||
String color = "";
|
||||
double joules = this.getJoules(par1ItemStack);
|
||||
|
||||
if (joules <= this.getMaxJoules() / 3)
|
||||
if (joules <= this.getMaxJoules(par1ItemStack) / 3)
|
||||
{
|
||||
color = "\u00a74";
|
||||
}
|
||||
else if (joules > this.getMaxJoules() * 2 / 3)
|
||||
else if (joules > this.getMaxJoules(par1ItemStack) * 2 / 3)
|
||||
{
|
||||
color = "\u00a72";
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
|||
color = "\u00a76";
|
||||
}
|
||||
|
||||
par3List.add(color + ElectricInfo.getDisplay(joules, ElectricUnit.JOULES) + " - " + Math.round((joules / this.getMaxJoules()) * 100) + "%");
|
||||
par3List.add(color + ElectricInfo.getDisplay(joules, ElectricUnit.JOULES) + " - " + Math.round((joules / this.getMaxJoules(par1ItemStack)) * 100) + "%");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,6 +68,9 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
|||
// for this electric item!
|
||||
ItemElectric item = ((ItemElectric) par1ItemStack.getItem());
|
||||
item.setJoules(item.getJoules(par1ItemStack), par1ItemStack);
|
||||
|
||||
// For items that can change electricity capacity
|
||||
this.setMaxDamage((int) this.getMaxJoules(par1ItemStack));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,7 +86,7 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
|||
@Override
|
||||
public double onReceive(double amps, double voltage, ItemStack itemStack)
|
||||
{
|
||||
double rejectedElectricity = Math.max((this.getJoules(itemStack) + ElectricInfo.getJoules(amps, voltage, 1)) - this.getMaxJoules(), 0);
|
||||
double rejectedElectricity = Math.max((this.getJoules(itemStack) + ElectricInfo.getJoules(amps, voltage, 1)) - this.getMaxJoules(itemStack), 0);
|
||||
this.setJoules(this.getJoules(itemStack) + ElectricInfo.getJoules(amps, voltage, 1) - rejectedElectricity, itemStack);
|
||||
return rejectedElectricity;
|
||||
}
|
||||
|
@ -126,7 +129,7 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
|||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
double electricityStored = Math.max(Math.min(wattHours, this.getMaxJoules()), 0);
|
||||
double electricityStored = Math.max(Math.min(wattHours, this.getMaxJoules(itemStack)), 0);
|
||||
itemStack.stackTagCompound.setDouble("electricity", electricityStored);
|
||||
itemStack.setItemDamage((int) (getMaxJoules() - electricityStored));
|
||||
}
|
||||
|
@ -154,7 +157,7 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
|||
{
|
||||
electricityStored = itemStack.stackTagCompound.getDouble("electricity");
|
||||
}
|
||||
itemStack.setItemDamage((int) (getMaxJoules() - electricityStored));
|
||||
itemStack.setItemDamage((int) (getMaxJoules(itemStack) - electricityStored));
|
||||
return electricityStored;
|
||||
}
|
||||
|
||||
|
@ -171,7 +174,7 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
|||
public ItemStack getUncharged()
|
||||
{
|
||||
ItemStack chargedItem = new ItemStack(this);
|
||||
chargedItem.setItemDamage((int) this.getMaxJoules());
|
||||
chargedItem.setItemDamage((int) this.getMaxJoules(chargedItem));
|
||||
return chargedItem;
|
||||
}
|
||||
|
||||
|
@ -180,7 +183,7 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
|||
if (itemStack.getItem() instanceof IItemElectric)
|
||||
{
|
||||
ItemStack chargedItem = itemStack.copy();
|
||||
chargedItem.setItemDamage((int) ((IItemElectric) itemStack.getItem()).getMaxJoules());
|
||||
chargedItem.setItemDamage((int) ((IItemElectric) itemStack.getItem()).getMaxJoules(chargedItem));
|
||||
return chargedItem;
|
||||
}
|
||||
|
||||
|
@ -193,12 +196,12 @@ public abstract class ItemElectric extends Item implements IItemElectric
|
|||
// Add an uncharged version of the
|
||||
// electric item
|
||||
ItemStack unchargedItem = new ItemStack(this, 1);
|
||||
unchargedItem.setItemDamage((int) this.getMaxJoules());
|
||||
unchargedItem.setItemDamage((int) this.getMaxJoules(unchargedItem));
|
||||
par3List.add(unchargedItem);
|
||||
// Add an electric item to the creative
|
||||
// list that is fully charged
|
||||
ItemStack chargedItem = new ItemStack(this, 1);
|
||||
this.setJoules(((IItemElectric) chargedItem.getItem()).getMaxJoules(), chargedItem);
|
||||
this.setJoules(((IItemElectric) chargedItem.getItem()).getMaxJoules(chargedItem), chargedItem);
|
||||
par3List.add(chargedItem);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package universalelectricity.prefab.modifier;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* This must be applied to an item that acts as a modifier or an upgrade.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public interface IModifier
|
||||
{
|
||||
/**
|
||||
* @return - The name of the modifier.
|
||||
*/
|
||||
public String getName(ItemStack itemstack);
|
||||
|
||||
/**
|
||||
* @return - How much effect does this modifier have?
|
||||
*/
|
||||
public int getEffectiveness(ItemStack itemstack);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package universalelectricity.prefab.modifier;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* This slot should be used by any container that contains an item that is a modifier. An example of
|
||||
* this would be upgrade slots.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class SlotModifier extends Slot
|
||||
{
|
||||
public SlotModifier(IInventory par2IInventory, int par3, int par4, int par5)
|
||||
{
|
||||
super(par2IInventory, par3, par4, par5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack)
|
||||
{
|
||||
return par1ItemStack.getItem() instanceof IModifier;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package universalelectricity.prefab.multiblock;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
public class BlockMulti extends BlockContainer
|
||||
{
|
||||
public BlockMulti(int id)
|
||||
{
|
||||
super(id, UniversalElectricity.machine);
|
||||
this.setHardness(0.8F);
|
||||
this.setBlockName("MultiBlock");
|
||||
}
|
||||
|
||||
public void makeFakeBlock(World worldObj, Vector3 position, Vector3 mainBlock)
|
||||
{
|
||||
worldObj.setBlockWithNotify(position.intX(), position.intY(), position.intZ(), this.blockID);
|
||||
((TileEntityMulti) worldObj.getBlockTileEntity(position.intX(), position.intY(), position.intZ())).setMainBlock(mainBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World par1World, int x, int y, int z, int par5, int par6)
|
||||
{
|
||||
TileEntityMulti tileEntity = (TileEntityMulti) par1World.getBlockTileEntity(x, y, z);
|
||||
tileEntity.onBlockRemoval();
|
||||
super.breakBlock(par1World, x, y, z, par5, par6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is right clicked by the player. This modified version detects electric
|
||||
* items and wrench actions on your machine block. Do not override this function. Use
|
||||
* machineActivated instead! (It does the same thing)
|
||||
*/
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
TileEntityMulti tileEntity = (TileEntityMulti) par1World.getBlockTileEntity(x, y, z);
|
||||
return tileEntity.onBlockActivated(par1World, x, y, z, par5EntityPlayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quantity of items to drop on block destruction.
|
||||
*/
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1)
|
||||
{
|
||||
return new TileEntityMulti();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World par1World, int x, int y, int z)
|
||||
{
|
||||
TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z);
|
||||
Vector3 mainBlockPosition = ((TileEntityMulti) tileEntity).mainBlockPosition;
|
||||
|
||||
if (mainBlockPosition != null)
|
||||
{
|
||||
int mainBlockID = par1World.getBlockId(mainBlockPosition.intX(), mainBlockPosition.intY(), mainBlockPosition.intZ());
|
||||
|
||||
if (mainBlockID > 0) { return Block.blocksList[mainBlockID].getPickBlock(target, par1World, mainBlockPosition.intX(), mainBlockPosition.intY(), mainBlockPosition.intZ()); }
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package universalelectricity.prefab.multiblock;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
/**
|
||||
* A general interface to be implemented by anything that needs it.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public interface IBlockActivate
|
||||
{
|
||||
/**
|
||||
* Called when activated
|
||||
*/
|
||||
public boolean onActivated(EntityPlayer entityPlayer);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package universalelectricity.prefab.multiblock;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
/**
|
||||
* Interface to be applied to tile entity blocks that occupies more than one block space. Useful for
|
||||
* large machines.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public interface IMultiBlock extends IBlockActivate
|
||||
{
|
||||
/**
|
||||
* Called when this multiblock is created
|
||||
*
|
||||
* @param placedPosition - The position the block was placed at
|
||||
*/
|
||||
public void onCreate(Vector3 placedPosition);
|
||||
|
||||
/**
|
||||
* Called when one of the multiblocks of this block is destroyed
|
||||
*
|
||||
* @param callingBlock - The tile entity who called the onDestroy function
|
||||
*/
|
||||
public void onDestroy(TileEntity callingBlock);
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
package universalelectricity.prefab.multiblock;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
/**
|
||||
* This is a multiblock to be used for blocks that are bigger than one block.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class TileEntityMulti extends TileEntity implements IPacketReceiver
|
||||
{
|
||||
// The the position of the main block
|
||||
public Vector3 mainBlockPosition;
|
||||
|
||||
public void setMainBlock(Vector3 mainBlock)
|
||||
{
|
||||
this.mainBlockPosition = mainBlock;
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
PacketManager.sendPacketToClients(this.getDescriptionPacket());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return PacketManager.getPacket("BasicComponents", this, this.mainBlockPosition.x, this.mainBlockPosition.y, this.mainBlockPosition.z);
|
||||
}
|
||||
|
||||
public void onBlockRemoval()
|
||||
{
|
||||
if (mainBlockPosition != null)
|
||||
{
|
||||
TileEntity tileEntity = this.worldObj.getBlockTileEntity((int) mainBlockPosition.x, (int) mainBlockPosition.y, (int) mainBlockPosition.z);
|
||||
|
||||
if (tileEntity != null && tileEntity instanceof IMultiBlock)
|
||||
{
|
||||
IMultiBlock mainBlock = (IMultiBlock) tileEntity;
|
||||
|
||||
if (mainBlock != null)
|
||||
{
|
||||
mainBlock.onDestroy(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer)
|
||||
{
|
||||
if (mainBlockPosition != null)
|
||||
{
|
||||
TileEntity tileEntity = this.worldObj.getBlockTileEntity((int) mainBlockPosition.x, (int) mainBlockPosition.y, (int) mainBlockPosition.z);
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
if (tileEntity instanceof IMultiBlock) { return ((IMultiBlock) tileEntity).onActivated(par5EntityPlayer); }
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
|
||||
this.mainBlockPosition = Vector3.readFromNBT("mainBlockPosition", par1NBTTagCompound);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
|
||||
this.mainBlockPosition.writeToNBT("mainBlockPosition", par1NBTTagCompound);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if this TileEntity requires update calls.
|
||||
*
|
||||
* @return True if you want updateEntity() to be called, false if not
|
||||
*/
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.mainBlockPosition = new Vector3(dataStream.readDouble(), dataStream.readDouble(), dataStream.readDouble());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package universalelectricity.prefab.ore;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
|
||||
/**
|
||||
* This class is used for storing ore generation data. If you are too lazy to generate your own
|
||||
* ores, you can do {@link #OreGenerator.ORES_TO_GENERATE.add()} to add your ore to the list of ores
|
||||
* to generate.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public abstract class OreGenBase
|
||||
{
|
||||
public String name;
|
||||
|
||||
public String oreDictionaryName;
|
||||
|
||||
public boolean shouldGenerate;
|
||||
|
||||
public int blockIndexTexture;
|
||||
|
||||
public ItemStack oreStack;
|
||||
|
||||
public int oreID;
|
||||
|
||||
public int oreMeta;
|
||||
|
||||
/**
|
||||
* What harvest level does this machine need to be acquired?
|
||||
*/
|
||||
public int harvestLevel;
|
||||
|
||||
/**
|
||||
* The predefined tool classes are "pickaxe", "shovel", "axe". You can add others for custom
|
||||
* tools.
|
||||
*/
|
||||
public String harvestTool;
|
||||
|
||||
/**
|
||||
* @param name - The name of the ore for display
|
||||
* @param textureFile - The 16x16 png texture of your ore to override
|
||||
* @param minGenerateLevel - The highest generation level of your ore
|
||||
* @param maxGenerateLevel - The lowest generation level of your ore
|
||||
* @param amountPerChunk - The amount of ores to generate per chunk
|
||||
* @param amountPerBranch - The amount of ores to generate in a clutter. E.g coal generates with
|
||||
* a lot of other coal next to it. How much do you want?
|
||||
*/
|
||||
public OreGenBase(String name, String oreDiectionaryName, ItemStack stack, String harvestTool, int harvestLevel)
|
||||
{
|
||||
this.name = name;
|
||||
this.shouldGenerate = false;
|
||||
this.harvestTool = harvestTool;
|
||||
this.harvestLevel = harvestLevel;
|
||||
this.oreDictionaryName = oreDiectionaryName;
|
||||
this.oreStack = stack;
|
||||
this.oreID = stack.itemID;
|
||||
this.oreMeta = stack.getItemDamage();
|
||||
|
||||
OreDictionary.registerOre(oreDictionaryName, stack);
|
||||
MinecraftForge.setBlockHarvestLevel(Block.blocksList[stack.itemID], stack.getItemDamage(), harvestTool, harvestLevel);
|
||||
}
|
||||
|
||||
public OreGenBase enable(Configuration config)
|
||||
{
|
||||
this.shouldGenerate = shouldGenerateOre(config, this.name);
|
||||
return this;
|
||||
}
|
||||
|
||||
public OreGenBase enable()
|
||||
{
|
||||
this.enable(UniversalElectricity.CONFIGURATION);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the config file and see if Universal Electricity should generate this ore
|
||||
*/
|
||||
private static boolean shouldGenerateOre(Configuration configuration, String oreName)
|
||||
{
|
||||
configuration.load();
|
||||
boolean shouldGenerate = configuration.get("Ore Generation", "Generate " + oreName, true).getBoolean(true);
|
||||
configuration.save();
|
||||
return shouldGenerate;
|
||||
}
|
||||
|
||||
public abstract void generate(World world, Random random, int varX, int varZ);
|
||||
|
||||
public abstract boolean isOreGeneratedInWorld(World world, IChunkProvider chunkGenerator);
|
||||
}
|
126
src/minecraft/universalelectricity/prefab/ore/OreGenReplace.java
Normal file
126
src/minecraft/universalelectricity/prefab/ore/OreGenReplace.java
Normal file
|
@ -0,0 +1,126 @@
|
|||
package universalelectricity.prefab.ore;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.ChunkProviderEnd;
|
||||
import net.minecraft.world.gen.ChunkProviderGenerate;
|
||||
import net.minecraft.world.gen.ChunkProviderHell;
|
||||
|
||||
/**
|
||||
* This class is used for storing ore generation data. If you are too lazy to generate your own
|
||||
* ores, you can do {@link #OreGenerator.ORES_TO_GENERATE.add()} to add your ore to the list of ores
|
||||
* to generate.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public class OreGenReplace extends OreGenBase
|
||||
{
|
||||
|
||||
public int minGenerateLevel;
|
||||
public int maxGenerateLevel;
|
||||
public int amountPerChunk;
|
||||
public int amountPerBranch;
|
||||
public int replaceID;
|
||||
|
||||
public boolean generateSurface;
|
||||
public boolean generateNether;
|
||||
public boolean generateEnd;
|
||||
|
||||
/**
|
||||
* @param name - The name of the ore for display
|
||||
* @param textureFile - The 16x16 png texture of your ore to override
|
||||
* @param minGenerateLevel - The highest generation level of your ore
|
||||
* @param maxGenerateLevel - The lowest generation level of your ore
|
||||
* @param amountPerChunk - The amount of ores to generate per chunk
|
||||
* @param amountPerBranch - The amount of ores to generate in a clutter. E.g coal generates with
|
||||
* a lot of other coal next to it. How much do you want?
|
||||
*/
|
||||
public OreGenReplace(String name, String oreDiectionaryName, ItemStack stack, int replaceID, int minGenerateLevel, int maxGenerateLevel, int amountPerChunk, int amountPerBranch, String harvestTool, int harvestLevel)
|
||||
{
|
||||
super(name, oreDiectionaryName, stack, harvestTool, harvestLevel);
|
||||
this.minGenerateLevel = minGenerateLevel;
|
||||
this.maxGenerateLevel = maxGenerateLevel;
|
||||
this.amountPerChunk = amountPerChunk;
|
||||
this.amountPerBranch = amountPerBranch;
|
||||
this.replaceID = replaceID;
|
||||
}
|
||||
|
||||
public void generate(World world, Random random, int varX, int varZ)
|
||||
{
|
||||
|
||||
for (int i = 0; i < this.amountPerChunk; i++)
|
||||
{
|
||||
int x = varX + random.nextInt(16);
|
||||
int z = varZ + random.nextInt(16);
|
||||
int y = random.nextInt(this.maxGenerateLevel - this.minGenerateLevel) + this.minGenerateLevel;
|
||||
generateReplace(world, random, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean generateReplace(World par1World, Random par2Random, int par3, int par4, int par5)
|
||||
{
|
||||
float var6 = par2Random.nextFloat() * (float) Math.PI;
|
||||
double var7 = (double) ((float) (par3 + 8) + MathHelper.sin(var6) * (float) this.amountPerBranch / 8.0F);
|
||||
double var9 = (double) ((float) (par3 + 8) - MathHelper.sin(var6) * (float) this.amountPerBranch / 8.0F);
|
||||
double var11 = (double) ((float) (par5 + 8) + MathHelper.cos(var6) * (float) this.amountPerBranch / 8.0F);
|
||||
double var13 = (double) ((float) (par5 + 8) - MathHelper.cos(var6) * (float) this.amountPerBranch / 8.0F);
|
||||
double var15 = (double) (par4 + par2Random.nextInt(3) - 2);
|
||||
double var17 = (double) (par4 + par2Random.nextInt(3) - 2);
|
||||
|
||||
for (int var19 = 0; var19 <= this.amountPerBranch; ++var19)
|
||||
{
|
||||
double var20 = var7 + (var9 - var7) * (double) var19 / (double) this.amountPerBranch;
|
||||
double var22 = var15 + (var17 - var15) * (double) var19 / (double) this.amountPerBranch;
|
||||
double var24 = var11 + (var13 - var11) * (double) var19 / (double) this.amountPerBranch;
|
||||
double var26 = par2Random.nextDouble() * (double) this.amountPerBranch / 16.0D;
|
||||
double var28 = (double) (MathHelper.sin((float) var19 * (float) Math.PI / (float) this.amountPerBranch) + 1.0F) * var26 + 1.0D;
|
||||
double var30 = (double) (MathHelper.sin((float) var19 * (float) Math.PI / (float) this.amountPerBranch) + 1.0F) * var26 + 1.0D;
|
||||
int var32 = MathHelper.floor_double(var20 - var28 / 2.0D);
|
||||
int var33 = MathHelper.floor_double(var22 - var30 / 2.0D);
|
||||
int var34 = MathHelper.floor_double(var24 - var28 / 2.0D);
|
||||
int var35 = MathHelper.floor_double(var20 + var28 / 2.0D);
|
||||
int var36 = MathHelper.floor_double(var22 + var30 / 2.0D);
|
||||
int var37 = MathHelper.floor_double(var24 + var28 / 2.0D);
|
||||
|
||||
for (int var38 = var32; var38 <= var35; ++var38)
|
||||
{
|
||||
double var39 = ((double) var38 + 0.5D - var20) / (var28 / 2.0D);
|
||||
|
||||
if (var39 * var39 < 1.0D)
|
||||
{
|
||||
for (int var41 = var33; var41 <= var36; ++var41)
|
||||
{
|
||||
double var42 = ((double) var41 + 0.5D - var22) / (var30 / 2.0D);
|
||||
|
||||
if (var39 * var39 + var42 * var42 < 1.0D)
|
||||
{
|
||||
for (int var44 = var34; var44 <= var37; ++var44)
|
||||
{
|
||||
double var45 = ((double) var44 + 0.5D - var24) / (var28 / 2.0D);
|
||||
|
||||
int block = par1World.getBlockId(var38, var41, var44);
|
||||
if (var39 * var39 + var42 * var42 + var45 * var45 < 1.0D && (this.replaceID == 0 || block == this.replaceID))
|
||||
{
|
||||
par1World.setBlockAndMetadata(var38, var41, var44, this.oreID, this.oreMeta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOreGeneratedInWorld(World world, IChunkProvider chunkGenerator)
|
||||
{
|
||||
return ((this.generateSurface && chunkGenerator instanceof ChunkProviderGenerate) || (this.generateNether && chunkGenerator instanceof ChunkProviderHell) || (this.generateEnd && chunkGenerator instanceof ChunkProviderEnd));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package universalelectricity.prefab.ore;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class OreGenReplaceStone extends OreGenReplace
|
||||
{
|
||||
public OreGenReplaceStone(String name, String oreDiectionaryName, ItemStack stack, int replaceID, int minGenerateLevel, int maxGenerateLevel, int amountPerChunk, int amountPerBranch, String harvestTool, int harvestLevel)
|
||||
{
|
||||
super(name, oreDiectionaryName, stack, 1, minGenerateLevel, maxGenerateLevel, amountPerChunk, amountPerBranch, harvestTool, harvestLevel);
|
||||
this.generateSurface = true;
|
||||
}
|
||||
|
||||
// A simplified version of the constructor
|
||||
public OreGenReplaceStone(String name, String oreDiectionaryName, ItemStack stack, int replaceID, int maxGenerateLevel, int amountPerChunk, int amountPerBranch)
|
||||
{
|
||||
this(name, oreDiectionaryName, stack, 0, replaceID, maxGenerateLevel, amountPerChunk, amountPerBranch, "pickaxe", 1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package universalelectricity.prefab.ore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class OreGenerator implements IWorldGenerator
|
||||
{
|
||||
public static boolean isInitiated = false;
|
||||
|
||||
/**
|
||||
* Add your ore data to this list of ores for it to automatically generate! No hassle indeed!
|
||||
*/
|
||||
private static final List<OreGenBase> ORES_TO_GENERATE = new ArrayList<OreGenBase>();
|
||||
|
||||
/**
|
||||
* Adds an ore to the ore generate list. Do this in pre-init.
|
||||
*/
|
||||
public static void addOre(OreGenBase data)
|
||||
{
|
||||
if (!isInitiated)
|
||||
{
|
||||
GameRegistry.registerWorldGenerator(new OreGenerator());
|
||||
}
|
||||
|
||||
ORES_TO_GENERATE.add(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if this ore
|
||||
*
|
||||
* @param oreName
|
||||
* @return
|
||||
*/
|
||||
public static boolean oreExists(String oreName)
|
||||
{
|
||||
for (OreGenBase ore : ORES_TO_GENERATE)
|
||||
{
|
||||
if (ore.oreDictionaryName == oreName) { return true; }
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an ore to the ore generate list. Do this in init.
|
||||
*/
|
||||
public static void removeOre(OreGenBase data)
|
||||
{
|
||||
ORES_TO_GENERATE.remove(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Random rand, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
|
||||
{
|
||||
chunkX = chunkX << 4;
|
||||
chunkZ = chunkZ << 4;
|
||||
|
||||
// Checks to make sure this is the normal
|
||||
// world
|
||||
for (OreGenBase oreData : ORES_TO_GENERATE)
|
||||
{
|
||||
if (oreData.shouldGenerate && oreData.isOreGeneratedInWorld(world, chunkGenerator))
|
||||
{
|
||||
oreData.generate(world, rand, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package universalelectricity.prefab.potion;
|
||||
|
||||
import net.minecraft.potion.Potion;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
public abstract class CustomPotion extends Potion
|
||||
{
|
||||
/**
|
||||
* Creates a new type of potion
|
||||
*
|
||||
* @param id - The ID of this potion. Make it greater than 20.
|
||||
* @param isBadEffect - Is this potion a good potion or a bad one?
|
||||
* @param color - The color of this potion.
|
||||
* @param name - The name of this potion.
|
||||
*/
|
||||
public CustomPotion(int id, boolean isBadEffect, int color, String name)
|
||||
{
|
||||
super(id, isBadEffect, color);
|
||||
this.setPotionName("potion." + name);
|
||||
LanguageRegistry.instance().addStringLocalization(this.getName(), name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Potion setIconIndex(int par1, int par2)
|
||||
{
|
||||
super.setIconIndex(par1, par2);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* You must register all your potion effects during mod initialization!
|
||||
*/
|
||||
public void register()
|
||||
{
|
||||
Potion.potionTypes[this.getId()] = this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package universalelectricity.prefab.potion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
|
||||
public class CustomPotionEffect extends PotionEffect
|
||||
{
|
||||
public CustomPotionEffect(int potionID, int duration, int amplifier)
|
||||
{
|
||||
super(potionID, duration, amplifier);
|
||||
}
|
||||
|
||||
public CustomPotionEffect(Potion potion, int duration, int amplifier)
|
||||
{
|
||||
this(potion.getId(), duration, amplifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a potion effect with custom curable items.
|
||||
*
|
||||
* @param curativeItems - ItemStacks that can cure this potion effect
|
||||
*/
|
||||
public CustomPotionEffect(int potionID, int duration, int amplifier, List<ItemStack> curativeItems)
|
||||
{
|
||||
super(potionID, duration, amplifier);
|
||||
|
||||
if (curativeItems == null)
|
||||
{
|
||||
this.setCurativeItems(new ArrayList<ItemStack>());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setCurativeItems(curativeItems);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package universalelectricity.prefab.repair;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
/**
|
||||
* Applied to TileEntities/Machines that can be repaired.
|
||||
*
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public interface IRepairable
|
||||
{
|
||||
/**
|
||||
* Called when the machine is being repaired.
|
||||
*
|
||||
* @param itemStack - The repairing tool that the player is holding
|
||||
* @param player - The player who is repairing this machine.
|
||||
*/
|
||||
public void onRepair(IToolRepair itemStack, EntityPlayer player);
|
||||
|
||||
/**
|
||||
* @return The maximum possible damage of this machine.
|
||||
*/
|
||||
public int getMaxDamage();
|
||||
|
||||
/**
|
||||
* @return How damaged is this machine?
|
||||
*/
|
||||
public int getDamage();
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package universalelectricity.prefab.repair;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IToolRepair
|
||||
{
|
||||
/**
|
||||
* A unique ID for mods to recognize what repair tool this is.
|
||||
*/
|
||||
public String getID();
|
||||
|
||||
/**
|
||||
* How effective is this repairing tool?
|
||||
*
|
||||
* @param itemStack The ItemStack
|
||||
* @return A effectiveness value.
|
||||
*/
|
||||
public int getEffectiveness(ItemStack itemStack);
|
||||
}
|
|
@ -91,6 +91,9 @@ public abstract class TileEntityConductor extends TileEntityAdvanced implements
|
|||
{
|
||||
Electricity.instance.splitConnection(this, (IConductor) this.getConnectedBlocks()[side.ordinal()]);
|
||||
}
|
||||
|
||||
this.getNetwork().stopProducing(this.connectedBlocks[side.ordinal()]);
|
||||
this.getNetwork().stopRequesting(this.connectedBlocks[side.ordinal()]);
|
||||
}
|
||||
|
||||
this.connectedBlocks[side.ordinal()] = null;
|
||||
|
|
Loading…
Add table
Reference in a new issue