mirror of
https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial.git
synced 2026-10-25 20:22:23 +00:00
1 parent
a6f80dcfc2
commit
85c566d896
8 files changed
+674
-522
No files matched your search
@@ -17,7 +17,10 @@ import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.storage.data.IAEStackType;
|
||||
import appeng.client.gui.slots.VirtualMEPhantomSlot;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerFormationPlane;
|
||||
@@ -27,26 +30,43 @@ import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
import appeng.parts.automation.PartBaseFormationPlane;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
|
||||
public class GuiFormationPlane extends GuiUpgradeable {
|
||||
|
||||
private GuiTabButton priority;
|
||||
private GuiImgButton placeMode;
|
||||
private VirtualMEPhantomSlot[] configSlots;
|
||||
protected final ContainerFormationPlane cfp;
|
||||
|
||||
public GuiFormationPlane(final InventoryPlayer inventoryPlayer, final PartFormationPlane te) {
|
||||
public GuiFormationPlane(final InventoryPlayer inventoryPlayer, final PartBaseFormationPlane te) {
|
||||
super(new ContainerFormationPlane(inventoryPlayer, te));
|
||||
this.ySize = 251;
|
||||
this.cfp = (ContainerFormationPlane) this.cvb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
initVirtualSlots();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.placeMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 28, Settings.PLACE_BLOCK, YesNo.YES);
|
||||
this.fuzzyMode = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
this.guiTop + 48,
|
||||
Settings.FUZZY_MODE,
|
||||
FuzzyMode.IGNORE_ALL);
|
||||
if (this.cfp.supportItemDrop()) {
|
||||
this.placeMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 28, Settings.PLACE_BLOCK, YesNo.YES);
|
||||
this.buttonList.add(this.placeMode);
|
||||
}
|
||||
|
||||
if (this.cfp.supportFuzzy()) {
|
||||
this.fuzzyMode = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
this.guiTop + 48,
|
||||
Settings.FUZZY_MODE,
|
||||
FuzzyMode.IGNORE_ALL);
|
||||
this.buttonList.add(this.fuzzyMode);
|
||||
}
|
||||
|
||||
this.buttonList.add(
|
||||
this.priority = new GuiTabButton(
|
||||
@@ -55,9 +75,6 @@ public class GuiFormationPlane extends GuiUpgradeable {
|
||||
2 + 4 * 16,
|
||||
GuiText.Priority.getLocal(),
|
||||
itemRender));
|
||||
|
||||
this.buttonList.add(this.placeMode);
|
||||
this.buttonList.add(this.fuzzyMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,7 +95,26 @@ public class GuiFormationPlane extends GuiUpgradeable {
|
||||
}
|
||||
|
||||
if (this.placeMode != null) {
|
||||
this.placeMode.set(((ContainerFormationPlane) this.cvb).getPlaceMode());
|
||||
this.placeMode.set(this.cfp.getPlaceMode());
|
||||
}
|
||||
|
||||
this.updateSlotVisibility();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
super.drawBG(offsetX, offsetY, mouseX, mouseY);
|
||||
|
||||
final int capacity = this.cvb.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY);
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
if (i >= capacity + 2) {
|
||||
// fadeout slots
|
||||
this.drawTexturedModalRect(offsetX + 7, offsetY + 28 + (18 * i), 7, 46, 162, 18);
|
||||
} else {
|
||||
// normal slots
|
||||
this.drawTexturedModalRect(offsetX + 7, offsetY + 28 + (18 * i), 7, 28, 162, 18);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,4 +135,36 @@ public class GuiFormationPlane extends GuiUpgradeable {
|
||||
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.placeMode.getSetting(), backwards));
|
||||
}
|
||||
}
|
||||
|
||||
private void initVirtualSlots() {
|
||||
this.configSlots = new VirtualMEPhantomSlot[63];
|
||||
final IAEStackInventory inputInv = this.cfp.getConfig();
|
||||
final int xo = 8;
|
||||
final int yo = -133;
|
||||
|
||||
for (int y = 0; y < 7; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
VirtualMEPhantomSlot slot = new VirtualMEPhantomSlot(
|
||||
xo + x * 18,
|
||||
yo + y * 18 + 9 * 18,
|
||||
inputInv,
|
||||
x + y * 9,
|
||||
this::acceptType);
|
||||
this.configSlots[x + y * 9] = slot;
|
||||
this.registerVirtualSlots(slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateSlotVisibility() {
|
||||
final int capacity = this.cfp.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY);
|
||||
|
||||
for (VirtualMEPhantomSlot slot : this.configSlots) {
|
||||
slot.setHidden(slot.getSlotIndex() >= (18 + (9 * capacity)));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean acceptType(VirtualMEPhantomSlot slot, IAEStackType<?> type, int mouseButton) {
|
||||
return type == this.cfp.getStackType();
|
||||
}
|
||||
}
|
||||
@@ -10,28 +10,36 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
import static appeng.util.Platform.isServer;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IAEStackType;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.OptionalSlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotFakeTypeOnly;
|
||||
import appeng.container.interfaces.IVirtualSlotHolder;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
import appeng.parts.automation.PartBaseFormationPlane;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import appeng.util.Platform;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
|
||||
public class ContainerFormationPlane extends ContainerUpgradeable {
|
||||
public class ContainerFormationPlane extends ContainerUpgradeable implements IVirtualSlotHolder {
|
||||
|
||||
@GuiSync(10)
|
||||
public YesNo placeMode;
|
||||
public final PartBaseFormationPlane te;
|
||||
private final IAEStack<?>[] configClientSlot = new IAEStack[63];
|
||||
|
||||
public ContainerFormationPlane(final InventoryPlayer ip, final PartFormationPlane te) {
|
||||
public ContainerFormationPlane(final InventoryPlayer ip, final PartBaseFormationPlane te) {
|
||||
super(ip, te);
|
||||
this.te = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,20 +49,6 @@ public class ContainerFormationPlane extends ContainerUpgradeable {
|
||||
|
||||
@Override
|
||||
protected void setupConfig() {
|
||||
final int xo = 8;
|
||||
final int yo = 23 + 6;
|
||||
|
||||
final IInventory config = this.getUpgradeable().getInventoryByName("config");
|
||||
for (int y = 0; y < 7; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
if (y < 2) {
|
||||
this.addSlotToContainer(new SlotFakeTypeOnly(config, y * 9 + x, xo + x * 18, yo + y * 18));
|
||||
} else {
|
||||
this.addSlotToContainer(new OptionalSlotFakeTypeOnly(config, this, y * 9 + x, xo, yo, x, y, y - 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final IInventory upgrades = this.getUpgradeable().getInventoryByName("upgrades");
|
||||
this.addSlotToContainer(
|
||||
(new SlotRestrictedInput(
|
||||
@@ -98,11 +92,6 @@ public class ContainerFormationPlane extends ContainerUpgradeable {
|
||||
this.getInventoryPlayer())).setNotDraggable());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportCapacity() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int availableUpgrades() {
|
||||
return 5;
|
||||
@@ -113,18 +102,28 @@ public class ContainerFormationPlane extends ContainerUpgradeable {
|
||||
this.verifyPermissions(SecurityPermissions.BUILD, false);
|
||||
|
||||
if (Platform.isServer()) {
|
||||
this.setFuzzyMode((FuzzyMode) this.getUpgradeable().getConfigManager().getSetting(Settings.FUZZY_MODE));
|
||||
this.setPlaceMode((YesNo) this.getUpgradeable().getConfigManager().getSetting(Settings.PLACE_BLOCK));
|
||||
if (this.supportFuzzy())
|
||||
this.setFuzzyMode((FuzzyMode) this.getUpgradeable().getConfigManager().getSetting(Settings.FUZZY_MODE));
|
||||
if (this.supportItemDrop())
|
||||
this.setPlaceMode((YesNo) this.getUpgradeable().getConfigManager().getSetting(Settings.PLACE_BLOCK));
|
||||
|
||||
final IAEStackInventory config = this.te.getAEInventoryByName(StorageName.CONFIG);
|
||||
this.updateVirtualSlots(StorageName.CONFIG, config, this.configClientSlot);
|
||||
}
|
||||
|
||||
this.standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(final int idx) {
|
||||
final int upgrades = this.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY);
|
||||
public void receiveSlotStacks(StorageName invName, Int2ObjectMap<IAEStack<?>> slotStacks) {
|
||||
final IAEStackInventory config = this.te.getAEInventoryByName(StorageName.CONFIG);
|
||||
for (var entry : slotStacks.int2ObjectEntrySet()) {
|
||||
config.putAEStackInSlot(entry.getIntKey(), entry.getValue());
|
||||
}
|
||||
|
||||
return upgrades > idx;
|
||||
if (isServer()) {
|
||||
this.updateVirtualSlots(StorageName.CONFIG, config, this.configClientSlot);
|
||||
}
|
||||
}
|
||||
|
||||
public YesNo getPlaceMode() {
|
||||
@@ -134,4 +133,20 @@ public class ContainerFormationPlane extends ContainerUpgradeable {
|
||||
private void setPlaceMode(final YesNo placeMode) {
|
||||
this.placeMode = placeMode;
|
||||
}
|
||||
|
||||
public IAEStackType<?> getStackType() {
|
||||
return this.te.getStackType();
|
||||
}
|
||||
|
||||
public IAEStackInventory getConfig() {
|
||||
return this.te.getAEInventoryByName(StorageName.CONFIG);
|
||||
}
|
||||
|
||||
public boolean supportItemDrop() {
|
||||
return this.te.supportItemDrop();
|
||||
}
|
||||
|
||||
public boolean supportFuzzy() {
|
||||
return this.te.supportFuzzy();
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ import appeng.helpers.IPriorityHost;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.items.contents.PriorityCardObject;
|
||||
import appeng.items.contents.QuartzKnifeObj;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
import appeng.parts.automation.PartBaseFormationPlane;
|
||||
import appeng.parts.automation.PartSharedItemBus;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
import appeng.tile.crafting.TileMolecularAssembler;
|
||||
@@ -188,7 +188,7 @@ public enum GuiBridge implements IGuiHandler {
|
||||
|
||||
GUI_STORAGEBUS(ContainerStorageBus.class, IStorageBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_FORMATION_PLANE(ContainerFormationPlane.class, PartFormationPlane.class, GuiHostType.WORLD,
|
||||
GUI_FORMATION_PLANE(ContainerFormationPlane.class, PartBaseFormationPlane.class, GuiHostType.WORLD,
|
||||
SecurityPermissions.BUILD),
|
||||
|
||||
GUI_PRIORITY(ContainerPriority.class, IPriorityHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD),
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -36,39 +35,26 @@ import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.core.sync.packets.PacketTransitionEffect;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.PartBasicState;
|
||||
import appeng.server.ServerHelper;
|
||||
import appeng.util.IWorldCallable;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartAnnihilationPlane extends PartBasicState implements IGridTickable, IWorldCallable<TickRateModulation> {
|
||||
public class PartAnnihilationPlane extends PartBaseAnnihilationPlane
|
||||
implements IGridTickable, IWorldCallable<TickRateModulation> {
|
||||
|
||||
private static final IIcon SIDE_ICON = CableBusTextures.PartPlaneSides.getIcon();
|
||||
private static final IIcon BACK_ICON = CableBusTextures.PartTransitionPlaneBack.getIcon();
|
||||
private static final IIcon STATUS_ICON = CableBusTextures.PartMonitorSidesStatus.getIcon();
|
||||
private static final IIcon ACTIVE_ICON = CableBusTextures.BlockAnnihilationPlaneOn.getIcon();
|
||||
private static final int MAX_CACHE_TIME = 60;
|
||||
|
||||
private final BaseActionSource mySrc = new MachineSource(this);
|
||||
@@ -94,137 +80,6 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
return this.breakBlock(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(final IPartCollisionHelper bch) {
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
final IPartHost host = this.getHost();
|
||||
if (host != null) {
|
||||
final TileEntity te = host.getTile();
|
||||
|
||||
final int x = te.xCoord;
|
||||
final int y = te.yCoord;
|
||||
final int z = te.zCoord;
|
||||
|
||||
final ForgeDirection e = bch.getWorldX();
|
||||
final ForgeDirection u = bch.getWorldY();
|
||||
|
||||
if (this.isAnnihilationPlane(
|
||||
te.getWorldObj().getTileEntity(x - e.offsetX, y - e.offsetY, z - e.offsetZ),
|
||||
this.getSide())) {
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(
|
||||
te.getWorldObj().getTileEntity(x + e.offsetX, y + e.offsetY, z + e.offsetZ),
|
||||
this.getSide())) {
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(
|
||||
te.getWorldObj().getTileEntity(x - u.offsetX, y - u.offsetY, z - u.offsetZ),
|
||||
this.getSide())) {
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(
|
||||
te.getWorldObj().getTileEntity(x + u.offsetX, y + u.offsetY, z + u.offsetZ),
|
||||
this.getSide())) {
|
||||
maxY = 16;
|
||||
}
|
||||
}
|
||||
|
||||
bch.addBox(5, 5, 14, 11, 11, 15);
|
||||
bch.addBox(minX, minY, 15, maxX, maxY, bch.isBBCollision() ? 15 : 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) {
|
||||
rh.setTexture(SIDE_ICON, SIDE_ICON, BACK_ICON, this.getItemStack().getIconIndex(), SIDE_ICON, SIDE_ICON);
|
||||
|
||||
rh.setBounds(1, 1, 15, 15, 15, 16);
|
||||
rh.renderInventoryBox(renderer);
|
||||
|
||||
rh.setBounds(5, 5, 14, 11, 11, 15);
|
||||
rh.renderInventoryBox(renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(final int x, final int y, final int z, final IPartRenderHelper rh,
|
||||
final RenderBlocks renderer) {
|
||||
this.renderStaticWithIcon(x, y, z, rh, renderer, ACTIVE_ICON);
|
||||
}
|
||||
|
||||
protected void renderStaticWithIcon(final int x, final int y, final int z, final IPartRenderHelper rh,
|
||||
final RenderBlocks renderer, final IIcon activeIcon) {
|
||||
int minX = 1;
|
||||
|
||||
final ForgeDirection e = rh.getWorldX();
|
||||
final ForgeDirection u = rh.getWorldY();
|
||||
|
||||
final TileEntity te = this.getHost().getTile();
|
||||
|
||||
if (this.isAnnihilationPlane(
|
||||
te.getWorldObj().getTileEntity(x - e.offsetX, y - e.offsetY, z - e.offsetZ),
|
||||
this.getSide())) {
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
int maxX = 15;
|
||||
if (this.isAnnihilationPlane(
|
||||
te.getWorldObj().getTileEntity(x + e.offsetX, y + e.offsetY, z + e.offsetZ),
|
||||
this.getSide())) {
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
int minY = 1;
|
||||
if (this.isAnnihilationPlane(
|
||||
te.getWorldObj().getTileEntity(x - u.offsetX, y - u.offsetY, z - u.offsetZ),
|
||||
this.getSide())) {
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
int maxY = 15;
|
||||
if (this.isAnnihilationPlane(
|
||||
te.getWorldObj().getTileEntity(x + u.offsetX, y + u.offsetY, z + u.offsetZ),
|
||||
this.getSide())) {
|
||||
maxY = 16;
|
||||
}
|
||||
|
||||
final boolean isActive = (this.getClientFlags() & (PartBasicState.POWERED_FLAG | PartBasicState.CHANNEL_FLAG))
|
||||
== (PartBasicState.POWERED_FLAG | PartBasicState.CHANNEL_FLAG);
|
||||
|
||||
this.setRenderCache(rh.useSimplifiedRendering(x, y, z, this, this.getRenderCache()));
|
||||
rh.setTexture(
|
||||
SIDE_ICON,
|
||||
SIDE_ICON,
|
||||
BACK_ICON,
|
||||
isActive ? activeIcon : this.getItemStack().getIconIndex(),
|
||||
SIDE_ICON,
|
||||
SIDE_ICON);
|
||||
|
||||
rh.setBounds(minX, minY, 15, maxX, maxY, 16);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
rh.setTexture(
|
||||
STATUS_ICON,
|
||||
STATUS_ICON,
|
||||
BACK_ICON,
|
||||
isActive ? activeIcon : this.getItemStack().getIconIndex(),
|
||||
STATUS_ICON,
|
||||
STATUS_ICON);
|
||||
|
||||
rh.setBounds(5, 5, 14, 11, 11, 15);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
this.renderLights(x, y, z, rh, renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged() {
|
||||
this.isAccepting = true;
|
||||
@@ -298,11 +153,6 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores an {@link EntityItem} inside the network and either marks it as dead or sets it to the leftover stackSize.
|
||||
*
|
||||
@@ -389,28 +239,6 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
w.spawnEntityInWorld(overflowEntity);
|
||||
}
|
||||
|
||||
protected boolean isAnnihilationPlane(final TileEntity blockTileEntity, final ForgeDirection side) {
|
||||
if (blockTileEntity instanceof IPartHost) {
|
||||
final IPart p = ((IPartHost) blockTileEntity).getPart(side);
|
||||
return p != null && p.getClass() == this.getClass();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void chanRender(final MENetworkChannelsChanged c) {
|
||||
this.onNeighborChanged();
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(final MENetworkPowerStatusChange c) {
|
||||
this.onNeighborChanged();
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
private TickRateModulation breakBlock(final boolean modulate) {
|
||||
if (this.isAccepting && this.getProxy().isActive()) {
|
||||
try {
|
||||
@@ -585,4 +413,9 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
this.spawnOverflow(overflow);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getActiveIcon() {
|
||||
return CableBusTextures.BlockAnnihilationPlaneOn.getIcon();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.parts.PartBasicState;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public abstract class PartBaseAnnihilationPlane extends PartBasicState {
|
||||
|
||||
private static final IIcon SIDE_ICON = CableBusTextures.PartPlaneSides.getIcon();
|
||||
private static final IIcon BACK_ICON = CableBusTextures.PartTransitionPlaneBack.getIcon();
|
||||
private static final IIcon STATUS_ICON = CableBusTextures.PartMonitorSidesStatus.getIcon();
|
||||
|
||||
public PartBaseAnnihilationPlane(ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(final IPartCollisionHelper bch) {
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
final IPartHost host = this.getHost();
|
||||
if (host != null) {
|
||||
final TileEntity te = host.getTile();
|
||||
|
||||
final int x = te.xCoord;
|
||||
final int y = te.yCoord;
|
||||
final int z = te.zCoord;
|
||||
|
||||
final ForgeDirection e = bch.getWorldX();
|
||||
final ForgeDirection u = bch.getWorldY();
|
||||
|
||||
if (this.isAnnihilationPlane(
|
||||
te.getWorldObj().getTileEntity(x - e.offsetX, y - e.offsetY, z - e.offsetZ),
|
||||
this.getSide())) {
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(
|
||||
te.getWorldObj().getTileEntity(x + e.offsetX, y + e.offsetY, z + e.offsetZ),
|
||||
this.getSide())) {
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(
|
||||
te.getWorldObj().getTileEntity(x - u.offsetX, y - u.offsetY, z - u.offsetZ),
|
||||
this.getSide())) {
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
if (this.isAnnihilationPlane(
|
||||
te.getWorldObj().getTileEntity(x + u.offsetX, y + u.offsetY, z + u.offsetZ),
|
||||
this.getSide())) {
|
||||
maxY = 16;
|
||||
}
|
||||
}
|
||||
|
||||
bch.addBox(5, 5, 14, 11, 11, 15);
|
||||
bch.addBox(minX, minY, 15, maxX, maxY, bch.isBBCollision() ? 15 : 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) {
|
||||
rh.setTexture(SIDE_ICON, SIDE_ICON, BACK_ICON, this.getItemStack().getIconIndex(), SIDE_ICON, SIDE_ICON);
|
||||
|
||||
rh.setBounds(1, 1, 15, 15, 15, 16);
|
||||
rh.renderInventoryBox(renderer);
|
||||
|
||||
rh.setBounds(5, 5, 14, 11, 11, 15);
|
||||
rh.renderInventoryBox(renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(final int x, final int y, final int z, final IPartRenderHelper rh,
|
||||
final RenderBlocks renderer) {
|
||||
this.renderStaticWithIcon(x, y, z, rh, renderer);
|
||||
}
|
||||
|
||||
protected void renderStaticWithIcon(final int x, final int y, final int z, final IPartRenderHelper rh,
|
||||
final RenderBlocks renderer) {
|
||||
int minX = 1;
|
||||
|
||||
final ForgeDirection e = rh.getWorldX();
|
||||
final ForgeDirection u = rh.getWorldY();
|
||||
|
||||
final TileEntity te = this.getHost().getTile();
|
||||
|
||||
if (this.isAnnihilationPlane(
|
||||
te.getWorldObj().getTileEntity(x - e.offsetX, y - e.offsetY, z - e.offsetZ),
|
||||
this.getSide())) {
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
int maxX = 15;
|
||||
if (this.isAnnihilationPlane(
|
||||
te.getWorldObj().getTileEntity(x + e.offsetX, y + e.offsetY, z + e.offsetZ),
|
||||
this.getSide())) {
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
int minY = 1;
|
||||
if (this.isAnnihilationPlane(
|
||||
te.getWorldObj().getTileEntity(x - u.offsetX, y - u.offsetY, z - u.offsetZ),
|
||||
this.getSide())) {
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
int maxY = 15;
|
||||
if (this.isAnnihilationPlane(
|
||||
te.getWorldObj().getTileEntity(x + u.offsetX, y + u.offsetY, z + u.offsetZ),
|
||||
this.getSide())) {
|
||||
maxY = 16;
|
||||
}
|
||||
|
||||
final boolean isActive = (this.getClientFlags() & (PartBasicState.POWERED_FLAG | PartBasicState.CHANNEL_FLAG))
|
||||
== (PartBasicState.POWERED_FLAG | PartBasicState.CHANNEL_FLAG);
|
||||
|
||||
this.setRenderCache(rh.useSimplifiedRendering(x, y, z, this, this.getRenderCache()));
|
||||
rh.setTexture(
|
||||
SIDE_ICON,
|
||||
SIDE_ICON,
|
||||
BACK_ICON,
|
||||
isActive ? this.getActiveIcon() : this.getItemStack().getIconIndex(),
|
||||
SIDE_ICON,
|
||||
SIDE_ICON);
|
||||
|
||||
rh.setBounds(minX, minY, 15, maxX, maxY, 16);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
rh.setTexture(
|
||||
STATUS_ICON,
|
||||
STATUS_ICON,
|
||||
BACK_ICON,
|
||||
isActive ? this.getActiveIcon() : this.getItemStack().getIconIndex(),
|
||||
STATUS_ICON,
|
||||
STATUS_ICON);
|
||||
|
||||
rh.setBounds(5, 5, 14, 11, 11, 15);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
this.renderLights(x, y, z, rh, renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected boolean isAnnihilationPlane(final TileEntity blockTileEntity, final ForgeDirection side) {
|
||||
if (blockTileEntity instanceof IPartHost iph) {
|
||||
final IPart p = iph.getPart(side);
|
||||
return p instanceof PartBaseAnnihilationPlane;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void chanRender(final MENetworkChannelsChanged c) {
|
||||
this.onNeighborChanged();
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(final MENetworkPowerStatusChange c) {
|
||||
this.onNeighborChanged();
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
public abstract IIcon getActiveIcon();
|
||||
}
|
||||
@@ -0,0 +1,322 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEStackType;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.IPrimaryGuiIconProvider;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.parts.PartBasicState;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import appeng.tile.inventory.IIAEStackInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public abstract class PartBaseFormationPlane extends PartUpgradeable
|
||||
implements IPriorityHost, IPrimaryGuiIconProvider, IIAEStackInventory {
|
||||
|
||||
protected int priority = 0;
|
||||
protected final IAEStackInventory Config = new IAEStackInventory(this, 63);
|
||||
protected boolean wasActive = false;
|
||||
protected boolean blocked = false;
|
||||
|
||||
public PartBaseFormationPlane(ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getUpgradeSlots() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
this.Config.readFromNBT(data, "config");
|
||||
this.priority = data.getInteger("priority");
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
this.Config.writeToNBT(data, "config");
|
||||
data.setInteger("priority", this.priority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
|
||||
this.updateHandler();
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removedStack, final ItemStack newStack) {
|
||||
super.onChangeInventory(inv, slot, mc, removedStack, newStack);
|
||||
|
||||
if (inv == this.Config) {
|
||||
this.updateHandler();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(final int newValue) {
|
||||
this.priority = newValue;
|
||||
this.getHost().markForSave();
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged() {
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(final MENetworkPowerStatusChange c) {
|
||||
final boolean currentActive = this.getProxy().isActive();
|
||||
if (this.wasActive != currentActive) {
|
||||
this.wasActive = currentActive;
|
||||
this.updateHandler();
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void updateChannels(final MENetworkChannelsChanged changedChannels) {
|
||||
final boolean currentActive = this.getProxy().isActive();
|
||||
if (this.wasActive != currentActive) {
|
||||
this.wasActive = currentActive;
|
||||
this.updateHandler();
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(final IPartCollisionHelper bch) {
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
final IPartHost host = this.getHost();
|
||||
if (host != null) {
|
||||
final TileEntity te = host.getTile();
|
||||
|
||||
final int x = te.xCoord;
|
||||
final int y = te.yCoord;
|
||||
final int z = te.zCoord;
|
||||
|
||||
final ForgeDirection e = bch.getWorldX();
|
||||
final ForgeDirection u = bch.getWorldY();
|
||||
|
||||
if (this.isTransitionPlane(
|
||||
te.getWorldObj().getTileEntity(x - e.offsetX, y - e.offsetY, z - e.offsetZ),
|
||||
this.getSide())) {
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
if (this.isTransitionPlane(
|
||||
te.getWorldObj().getTileEntity(x + e.offsetX, y + e.offsetY, z + e.offsetZ),
|
||||
this.getSide())) {
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
if (this.isTransitionPlane(
|
||||
te.getWorldObj().getTileEntity(x - u.offsetX, y - u.offsetY, z - u.offsetZ),
|
||||
this.getSide())) {
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
if (this.isTransitionPlane(
|
||||
te.getWorldObj().getTileEntity(x + u.offsetX, y + u.offsetY, z + u.offsetZ),
|
||||
this.getSide())) {
|
||||
maxY = 16;
|
||||
}
|
||||
}
|
||||
|
||||
bch.addBox(5, 5, 14, 11, 11, 15);
|
||||
bch.addBox(minX, minY, 15, maxX, maxY, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) {
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(),
|
||||
this.getItemStack().getIconIndex(),
|
||||
CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartPlaneSides.getIcon());
|
||||
|
||||
rh.setBounds(1, 1, 15, 15, 15, 16);
|
||||
rh.renderInventoryBox(renderer);
|
||||
|
||||
rh.setBounds(5, 5, 14, 11, 11, 15);
|
||||
rh.renderInventoryBox(renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(final int x, final int y, final int z, final IPartRenderHelper rh,
|
||||
final RenderBlocks renderer) {
|
||||
int minX = 1;
|
||||
|
||||
final ForgeDirection e = rh.getWorldX();
|
||||
final ForgeDirection u = rh.getWorldY();
|
||||
|
||||
final TileEntity te = this.getHost().getTile();
|
||||
|
||||
if (this.isTransitionPlane(
|
||||
te.getWorldObj().getTileEntity(x - e.offsetX, y - e.offsetY, z - e.offsetZ),
|
||||
this.getSide())) {
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
int maxX = 15;
|
||||
if (this.isTransitionPlane(
|
||||
te.getWorldObj().getTileEntity(x + e.offsetX, y + e.offsetY, z + e.offsetZ),
|
||||
this.getSide())) {
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
int minY = 1;
|
||||
if (this.isTransitionPlane(
|
||||
te.getWorldObj().getTileEntity(x - u.offsetX, y - u.offsetY, z - u.offsetZ),
|
||||
this.getSide())) {
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
int maxY = 15;
|
||||
if (this.isTransitionPlane(
|
||||
te.getWorldObj().getTileEntity(x + u.offsetX, y + u.offsetY, z + u.offsetZ),
|
||||
this.getSide())) {
|
||||
maxY = 16;
|
||||
}
|
||||
|
||||
final boolean isActive = (this.getClientFlags() & (PartBasicState.POWERED_FLAG | PartBasicState.CHANNEL_FLAG))
|
||||
== (PartBasicState.POWERED_FLAG | PartBasicState.CHANNEL_FLAG);
|
||||
|
||||
this.setRenderCache(rh.useSimplifiedRendering(x, y, z, this, this.getRenderCache()));
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(),
|
||||
isActive ? this.getActiveIcon() : this.getItemStack().getIconIndex(),
|
||||
CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartPlaneSides.getIcon());
|
||||
|
||||
rh.setBounds(minX, minY, 15, maxX, maxY, 16);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(),
|
||||
isActive ? this.getActiveIcon() : this.getItemStack().getIconIndex(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon());
|
||||
|
||||
rh.setBounds(5, 5, 14, 11, 11, 15);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
this.renderLights(x, y, z, rh, renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
if (!player.isSneaking()) {
|
||||
if (Platform.isClient()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI(player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_FORMATION_PLANE);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged() {
|
||||
final TileEntity te = this.getHost().getTile();
|
||||
final World w = te.getWorldObj();
|
||||
final ForgeDirection side = this.getSide();
|
||||
|
||||
final int x = te.xCoord + side.offsetX;
|
||||
final int y = te.yCoord + side.offsetY;
|
||||
final int z = te.zCoord + side.offsetZ;
|
||||
|
||||
this.blocked = !w.getBlock(x, y, z).isReplaceable(w, x, y, z);
|
||||
}
|
||||
|
||||
protected boolean isTransitionPlane(final TileEntity blockTileEntity, final ForgeDirection side) {
|
||||
if (blockTileEntity instanceof IPartHost) {
|
||||
final IPart p = ((IPartHost) blockTileEntity).getPart(side);
|
||||
return p instanceof PartBaseFormationPlane;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPrimaryGuiIcon() {
|
||||
return this.getItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAEStackInv() {
|
||||
this.updateHandler();
|
||||
this.saveChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEStackInventory getAEInventoryByName(StorageName name) {
|
||||
if (name == StorageName.CONFIG) {
|
||||
return this.Config;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract IAEStackType<?> getStackType();
|
||||
|
||||
public abstract boolean supportItemDrop();
|
||||
|
||||
public abstract boolean supportFuzzy();
|
||||
|
||||
protected void updateHandler() {}
|
||||
|
||||
public abstract IIcon getActiveIcon();
|
||||
}
|
||||
@@ -17,21 +17,18 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemFirework;
|
||||
import net.minecraft.item.ItemReed;
|
||||
import net.minecraft.item.ItemSkull;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
@@ -52,14 +49,7 @@ import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.networking.events.MENetworkCellArrayUpdate;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartCollisionHelper;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.storage.ICellContainer;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
@@ -67,32 +57,18 @@ import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStackType;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.IPrimaryGuiIconProvider;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.parts.PartBasicState;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.prioitylist.FuzzyPriorityList;
|
||||
import appeng.util.prioitylist.PrecisePriorityList;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartFormationPlane extends PartUpgradeable
|
||||
implements ICellContainer, IPriorityHost, IMEInventory<IAEItemStack>, IPrimaryGuiIconProvider {
|
||||
public class PartFormationPlane extends PartBaseFormationPlane implements ICellContainer, IMEInventory<IAEItemStack> {
|
||||
|
||||
private final MEInventoryHandler myHandler = new MEInventoryHandler(this, ITEM_STACK_TYPE);
|
||||
private final AppEngInternalAEInventory Config = new AppEngInternalAEInventory(this, 63);
|
||||
private EntityPlayer owner = null;
|
||||
private int priority = 0;
|
||||
private boolean wasActive = false;
|
||||
private boolean blocked = false;
|
||||
|
||||
public PartFormationPlane(final ItemStack is) {
|
||||
super(is);
|
||||
@@ -108,7 +84,7 @@ public class PartFormationPlane extends PartUpgradeable
|
||||
this.owner = player;
|
||||
}
|
||||
|
||||
private void updateHandler() {
|
||||
protected void updateHandler() {
|
||||
this.myHandler.setBaseAccess(AccessRestriction.WRITE);
|
||||
this.myHandler.setWhitelist(
|
||||
this.getInstalledUpgrades(Upgrades.INVERTER) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST);
|
||||
@@ -118,10 +94,8 @@ public class PartFormationPlane extends PartUpgradeable
|
||||
|
||||
final int slotsToUse = 18 + this.getInstalledUpgrades(Upgrades.CAPACITY) * 9;
|
||||
for (int x = 0; x < this.Config.getSizeInventory() && x < slotsToUse; x++) {
|
||||
final IAEItemStack is = this.Config.getAEStackInSlot(x);
|
||||
if (is != null) {
|
||||
priorityList.add(is);
|
||||
}
|
||||
if (!(this.Config.getAEStackInSlot(x) instanceof IAEItemStack ais)) continue;
|
||||
priorityList.add(ais);
|
||||
}
|
||||
|
||||
if (this.getInstalledUpgrades(Upgrades.FUZZY) > 0) {
|
||||
@@ -140,249 +114,6 @@ public class PartFormationPlane extends PartUpgradeable
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getUpgradeSlots() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
|
||||
this.updateHandler();
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removedStack, final ItemStack newStack) {
|
||||
super.onChangeInventory(inv, slot, mc, removedStack, newStack);
|
||||
|
||||
if (inv == this.Config) {
|
||||
this.updateHandler();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged() {
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
this.Config.readFromNBT(data, "config");
|
||||
this.priority = data.getInteger("priority");
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
this.Config.writeToNBT(data, "config");
|
||||
data.setInteger("priority", this.priority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(final String name) {
|
||||
if (name.equals("config")) {
|
||||
return this.Config;
|
||||
}
|
||||
|
||||
return super.getInventoryByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(final MENetworkPowerStatusChange c) {
|
||||
final boolean currentActive = this.getProxy().isActive();
|
||||
if (this.wasActive != currentActive) {
|
||||
this.wasActive = currentActive;
|
||||
this.updateHandler(); // proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void updateChannels(final MENetworkChannelsChanged changedChannels) {
|
||||
final boolean currentActive = this.getProxy().isActive();
|
||||
if (this.wasActive != currentActive) {
|
||||
this.wasActive = currentActive;
|
||||
this.updateHandler(); // proxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes(final IPartCollisionHelper bch) {
|
||||
int minX = 1;
|
||||
int minY = 1;
|
||||
int maxX = 15;
|
||||
int maxY = 15;
|
||||
|
||||
final IPartHost host = this.getHost();
|
||||
if (host != null) {
|
||||
final TileEntity te = host.getTile();
|
||||
|
||||
final int x = te.xCoord;
|
||||
final int y = te.yCoord;
|
||||
final int z = te.zCoord;
|
||||
|
||||
final ForgeDirection e = bch.getWorldX();
|
||||
final ForgeDirection u = bch.getWorldY();
|
||||
|
||||
if (this.isTransitionPlane(
|
||||
te.getWorldObj().getTileEntity(x - e.offsetX, y - e.offsetY, z - e.offsetZ),
|
||||
this.getSide())) {
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
if (this.isTransitionPlane(
|
||||
te.getWorldObj().getTileEntity(x + e.offsetX, y + e.offsetY, z + e.offsetZ),
|
||||
this.getSide())) {
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
if (this.isTransitionPlane(
|
||||
te.getWorldObj().getTileEntity(x - u.offsetX, y - u.offsetY, z - u.offsetZ),
|
||||
this.getSide())) {
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
if (this.isTransitionPlane(
|
||||
te.getWorldObj().getTileEntity(x + u.offsetX, y + u.offsetY, z + u.offsetZ),
|
||||
this.getSide())) {
|
||||
maxY = 16;
|
||||
}
|
||||
}
|
||||
|
||||
bch.addBox(5, 5, 14, 11, 11, 15);
|
||||
bch.addBox(minX, minY, 15, maxX, maxY, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) {
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(),
|
||||
this.getItemStack().getIconIndex(),
|
||||
CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartPlaneSides.getIcon());
|
||||
|
||||
rh.setBounds(1, 1, 15, 15, 15, 16);
|
||||
rh.renderInventoryBox(renderer);
|
||||
|
||||
rh.setBounds(5, 5, 14, 11, 11, 15);
|
||||
rh.renderInventoryBox(renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(final int x, final int y, final int z, final IPartRenderHelper rh,
|
||||
final RenderBlocks renderer) {
|
||||
int minX = 1;
|
||||
|
||||
final ForgeDirection e = rh.getWorldX();
|
||||
final ForgeDirection u = rh.getWorldY();
|
||||
|
||||
final TileEntity te = this.getHost().getTile();
|
||||
|
||||
if (this.isTransitionPlane(
|
||||
te.getWorldObj().getTileEntity(x - e.offsetX, y - e.offsetY, z - e.offsetZ),
|
||||
this.getSide())) {
|
||||
minX = 0;
|
||||
}
|
||||
|
||||
int maxX = 15;
|
||||
if (this.isTransitionPlane(
|
||||
te.getWorldObj().getTileEntity(x + e.offsetX, y + e.offsetY, z + e.offsetZ),
|
||||
this.getSide())) {
|
||||
maxX = 16;
|
||||
}
|
||||
|
||||
int minY = 1;
|
||||
if (this.isTransitionPlane(
|
||||
te.getWorldObj().getTileEntity(x - u.offsetX, y - u.offsetY, z - u.offsetZ),
|
||||
this.getSide())) {
|
||||
minY = 0;
|
||||
}
|
||||
|
||||
int maxY = 15;
|
||||
if (this.isTransitionPlane(
|
||||
te.getWorldObj().getTileEntity(x + u.offsetX, y + u.offsetY, z + u.offsetZ),
|
||||
this.getSide())) {
|
||||
maxY = 16;
|
||||
}
|
||||
|
||||
final boolean isActive = (this.getClientFlags() & (PartBasicState.POWERED_FLAG | PartBasicState.CHANNEL_FLAG))
|
||||
== (PartBasicState.POWERED_FLAG | PartBasicState.CHANNEL_FLAG);
|
||||
|
||||
this.setRenderCache(rh.useSimplifiedRendering(x, y, z, this, this.getRenderCache()));
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(),
|
||||
isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : this.getItemStack().getIconIndex(),
|
||||
CableBusTextures.PartPlaneSides.getIcon(),
|
||||
CableBusTextures.PartPlaneSides.getIcon());
|
||||
|
||||
rh.setBounds(minX, minY, 15, maxX, maxY, 16);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
rh.setTexture(
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartTransitionPlaneBack.getIcon(),
|
||||
isActive ? CableBusTextures.BlockFormPlaneOn.getIcon() : this.getItemStack().getIconIndex(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon(),
|
||||
CableBusTextures.PartMonitorSidesStatus.getIcon());
|
||||
|
||||
rh.setBounds(5, 5, 14, 11, 11, 15);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
this.renderLights(x, y, z, rh, renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged() {
|
||||
final TileEntity te = this.getHost().getTile();
|
||||
final World w = te.getWorldObj();
|
||||
final ForgeDirection side = this.getSide();
|
||||
|
||||
final int x = te.xCoord + side.offsetX;
|
||||
final int y = te.yCoord + side.offsetY;
|
||||
final int z = te.zCoord + side.offsetZ;
|
||||
|
||||
this.blocked = !w.getBlock(x, y, z).isReplaceable(w, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cableConnectionRenderTo() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
if (!player.isSneaking()) {
|
||||
if (Platform.isClient()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Platform.openGUI(player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_FORMATION_PLANE);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isTransitionPlane(final TileEntity blockTileEntity, final ForgeDirection side) {
|
||||
if (blockTileEntity instanceof IPartHost) {
|
||||
final IPart p = ((IPartHost) blockTileEntity).getPart(side);
|
||||
return p instanceof PartFormationPlane;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<IMEInventoryHandler> getCellArray(final IAEStackType<?> type) {
|
||||
@@ -394,18 +125,6 @@ public class PartFormationPlane extends PartUpgradeable
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(final int newValue) {
|
||||
this.priority = newValue;
|
||||
this.getHost().markForSave();
|
||||
this.updateHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(final IAEItemStack input, final Actionable type, final BaseActionSource src) {
|
||||
if (this.blocked || input == null || input.getStackSize() <= 0) {
|
||||
@@ -655,7 +374,22 @@ public class PartFormationPlane extends PartUpgradeable
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPrimaryGuiIcon() {
|
||||
return AEApi.instance().definitions().parts().formationPlane().maybeStack(1).orNull();
|
||||
public @NotNull IAEStackType<?> getStackType() {
|
||||
return ITEM_STACK_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportItemDrop() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportFuzzy() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getActiveIcon() {
|
||||
return CableBusTextures.BlockFormPlaneOn.getIcon();
|
||||
}
|
||||
}
|
||||
@@ -18,13 +18,9 @@ import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.util.Platform;
|
||||
@@ -33,8 +29,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PartIdentityAnnihilationPlane extends PartAnnihilationPlane {
|
||||
|
||||
private static final IIcon ACTIVE_ICON = CableBusTextures.BlockIdentityAnnihilationPlaneOn.getIcon();
|
||||
|
||||
private static final float SILK_TOUCH_FACTOR = 16;
|
||||
|
||||
public PartIdentityAnnihilationPlane(final ItemStack is) {
|
||||
@@ -45,16 +39,7 @@ public class PartIdentityAnnihilationPlane extends PartAnnihilationPlane {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(final int x, final int y, final int z, final IPartRenderHelper rh,
|
||||
final RenderBlocks renderer) {
|
||||
this.renderStaticWithIcon(x, y, z, rh, renderer, ACTIVE_ICON);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAnnihilationPlane(final TileEntity blockTileEntity, final ForgeDirection side) {
|
||||
if (blockTileEntity instanceof IPartHost) {
|
||||
final IPart p = ((IPartHost) blockTileEntity).getPart(side);
|
||||
return p != null && p.getClass() == this.getClass();
|
||||
}
|
||||
return false;
|
||||
this.renderStaticWithIcon(x, y, z, rh, renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,4 +73,9 @@ public class PartIdentityAnnihilationPlane extends PartAnnihilationPlane {
|
||||
return super.obtainBlockDrops(w, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getActiveIcon() {
|
||||
return CableBusTextures.BlockIdentityAnnihilationPlaneOn.getIcon();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user