This commit is contained in:
tterrag1098 committed 2014-08-17 20:46:50 -04:00
commit eab14a3eda
17 files changed
+180 -74

No files matched your search

@@ -15,6 +15,7 @@ import crazypants.enderio.EnderIO;
import crazypants.enderio.GuiHandler;
import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.IConduitBundle;
import crazypants.enderio.conduit.redstone.IInsulatedRedstoneConduit;
import crazypants.enderio.network.PacketHandler;
import crazypants.render.ColorUtil;
import crazypants.util.BlockCoord;
@@ -28,7 +29,17 @@ public class GuiExternalConnectionSelector extends GuiScreen {
this.cb = cb;
cons = new HashSet<ForgeDirection>();
for (IConduit con : cb.getConduits()) {
cons.addAll(con.getExternalConnections());
if(con instanceof IInsulatedRedstoneConduit) {
Set<ForgeDirection> conCons = con.getConduitConnections();
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if(!conCons.contains(dir)) {
cons.add(dir);
}
}
} else {
cons.addAll(con.getExternalConnections());
}
}
}
@@ -192,6 +192,7 @@ public class ExistingItemFilterGui implements IItemFilterGui {
stickyB.detach();
gui.removeButton(snapshotB);
gui.removeButton(clearB);
gui.removeButton(showB);
}
public void renderCustomOptions(int top, float par1, int par2, int par3) {
@@ -38,6 +38,9 @@ public class NetworkedInventory {
//work around for a vanilla chest changing into a double chest without doing unneeded checks all the time
boolean recheckInv = false;
//Hack for TiC crafting station not working correctly when setting output slot to null
boolean ticHack = false;
World world;
ItemConduitNetwork network;
@@ -51,7 +54,9 @@ public class NetworkedInventory {
world = con.getBundle().getWorld();
TileEntity te = world.getTileEntity(location.x, location.y, location.z);
if(te.getClass().getName().contains("cpw.mods.ironchest")) {
if(te.getClass().getName().equals("tconstruct.tools.logic.CraftingStationLogic")) {
ticHack = true;
} else if(te.getClass().getName().contains("cpw.mods.ironchest")) {
recheckInv = true;
} else if(te instanceof TileEntityChest) {
recheckInv = true;
@@ -81,8 +86,8 @@ public class NetworkedInventory {
boolean isSticky() {
return con.getOutputFilter(conDir) != null && con.getOutputFilter(conDir).isValid() && con.getOutputFilter(conDir).isSticky();
}
int getPriority() {
int getPriority() {
return con.getOutputPriority(conDir);
}
@@ -175,17 +180,21 @@ public class NetworkedInventory {
if(numInserted <= 0) {
return false;
}
ItemStack curStack = getInventory().getStackInSlot(slot);
if(curStack != null) {
curStack = curStack.copy();
curStack.stackSize -= numInserted;
if(curStack.stackSize > 0) {
getInventory().setInventorySlotContents(slot, curStack);
if(ticHack) {
getInventory().decrStackSize(slot, numInserted);
getInventory().markDirty();
} else {
getInventory().setInventorySlotContents(slot, null);
getInventory().markDirty();
curStack = curStack.copy();
curStack.stackSize -= numInserted;
if(curStack.stackSize > 0) {
getInventory().setInventorySlotContents(slot, curStack);
getInventory().markDirty();
} else {
getInventory().setInventorySlotContents(slot, null);
getInventory().markDirty();
}
}
}
con.itemsExtracted(numInserted, slot);
@@ -337,7 +346,7 @@ public class NetworkedInventory {
BlockCoord targetConLoc = null;
if(target != null && target.inv != null && target.inv.con != null) {
targetConLoc = target.inv.con.getLocation();
}
}
if(targetConLoc != null && target.inv.conDir == dir && targetConLoc.equals(con.getLocation())) {
return target;
}
@@ -352,7 +361,7 @@ public class NetworkedInventory {
public ISidedInventory getInventory() {
return inv;
}
public int getInventorySide() {
return inventorySide;
}
@@ -360,7 +369,7 @@ public class NetworkedInventory {
public void setInventorySide(int inventorySide) {
this.inventorySide = inventorySide;
}
static class Target implements Comparable<Target> {
NetworkedInventory inv;
int distance;
@@ -383,7 +392,7 @@ public class NetworkedInventory {
return 1;
}
if(priority != o.priority) {
return ItemConduitNetwork.compare(o.priority,priority);
return ItemConduitNetwork.compare(o.priority, priority);
}
return ItemConduitNetwork.compare(distance, o.distance);
}
@@ -24,6 +24,8 @@ public class LiquidConduitNetwork extends AbstractTankConduitNetwork<LiquidCondu
private long timeAtLastApply;
private int ticksEmpty = 0;
private int maxFlowsPerTick = 10;
private int lastFlowIndex = 0;
@@ -65,7 +67,6 @@ public class LiquidConduitNetwork extends AbstractTankConduitNetwork<LiquidCondu
if(curTime > 0 && curTime != timeAtLastApply) {
timeAtLastApply = curTime;
ConduitNetworkTickHandler.instance.addListener(tickHandler);
//doTick(curTime);
}
}
@@ -76,10 +77,22 @@ public class LiquidConduitNetwork extends AbstractTankConduitNetwork<LiquidCondu
return;
}
if(isEmpty()) {
if(!fluidTypeLocked && liquidType != null) {
ticksEmpty++;
if(ticksEmpty > 40) {
setFluidType(null);
ticksEmpty = 0;
}
}
return;
}
ticksEmpty = 0;
long curTime = cons.get(0).getBundle().getEntity().getWorldObj().getTotalWorldTime();
// 1000 water, 6000 lava
if(liquidType != null && liquidType.getFluid() != null) {
if(liquidType != null && liquidType.getFluid() != null && !isEmpty()) {
int visc = Math.max(1000, liquidType.getFluid().getViscosity());
if(curTime % (visc / 500) == 0) {
long start = System.nanoTime();
@@ -90,9 +103,6 @@ public class LiquidConduitNetwork extends AbstractTankConduitNetwork<LiquidCondu
}
}
}
if(!fluidTypeLocked && isEmpty()) {
setFluidType(null);
}
}
void addedFromExternal(int res) {
@@ -7,6 +7,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.conduit.ConnectionMode;
import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.redstone.IInsulatedRedstoneConduit;
public class PacketConnectionMode extends AbstractConduitPacket<IConduit> implements IMessageHandler<PacketConnectionMode, IMessage>{
@@ -39,7 +40,12 @@ public class PacketConnectionMode extends AbstractConduitPacket<IConduit> implem
@Override
public IMessage onMessage(PacketConnectionMode message, MessageContext ctx) {
message.getTileCasted(ctx).setConnectionMode(message.dir, message.mode);
IConduit conduit = message.getTileCasted(ctx);
if(conduit instanceof IInsulatedRedstoneConduit) {
((IInsulatedRedstoneConduit)conduit).forceConnectionMode(message.dir, message.mode);
} else {
conduit.setConnectionMode(message.dir, message.mode);
}
message.getWorld(ctx).markBlockForUpdate(message.x, message.y, message.z);
return null;
}
@@ -59,18 +59,19 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
}
});
}
}
private static List<Block> VANILLA_CONECTABLES = Arrays.asList(Blocks.redstone_lamp, Blocks.redstone_torch, Blocks.redstone_wire, Blocks.redstone_block,
Blocks.dispenser, Blocks.lever, Blocks.wooden_button, Blocks.stone_button, Blocks.wooden_pressure_plate, Blocks.stone_pressure_plate,
Blocks.dropper, Blocks.daylight_detector, Blocks.command_block, Blocks.golden_rail);
//TODO:1.7 need to map all these
// 23, 25, 27, 28, 29, 33, 46, 55, 64, 69, 70, 71, 72, 75, 76, 77, 93, 94,
// 96, 107, 123, 124, 131, 143, 147, 148, 149, 150, 151, 152, 154, 157, 158);
Blocks.dropper, Blocks.daylight_detector, Blocks.command_block, Blocks.golden_rail, Blocks.trapped_chest);
private static Set<Class<?>> CONNECTABLE_CLASSES = null;
private Map<ForgeDirection, ConnectionMode> forcedConnections = new HashMap<ForgeDirection, ConnectionMode>();
private Map<ForgeDirection, DyeColor> signalColors = new HashMap<ForgeDirection, DyeColor>();
@Override
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) {
@@ -270,13 +271,33 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
World world = getBundle().getEntity().getWorldObj();
TileEntity te = world.getTileEntity(loc.x, loc.y, loc.z);
if(te instanceof IPowerEmitter || te instanceof IRedstoneControl || te instanceof AbstractMachineEntity) {
return true;
}
Collection<Class<?>> conectableInterfaces = getConectableInterfaces();
for(Class<?> conectable : conectableInterfaces) {
if( (te != null && conectable.isAssignableFrom(te.getClass()) ) || (block != null && conectable.isAssignableFrom(block.getClass()))) {
return true;
}
}
return false;
}
private static Collection<Class<?>> getConectableInterfaces() {
if(CONNECTABLE_CLASSES == null) {
CONNECTABLE_CLASSES = new HashSet<Class<?>>();
CONNECTABLE_CLASSES.add(IPowerEmitter.class);
CONNECTABLE_CLASSES.add(IRedstoneControl.class);
CONNECTABLE_CLASSES.add(AbstractMachineEntity.class);
try{
Class<?> conInterface = Class.forName("powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection");
CONNECTABLE_CLASSES.add(conInterface);
} catch(Throwable e) {
}
}
return CONNECTABLE_CLASSES;
}
@Override
public int isProvidingWeakPower(ForgeDirection toDirection) {
if(getConectionMode(toDirection.getOpposite()) != ConnectionMode.IN_OUT) {
@@ -55,8 +55,7 @@ public class RedstoneSwitchRenderer extends DefaultConduitRenderer {
for (int i = 0; i < icons.length; i++) {
icons[i] = EnderIO.blockConduitBundle.getConnectorIcon();
}
icons[1] = sw.getSwitchIcon();
;
icons[3] = sw.getSwitchIcon();
Vector3d trans = ConduitGeometryUtil.instance.getTranslation(ForgeDirection.UNKNOWN, bundle.getOffset(IRedstoneConduit.class, ForgeDirection.UNKNOWN));
BoundingBox bb = switchBounds.translate(trans);
@@ -253,23 +253,8 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
super.onBlockPlacedBy(world, x, y, z, player, stack);
int heading = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
AbstractMachineEntity te = (AbstractMachineEntity) world.getTileEntity(x, y, z);
switch (heading) {
case 0:
te.setFacing((short) 2);
break;
case 1:
te.setFacing((short) 5);
break;
case 2:
te.setFacing((short) 3);
break;
case 3:
te.setFacing((short) 4);
break;
default:
break;
}
AbstractMachineEntity te = (AbstractMachineEntity) world.getTileEntity(x, y, z);
te.setFacing(getFacingForHeading(heading));
te.readFromItemStack(stack);
if(world.isRemote) {
return;
@@ -277,6 +262,20 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
world.markBlockForUpdate(x, y, z);
}
protected short getFacingForHeading(int heading) {
switch (heading) {
case 0:
return 2;
case 1:
return 5;
case 2:
return 3;
case 3:
default:
return 4;
}
}
@Override
public void onBlockAdded(World world, int x, int y, int z) {
super.onBlockAdded(world, x, y, z);
@@ -262,13 +262,22 @@ public abstract class AbstractPoweredTaskEntity extends AbstractMachineEntity {
ResultStack[] nextResults = nextRecipe.getCompletedResult(chance, getInputs());
List<ItemStack> outputStacks = new ArrayList<ItemStack>(slotDefinition.getNumOutputSlots());
if(slotDefinition.getNumOutputSlots() > 0) {
boolean allFull = true;
for (int i = slotDefinition.minOutputSlot; i <= slotDefinition.maxOutputSlot; i++) {
ItemStack st = inventory[i];
if(st != null) {
st = st.copy();
if(allFull && st.stackSize < st.getMaxStackSize()) {
allFull = false;
}
} else {
allFull = false;
}
outputStacks.add(st);
}
if(allFull) {
return false;
}
}
for (ResultStack result : nextResults) {
@@ -290,6 +290,11 @@ public class TileFarmStation extends AbstractPoweredTaskEntity /*implements IEnt
FarmersCommune.instance.prepareBlock(this, bc, block, meta);
block = worldObj.getBlock(bc.x, bc.y, bc.z);
}
if(isOutputFull()) {
return false;
}
if(!isOpen(bc) && hasPower()) {
IHarvestResult harvest = FarmersCommune.instance.harvestBlock(this, bc, block, meta);
if(harvest != null) {
@@ -310,6 +315,16 @@ public class TileFarmStation extends AbstractPoweredTaskEntity /*implements IEnt
return false;
}
private boolean isOutputFull() {
for (int i = slotDefinition.minOutputSlot; i <= slotDefinition.maxOutputSlot; i++) {
ItemStack curStack = inventory[i];
if(curStack == null || curStack.stackSize < curStack.getMaxStackSize()) {
return false;
}
}
return true;
}
public boolean hasSeed(ItemStack seeds, BlockCoord bc) {
int slot = getSupplySlotForCoord(bc);
ItemStack inv = inventory[slot];
@@ -6,8 +6,11 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.fluids.FluidStack;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import crazypants.enderio.GuiHandler;
import crazypants.enderio.ModObject;
@@ -29,12 +32,16 @@ import crazypants.util.Util;
*/
public class BlockKillerJoe extends AbstractMachineBlock<TileKillerJoe> {
static final String USERNAME = "KillerJoe";
public static BlockKillerJoe create() {
PacketHandler.INSTANCE.registerMessage(PacketNutrientLevel.class, PacketNutrientLevel.class, PacketHandler.nextID(), Side.CLIENT);
PacketHandler.INSTANCE.registerMessage(PacketSwing.class, PacketSwing.class, PacketHandler.nextID(), Side.CLIENT);
PacketHandler.INSTANCE.registerMessage(PacketExperianceTotal.class, PacketExperianceTotal.class, PacketHandler.nextID(), Side.CLIENT);
PacketHandler.INSTANCE.registerMessage(PacketUseXP.class, PacketUseXP.class, PacketHandler.nextID(), Side.SERVER);
BlockKillerJoe res = new BlockKillerJoe();
MinecraftForge.EVENT_BUS.register(res);
res.init();
return res;
}
@@ -49,6 +56,13 @@ public class BlockKillerJoe extends AbstractMachineBlock<TileKillerJoe> {
return 2000;
}
@SubscribeEvent
public void getKillDisplayName(PlayerEvent.NameFormat nameEvt) {
if(nameEvt.username != null && nameEvt.username.startsWith(USERNAME)) {
nameEvt.displayname = getLocalizedName();
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
@@ -114,4 +128,18 @@ public class BlockKillerJoe extends AbstractMachineBlock<TileKillerJoe> {
return false;
}
protected short getFacingForHeading(int heading) {
switch (heading) {
case 0:
return 3;
case 1:
return 4;
case 2:
return 2;
case 3:
default:
return 5;
}
}
}
@@ -7,6 +7,8 @@ import java.util.Map;
import com.google.common.collect.Multimap;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
import net.minecraft.command.IEntitySelector;
@@ -33,6 +35,7 @@ import net.minecraft.util.DamageSource;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
@@ -115,14 +118,6 @@ public class TileKillerJoe extends AbstractMachineEntity implements IFluidHandle
return 0;
}
@Override
public void setInventorySlotContents(int slot, ItemStack contents) {
super.setInventorySlotContents(slot, contents);
if(slot == 0) {
getAttackera().inventory.setInventorySlotContents(0, contents);
}
}
@Override
public void updateEntity() {
updateArmSwingProgress();
@@ -141,8 +136,6 @@ public class TileKillerJoe extends AbstractMachineEntity implements IFluidHandle
return false;
}
//addExperience(1);
if(tanksDirty) {
PacketHandler.sendToAllAround(new PacketNutrientLevel(this), this);
tanksDirty = false;
@@ -354,11 +347,10 @@ public class TileKillerJoe extends AbstractMachineEntity implements IFluidHandle
FakePlayer getAttackera() {
if(attackera == null) {
attackera = new FakePlayer(MinecraftServer.getServer().worldServerForDimension(worldObj.provider.dimensionId), new GameProfile(null, "KillerJoe"
+ getLocation()));
attackera = new FakePlayer(MinecraftServer.getServer().worldServerForDimension(worldObj.provider.dimensionId), new GameProfile(null, BlockKillerJoe.USERNAME + ":" + getLocation()));
attackera.posX = xCoord + 0.5;
attackera.posY = yCoord + 0.5;
attackera.posZ = zCoord + 0.5;
attackera.posZ = zCoord + 0.5;
}
return attackera;
}
@@ -21,6 +21,7 @@ import crazypants.enderio.GuiHandler;
import crazypants.enderio.ModObject;
import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.IConduitBundle;
import crazypants.enderio.conduit.redstone.IInsulatedRedstoneConduit;
import crazypants.enderio.gui.IResourceTooltipProvider;
import crazypants.enderio.network.PacketHandler;
@@ -46,11 +47,6 @@ public class ItemConduitProbe extends Item implements IResourceTooltipProvider {
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float par8,
float par9, float par10) {
Block blk = world.getBlock(x, y, z);
if(blk != null) {
System.out.println("ItemConduitProbe.onItemUse: " + blk.getUnlocalizedName());
}
if(player.isSneaking()) {
@@ -58,11 +54,14 @@ public class ItemConduitProbe extends Item implements IResourceTooltipProvider {
if(te instanceof IConduitBundle) {
IConduitBundle cb = (IConduitBundle) te;
Set<ForgeDirection> cons = new HashSet<ForgeDirection>();
boolean hasInsulated = false;
for (IConduit con : cb.getConduits()) {
cons.addAll(con.getExternalConnections());
if(con instanceof IInsulatedRedstoneConduit) {
hasInsulated = true;
}
}
if(cons.isEmpty()) {
if(cons.isEmpty() && !hasInsulated) {
return false;
}
if(cons.size() == 1) {
@@ -263,7 +263,7 @@ public class TileCapacitorBank extends TileEntityEio implements IInternalPowerRe
}
//input any BC energy, yes, after output to avoid losing energy if we can
if(powerHandler != null && powerHandler.getEnergyStored() > 0) {
storedEnergy += powerHandler.getEnergyStored();
storedEnergy += powerHandler.getEnergyStored();
powerHandler.setEnergy(0);
}
if(isCreative) {
@@ -652,7 +652,7 @@ public class TileCapacitorBank extends TileEntityEio implements IInternalPowerRe
int canAccept = (int) Math.min(space, maxInput);
if(powerHandler == null || canAccept != mjBuf) {
mjBuf = canAccept;
powerHandler = PowerHandlerUtil.createHandler(new BasicCapacitor(maxInput, mjBuf, maxOutput), this, Type.STORAGE);
powerHandler = PowerHandlerUtil.createHandler(new BasicCapacitor(maxInput, mjBuf, maxOutput), this, Type.PIPE);
}
return powerHandler;
}
@@ -45,8 +45,6 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity {
public TilePoweredSpawner() {
super(new SlotDefinition(0, 0));
//logic.setEntityName("Zombie");
//logic.setEntityName("Skeleton");
logic.setEntityName(NULL_ENTITY_NAME);
}
@@ -154,7 +154,15 @@ public class BlockFusedQuartz extends BlockEio {
}
@Override
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
if(side == ForgeDirection.UP) { //stop drips
return false;
}
return true;
}
@Override
public boolean canPlaceTorchOnTop(World arg0, int arg1, int arg2, int arg3) {
return true;
}