use of logisticspipes.utils.MinecraftColor in project LogisticsPipes by RS485.
the class FluidContainerRenderer method renderItem.
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
if (FluidContainerRenderer.skipNext) {
FluidContainerRenderer.skipNext = false;
return;
}
GL11.glPushMatrix();
Minecraft mc = FMLClientHandler.instance().getClient();
if (item.getItem() instanceof LogisticsFluidContainer) {
FluidStack liquid = SimpleServiceLocator.logisticsFluidManager.getFluidFromContainer(ItemIdentifierStack.getFromStack(item));
if ((type != ItemRenderType.INVENTORY && type != ItemRenderType.ENTITY) || liquid == null) {
doRenderItem(item, mc, type, data);
GL11.glPopMatrix();
return;
}
doRenderFluid(liquid, mc, type, data);
doRenderItem(item, mc, type, data);
} else if (item.getItem() instanceof LogisticsItemCard) {
doRenderItem(item, mc, type, data);
NBTTagCompound nbt = item.getTagCompound();
if (nbt == null || !nbt.hasKey("colors")) {
GL11.glPopMatrix();
return;
}
NBTTagCompound colors = nbt.getCompoundTag("colors");
if (colors == null) {
GL11.glPopMatrix();
return;
}
if (type == ItemRenderType.ENTITY) {
GL11.glScaled(0.07, 0.07, 1);
GL11.glTranslated(-3, 3.5, -0.025);
}
for (int i = 0; i < 6; i++) {
int colorCode = colors.getInteger("color:" + i);
MinecraftColor color = MinecraftColor.values()[colorCode];
int x = i / 3;
int y = i % 3;
if (type == ItemRenderType.INVENTORY) {
Gui.drawRect(x * 5 + 4, y * 3 + 3, x * 5 + 7, y * 3 + 5, color.getColorCode());
}
if (type == ItemRenderType.ENTITY) {
Gui.drawRect(-x * 5 + 4, -y * 3 + 3, -x * 5 + 7, -y * 3 + 5, color.getColorCode());
GL11.glRotatef(180, 1, 0, 0);
Gui.drawRect(-x * 5 + 4, -y * 3 + 3, -x * 5 + 7, -y * 3 + 5, color.getColorCode());
GL11.glRotatef(180, 1, 0, 0);
}
}
}
GL11.glPopMatrix();
}
use of logisticspipes.utils.MinecraftColor in project LogisticsPipes by RS485.
the class DummyContainer method handleDummyClick.
public void handleDummyClick(Slot slot, int slotId, ItemStack currentlyEquippedStack, int mouseButton, int isShift, EntityPlayer entityplayer) {
if (slot instanceof FluidSlot) {
if (currentlyEquippedStack != null) {
FluidStack liquidId = FluidContainerRegistry.getFluidForFilledItem(currentlyEquippedStack);
if (liquidId != null) {
FluidIdentifier ident = FluidIdentifier.get(liquidId);
if (mouseButton == 0) {
if (ident == null) {
slot.putStack(null);
} else {
slot.putStack(ident.getItemIdentifier().unsafeMakeNormalStack(1));
}
} else {
slot.putStack(null);
}
return;
}
FluidIdentifier ident = FluidIdentifier.get(currentlyEquippedStack);
if (ident != null) {
if (mouseButton == 0) {
slot.putStack(ident.getItemIdentifier().unsafeMakeNormalStack(1));
} else {
slot.putStack(null);
}
return;
}
}
FluidIdentifier ident = null;
if (slot.getStack() != null) {
ident = FluidIdentifier.get(ItemIdentifier.get(slot.getStack()));
}
if (ident == null) {
if (MainProxy.isClient(entityplayer.getEntityWorld())) {
MainProxy.proxy.openFluidSelectGui(slotId);
}
}
slot.putStack(null);
return;
}
if (slot instanceof ColorSlot) {
MinecraftColor equipped = MinecraftColor.getColor(currentlyEquippedStack);
MinecraftColor color = MinecraftColor.getColor(slot.getStack());
if (MinecraftColor.BLANK.equals(equipped)) {
if (mouseButton == 0) {
color = color.getNext();
} else if (mouseButton == 1) {
color = color.getPrev();
} else {
color = MinecraftColor.BLANK;
}
slot.putStack(color.getItemStack());
} else {
if (mouseButton == 1) {
slot.putStack(MinecraftColor.BLANK.getItemStack());
} else {
slot.putStack(equipped.getItemStack());
}
}
if (entityplayer instanceof EntityPlayerMP && MainProxy.isServer(entityplayer.worldObj)) {
((EntityPlayerMP) entityplayer).sendSlotContents(this, slotId, slot.getStack());
}
return;
}
if (slot instanceof DummySlot) {
((DummySlot) slot).setRedirectCall(true);
}
if (currentlyEquippedStack == null) {
if (slot.getStack() != null && mouseButton == 1) {
ItemStack tstack = slot.getStack();
if (isShift == 1) {
tstack.stackSize = Math.min(slot.getSlotStackLimit(), tstack.stackSize * 2);
} else {
tstack.stackSize /= 2;
if (tstack.stackSize <= 0) {
tstack = null;
}
}
slot.putStack(tstack);
} else {
slot.putStack(null);
}
if (slot instanceof DummySlot) {
((DummySlot) slot).setRedirectCall(false);
}
return;
}
if (!slot.getHasStack()) {
ItemStack tstack = currentlyEquippedStack.copy();
if (mouseButton == 1) {
tstack.stackSize = 1;
}
if (tstack.stackSize > slot.getSlotStackLimit()) {
tstack.stackSize = slot.getSlotStackLimit();
}
slot.putStack(tstack);
if (slot instanceof DummySlot) {
((DummySlot) slot).setRedirectCall(false);
}
return;
}
ItemIdentifier currentItem = ItemIdentifier.get(currentlyEquippedStack);
ItemIdentifier slotItem = ItemIdentifier.get(slot.getStack());
if (currentItem.equals(slotItem)) {
ItemStack tstack = slot.getStack();
// Do manual shift-checking to play nice with NEI
int counter = isShift == 1 ? 10 : 1;
if (mouseButton == 1) {
if (tstack.stackSize + counter <= slot.getSlotStackLimit()) {
tstack.stackSize += counter;
} else {
tstack.stackSize = slot.getSlotStackLimit();
}
slot.putStack(tstack);
} else if (mouseButton == 0) {
tstack.stackSize -= counter;
if (tstack.stackSize <= 0) {
tstack = null;
}
slot.putStack(tstack);
}
if (slot instanceof DummySlot) {
((DummySlot) slot).setRedirectCall(false);
}
return;
}
ItemStack tstack = currentlyEquippedStack.copy();
if (tstack.stackSize > slot.getSlotStackLimit()) {
tstack.stackSize = slot.getSlotStackLimit();
}
slot.putStack(tstack);
if (slot instanceof DummySlot) {
((DummySlot) slot).setRedirectCall(false);
}
return;
}
use of logisticspipes.utils.MinecraftColor in project LogisticsPipes by RS485.
the class DummyContainer method handleDummyClick.
public void handleDummyClick(Slot slot, int slotId, @Nonnull ItemStack currentlyEquippedStack, int mouseButton, ClickType shiftMode, EntityPlayer entityplayer) {
if (slot instanceof FluidSlot) {
if (!currentlyEquippedStack.isEmpty()) {
FluidIdentifier ident = FluidIdentifier.get(currentlyEquippedStack);
if (ident != null) {
if (mouseButton == 0) {
slot.putStack(ident.getItemIdentifier().unsafeMakeNormalStack(1));
} else {
slot.putStack(ItemStack.EMPTY);
}
return;
}
}
FluidIdentifier ident = null;
if (!slot.getStack().isEmpty()) {
ident = FluidIdentifier.get(ItemIdentifier.get(slot.getStack()));
}
if (ident == null) {
if (MainProxy.isClient(entityplayer.getEntityWorld())) {
MainProxy.proxy.openFluidSelectGui(slotId);
}
}
slot.putStack(ItemStack.EMPTY);
return;
}
if (slot instanceof ColorSlot) {
MinecraftColor equipped = MinecraftColor.getColor(currentlyEquippedStack);
MinecraftColor color = MinecraftColor.getColor(slot.getStack());
if (MinecraftColor.BLANK.equals(equipped)) {
if (mouseButton == 0) {
color = color.getNext();
} else if (mouseButton == 1) {
color = color.getPrev();
} else {
color = MinecraftColor.BLANK;
}
slot.putStack(color.getItemStack());
} else {
if (mouseButton == 1) {
slot.putStack(MinecraftColor.BLANK.getItemStack());
} else {
slot.putStack(equipped.getItemStack());
}
}
if (entityplayer instanceof EntityPlayerMP && MainProxy.isServer(entityplayer.world)) {
((EntityPlayerMP) entityplayer).sendSlotContents(this, slotId, slot.getStack());
}
return;
}
if (slot instanceof DummySlot) {
((DummySlot) slot).setRedirectCall(true);
}
if (mouseButton >= 1000) {
if (mouseButton <= 1001) {
if (slot.getHasStack()) {
ItemStack stack = slot.getStack().copy();
if (mouseButton == 1000) {
stack.grow(1);
} else if (stack.getCount() > 1) {
stack.shrink(1);
}
stack.setCount(Math.min(slot.getSlotStackLimit(), Math.max(1, stack.getCount())));
slot.putStack(stack);
}
if (slot instanceof DummySlot) {
((DummySlot) slot).setRedirectCall(false);
}
return;
}
}
if (currentlyEquippedStack.isEmpty()) {
if (!slot.getStack().isEmpty() && mouseButton == 1) {
ItemStack tstack = slot.getStack();
if (shiftMode == ClickType.QUICK_MOVE) {
tstack.setCount(Math.min(slot.getSlotStackLimit(), tstack.getCount() * 2));
} else {
tstack.setCount(tstack.getCount() / 2);
}
slot.putStack(tstack);
} else {
slot.putStack(ItemStack.EMPTY);
}
if (slot instanceof DummySlot) {
((DummySlot) slot).setRedirectCall(false);
}
return;
}
if (!slot.getHasStack()) {
ItemStack tstack = currentlyEquippedStack.copy();
if (mouseButton == 1) {
tstack.setCount(1);
}
if (tstack.getCount() > slot.getSlotStackLimit()) {
tstack.setCount(slot.getSlotStackLimit());
}
slot.putStack(tstack);
if (slot instanceof DummySlot) {
((DummySlot) slot).setRedirectCall(false);
}
return;
}
ItemIdentifier currentItem = ItemIdentifier.get(currentlyEquippedStack);
ItemIdentifier slotItem = ItemIdentifier.get(slot.getStack());
if (currentItem.equals(slotItem)) {
ItemStack tstack = slot.getStack();
// Do manual shift-checking to play nice with NEI
int counter = shiftMode == ClickType.QUICK_MOVE ? 10 : 1;
if (mouseButton == 1) {
if (tstack.getCount() + counter <= slot.getSlotStackLimit()) {
tstack.grow(counter);
} else {
tstack.setCount(slot.getSlotStackLimit());
}
slot.putStack(tstack);
} else if (mouseButton == 0) {
tstack.shrink(counter);
slot.putStack(tstack);
}
if (slot instanceof DummySlot) {
((DummySlot) slot).setRedirectCall(false);
}
return;
}
ItemStack tstack = currentlyEquippedStack.copy();
if (tstack.getCount() > slot.getSlotStackLimit()) {
tstack.setCount(slot.getSlotStackLimit());
}
slot.putStack(tstack);
if (slot instanceof DummySlot) {
((DummySlot) slot).setRedirectCall(false);
}
}
Aggregations