mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-28 07:36:01 +00:00
Merge branch '1.8' of https://github.com/aidancbrady/Mekanism into 1.8
This commit is contained in:
commit
ddb6140513
11 files changed
+1574
-35
No files matched your search
@@ -0,0 +1,38 @@
|
||||
package mekanism.api;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class BlockInfo
|
||||
{
|
||||
public Block block;
|
||||
public int meta;
|
||||
|
||||
public BlockInfo(Block b, int j)
|
||||
{
|
||||
block = b;
|
||||
meta = j;
|
||||
}
|
||||
|
||||
public static BlockInfo get(ItemStack stack)
|
||||
{
|
||||
return new BlockInfo(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
return obj instanceof BlockInfo &&
|
||||
((BlockInfo)obj).block == block &&
|
||||
((BlockInfo)obj).meta == meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int code = 1;
|
||||
code = 31 * code + block.getUnlocalizedName().hashCode();
|
||||
code = 31 * code + meta;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,29 @@
|
||||
package mekanism.api;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemInfo
|
||||
{
|
||||
public Block block;
|
||||
public Item item;
|
||||
public int meta;
|
||||
|
||||
public ItemInfo(Block b, int j)
|
||||
public ItemInfo(Item i, int j)
|
||||
{
|
||||
block = b;
|
||||
item = i;
|
||||
meta = j;
|
||||
}
|
||||
|
||||
public static ItemInfo get(ItemStack stack)
|
||||
{
|
||||
return new ItemInfo(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage());
|
||||
return new ItemInfo(stack.getItem(), stack.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
return obj instanceof ItemInfo &&
|
||||
((ItemInfo)obj).block == block &&
|
||||
return obj instanceof BlockInfo &&
|
||||
((ItemInfo)obj).item == item &&
|
||||
((ItemInfo)obj).meta == meta;
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ public class ItemInfo
|
||||
public int hashCode()
|
||||
{
|
||||
int code = 1;
|
||||
code = 31 * code + block.getUnlocalizedName().hashCode();
|
||||
code = 31 * code + item.getUnlocalizedName().hashCode();
|
||||
code = 31 * code + meta;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,11 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
public class MekanismAPI
|
||||
{
|
||||
//Add a BlockInfo value here if you don't want a certain block to be picked up by cardboard boxes
|
||||
private static Set<ItemInfo> cardboardBoxIgnore = new HashSet<ItemInfo>();
|
||||
private static Set<BlockInfo> cardboardBoxIgnore = new HashSet<BlockInfo>();
|
||||
|
||||
public static boolean isBlockCompatible(Item item, int meta)
|
||||
{
|
||||
for(ItemInfo i : cardboardBoxIgnore)
|
||||
for(BlockInfo i : cardboardBoxIgnore)
|
||||
{
|
||||
if(i.block == Block.getBlockFromItem(item) && (i.meta == OreDictionary.WILDCARD_VALUE || i.meta == meta))
|
||||
{
|
||||
@@ -28,15 +28,15 @@ public class MekanismAPI
|
||||
|
||||
public static void addBoxBlacklist(Block block, int meta)
|
||||
{
|
||||
cardboardBoxIgnore.add(new ItemInfo(block, meta));
|
||||
cardboardBoxIgnore.add(new BlockInfo(block, meta));
|
||||
}
|
||||
|
||||
public static void removeBoxBlacklist(Block block, int meta)
|
||||
{
|
||||
cardboardBoxIgnore.remove(new ItemInfo(block, meta));
|
||||
cardboardBoxIgnore.remove(new BlockInfo(block, meta));
|
||||
}
|
||||
|
||||
public static Set<ItemInfo> getBoxIgnore()
|
||||
public static Set<BlockInfo> getBoxIgnore()
|
||||
{
|
||||
return cardboardBoxIgnore;
|
||||
}
|
||||
|
||||
@@ -2,12 +2,48 @@ package mekanism.api.lasers;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class LaserManager
|
||||
{
|
||||
public static void fireLaser(Coord4D from, ForgeDirection direction, double energy)
|
||||
public static int range = 100;
|
||||
|
||||
public static void fireLaser(Coord4D from, ForgeDirection direction, double energy, World world)
|
||||
{
|
||||
//TODO: Implement this
|
||||
Coord4D to = from.getFromSide(direction, range);
|
||||
MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(from.xCoord, from.yCoord, from.zCoord), Vec3.createVectorHelper(to.xCoord, to.yCoord, to.zCoord));
|
||||
|
||||
if(mop != null)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
|
||||
|
||||
if(tile instanceof ILaserReceptor)
|
||||
{
|
||||
if(((ILaserReceptor)tile).canLasersDig() && energy > ((ILaserReceptor)tile).energyToDig())
|
||||
{
|
||||
//TODO dig block
|
||||
}
|
||||
else
|
||||
{
|
||||
((ILaserReceptor)tile).receiveLaserEnergy(energy, ForgeDirection.getOrientation(mop.sideHit));
|
||||
}
|
||||
}
|
||||
|
||||
renderLaser(from, new Coord4D(mop.blockX, mop.blockY, mop.blockZ));
|
||||
}
|
||||
else
|
||||
{
|
||||
renderLaser(from, to);
|
||||
}
|
||||
}
|
||||
|
||||
public static void renderLaser(Coord4D from, Coord4D to)
|
||||
{
|
||||
//TODO Particle effects
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user