use of net.minecraft.entity.player.EntityPlayer in project LogisticsPipes by RS485.
the class PipeController method getContainer.
@Override
public DummyContainer getContainer(EntityPlayer player) {
LogisticsTileGenericPipe tile = getPipe(player.getEntityWorld());
if (tile == null || !(tile.pipe instanceof CoreRoutedPipe)) {
return null;
}
final CoreRoutedPipe pipe = (CoreRoutedPipe) tile.pipe;
DummyContainer dummy = new DummyContainer(player, null, pipe.getOriginalUpgradeManager().getGuiController(), new IGuiOpenControler() {
//Network Statistics
@Override
public void guiOpenedByPlayer(EntityPlayer player) {
pipe.playerStartWatching(player, 0);
}
@Override
public void guiClosedByPlayer(EntityPlayer player) {
pipe.playerStopWatching(player, 0);
}
});
dummy.addNormalSlotsForPlayerInventory(0, 0);
// TAB_1 SLOTS
for (int pipeSlot = 0; pipeSlot < 9; pipeSlot++) {
dummy.addUpgradeSlot(pipeSlot, pipe.getOriginalUpgradeManager(), pipeSlot, 8 + pipeSlot * 18, 18, itemStack -> {
if (itemStack == null) {
return false;
}
if (itemStack.getItem() == LogisticsPipes.UpgradeItem) {
if (!LogisticsPipes.UpgradeItem.getUpgradeForItem(itemStack, null).isAllowedForPipe(pipe)) {
return false;
}
} else {
return false;
}
return true;
});
}
for (int pipeSlot = 0; pipeSlot < 9; pipeSlot++) {
dummy.addSneakyUpgradeSlot(pipeSlot, pipe.getOriginalUpgradeManager(), pipeSlot + 9, 8 + pipeSlot * 18, 48, itemStack -> {
if (itemStack == null) {
return false;
}
if (itemStack.getItem() == LogisticsPipes.UpgradeItem) {
IPipeUpgrade upgrade = LogisticsPipes.UpgradeItem.getUpgradeForItem(itemStack, null);
if (!(upgrade instanceof SneakyUpgrade) && !(upgrade instanceof SneakyUpgradeConfig)) {
return false;
}
if (!upgrade.isAllowedForPipe(pipe)) {
return false;
}
} else {
return false;
}
return true;
});
}
// TAB_2 SLOTS
dummy.addStaticRestrictedSlot(0, pipe.getOriginalUpgradeManager().getSecInv(), 8 + 8 * 18, 18, itemStack -> {
if (itemStack == null) {
return false;
}
if (itemStack.getItem() != LogisticsPipes.LogisticsItemCard) {
return false;
}
if (itemStack.getItemDamage() != LogisticsItemCard.SEC_CARD) {
return false;
}
return SimpleServiceLocator.securityStationManager.isAuthorized(UUID.fromString(itemStack.getTagCompound().getString("UUID")));
}, 1);
dummy.addRestrictedSlot(0, tile.logicController.diskInv, 14, 36, LogisticsPipes.LogisticsItemDisk);
return dummy;
}
use of net.minecraft.entity.player.EntityPlayer in project LogisticsPipes by RS485.
the class ImmibisCraftingTableMk2 method importRecipe.
@Override
public boolean importRecipe(TileEntity tile, ItemIdentifierInventory inventory) {
try {
if (tileAutoCraftingMk2.isInstance(tile)) {
// Import recipeInputs
ItemStack[][] recipe = (ItemStack[][]) tileAutoCraftingMk2.getField("recipeInputs").get(tile);
// Not really a AutoCraftingInventory, but same content
InventoryCrafting tempCraftingInv = new InventoryCrafting(new Container() {
@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return false;
}
@Override
public void onCraftMatrixChanged(IInventory par1iInventory) {
}
}, 3, 3);
for (int i = 0; i < 9; i++) {
if (recipe[i].length > 0) {
tempCraftingInv.setInventorySlotContents(i, recipe[i][0]);
inventory.setInventorySlotContents(i, recipe[i][0]);
} else {
inventory.clearInventorySlotContents(i);
}
}
// Compact
int slotCount = 0;
for (int i = 0; i < 9; i++) {
ItemStack slotStack = inventory.getStackInSlot(i);
inventory.clearInventorySlotContents(i);
if (slotStack != null && slotStack.getItem() != null) {
int count = 1;
for (int j = i + 1; j < 9; j++) {
ItemStack tempStack = inventory.getStackInSlot(j);
if (tempStack != null && ItemIdentifier.get(slotStack).equals(ItemIdentifier.get(tempStack))) {
inventory.clearInventorySlotContents(j);
count++;
}
}
slotStack.stackSize = count;
inventory.setInventorySlotContents(slotCount, slotStack);
slotCount++;
}
}
ItemStack result = null;
for (IRecipe r : CraftingUtil.getRecipeList()) {
if (r.matches(tempCraftingInv, tile.getWorldObj())) {
result = r.getCraftingResult(tempCraftingInv);
break;
}
}
inventory.setInventorySlotContents(9, result);
return true;
}
} catch (IllegalArgumentException | NoSuchFieldException e) {
LogisticsPipes.log.fatal("Error while importing recipe from Tubestuff's AutoCraftingMk2");
e.printStackTrace();
} catch (Exception e) {
LogisticsPipes.log.error("Got a problem on ImmibisCraftingTableMk2 CraftingRecipeProvider:");
LogisticsPipes.log.error(e.getMessage());
}
return false;
}
use of net.minecraft.entity.player.EntityPlayer in project LogisticsPipes by RS485.
the class MainProxy method sendToPlayerList.
public static void sendToPlayerList(ModernPacket packet, Iterable<EntityPlayer> players) {
if (!MainProxy.isServer()) {
System.err.println("sendToPlayerList called clientside !");
new Exception().printStackTrace();
return;
}
if (packet.isCompressable() || MainProxy.needsToBeCompressed(packet)) {
for (EntityPlayer player : players) {
SimpleServiceLocator.serverBufferHandler.addPacketToCompressor(packet, player);
}
} else {
for (EntityPlayer player : players) {
MainProxy.sendPacketToPlayer(packet, player);
}
}
}
use of net.minecraft.entity.player.EntityPlayer in project LogisticsPipes by RS485.
the class LogisticsHUDRenderer method renderWorldRelative.
public void renderWorldRelative(long renderTicks, float partialTick) {
if (!displayRenderer()) {
return;
}
Minecraft mc = FMLClientHandler.instance().getClient();
EntityPlayer player = mc.thePlayer;
if (list.size() == 0 || Math.hypot(lastXPos - player.posX, Math.hypot(lastYPos - player.posY, lastZPos - player.posZ)) > 0.5 || (renderTicks % 10 == 0 && (lastXPos != player.posX || lastYPos != player.posY || lastZPos != player.posZ)) || renderTicks % 600 == 0) {
refreshList(player.posX, player.posY, player.posZ);
lastXPos = player.posX;
lastYPos = player.posY;
lastZPos = player.posZ;
}
boolean cursorHandled = false;
displayCross = false;
IHUDConfig config;
if (debugHUD == null) {
config = new HUDConfig(mc.thePlayer.inventory.armorInventory[3]);
} else {
config = new IHUDConfig() {
@Override
public boolean isHUDSatellite() {
return false;
}
@Override
public boolean isHUDProvider() {
return false;
}
@Override
public boolean isHUDPowerLevel() {
return false;
}
@Override
public boolean isHUDInvSysCon() {
return false;
}
@Override
public boolean isHUDCrafting() {
return false;
}
@Override
public boolean isHUDChassie() {
return false;
}
@Override
public void setHUDChassie(boolean state) {
}
@Override
public void setHUDCrafting(boolean state) {
}
@Override
public void setHUDInvSysCon(boolean state) {
}
@Override
public void setHUDPowerJunction(boolean state) {
}
@Override
public void setHUDProvider(boolean state) {
}
@Override
public void setHUDSatellite(boolean state) {
}
};
}
IHeadUpDisplayRendererProvider thisIsLast = null;
List<IHeadUpDisplayRendererProvider> toUse = list;
if (debugHUD != null) {
toUse = debugHUD.getHUDs();
}
for (IHeadUpDisplayRendererProvider renderer : toUse) {
if (renderer.getRenderer() == null) {
continue;
}
if (renderer.getRenderer().display(config)) {
GL11.glPushMatrix();
if (!cursorHandled) {
double x = renderer.getX() + 0.5 - player.posX;
double y = renderer.getY() + 0.5 - player.posY;
double z = renderer.getZ() + 0.5 - player.posZ;
if (Math.hypot(x, Math.hypot(y, z)) < 0.75 || (renderer instanceof IHeadUpDisplayBlockRendererProvider && (((IHeadUpDisplayBlockRendererProvider) renderer).isHUDInvalid() || !((IHeadUpDisplayBlockRendererProvider) renderer).isHUDExistent()))) {
refreshList(player.posX, player.posY, player.posZ);
GL11.glPopMatrix();
break;
}
int[] pos = getCursor(renderer);
if (pos.length == 2) {
if (renderer.getRenderer().cursorOnWindow(pos[0], pos[1])) {
renderer.getRenderer().handleCursor(pos[0], pos[1]);
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
//if(FMLClientHandler.instance().getClient().thePlayer.isSneaking()) {
thisIsLast = renderer;
displayCross = true;
}
cursorHandled = true;
}
}
}
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (thisIsLast != renderer) {
displayOneView(renderer, config, partialTick, false);
}
GL11.glPopMatrix();
}
}
if (thisIsLast != null) {
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_DEPTH_TEST);
displayOneView(thisIsLast, config, partialTick, true);
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glPopMatrix();
}
GL11.glPushMatrix();
MovingObjectPosition box = mc.objectMouseOver;
if (box != null && box.typeOfHit == MovingObjectType.BLOCK) {
if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
progress = Math.min(progress + (2 * Math.max(1, (int) Math.floor((System.currentTimeMillis() - last) / 50.0D))), 100);
} else {
progress = Math.max(progress - (2 * Math.max(1, (int) Math.floor((System.currentTimeMillis() - last) / 50.0D))), 0);
}
if (progress != 0) {
List<String> textData = new ArrayList<>();
if (textData.isEmpty()) {
textData = SimpleServiceLocator.neiProxy.getInfoForPosition(player.worldObj, player, box);
}
if (!textData.isEmpty()) {
double xCoord = box.blockX + 0.5D;
double yCoord = box.blockY + 0.5D;
double zCoord = box.blockZ + 0.5D;
double x = xCoord - player.prevPosX - ((player.posX - player.prevPosX) * partialTick);
double y = yCoord - player.prevPosY - ((player.posY - player.prevPosY) * partialTick);
double z = zCoord - player.prevPosZ - ((player.posZ - player.prevPosZ) * partialTick);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glTranslatef((float) x, (float) y, (float) z);
GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(getAngle(z, x) + 110F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef((-1) * getAngle(Math.hypot(x + 0.8, z + 0.8), y + 0.5) + 180, 1.0F, 0.0F, 0.0F);
double dProgress = progress / 100D;
GL11.glTranslated(0.4D * dProgress + 0.6D, -0.2D * dProgress - 0.6D, -0.0D);
GL11.glScalef(0.01F, 0.01F, 1F);
int heigth = Math.max(32, 10 * textData.size() + 15);
int width = 0;
for (String s : textData) {
width = Math.max(width, mc.fontRenderer.getStringWidth(s) + 22);
}
width = Math.max(32, width + 15);
GL11.glColor4b((byte) 127, (byte) 127, (byte) 127, (byte) 96);
GuiGraphics.drawGuiBackGround(mc, (int) ((-0.5 * (width - 32)) * dProgress) - 16, (int) ((-0.5 * (heigth - 32)) * dProgress) - 16, (int) ((0.5 * (width - 32)) * dProgress) + 16, (int) ((0.5 * (heigth - 32)) * dProgress) + 16, 0, false);
GL11.glColor4b((byte) 127, (byte) 127, (byte) 127, (byte) 127);
if (progress == 100) {
GL11.glTranslated((int) ((-0.5 * (width - 32)) * dProgress) - 16, (int) ((-0.5 * (heigth - 32)) * dProgress) - 16, -0.0001D);
for (int i = 0; i < textData.size(); i++) {
mc.fontRenderer.drawString(textData.get(i), 28, 8 + i * 10, 0x000000);
}
ItemStack item = SimpleServiceLocator.neiProxy.getItemForPosition(player.worldObj, player, box);
if (item != null) {
float scaleX = 1.5F * 0.8F;
float scaleY = 1.5F * 0.8F;
float scaleZ = -0.0001F;
GL11.glScalef(scaleX, scaleY, scaleZ);
ItemStackRenderer itemStackRenderer = new ItemStackRenderer(5, 6, 0.0F, false, true, true);
itemStackRenderer.setItemstack(item).setDisplayAmount(DisplayAmount.NEVER);
itemStackRenderer.setScaleX(scaleX).setScaleY(scaleY).setScaleZ(scaleZ);
itemStackRenderer.renderInGui();
}
}
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
}
} else if (!Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
progress = 0;
}
GL11.glPopMatrix();
//Render Laser
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
//GL11.glEnable(GL11.GL_LIGHTING);
for (LaserData data : lasers) {
GL11.glPushMatrix();
double x = data.getPosX() + 0.5 - player.prevPosX - ((player.posX - player.prevPosX) * partialTick);
double y = data.getPosY() + 0.5 - player.prevPosY - ((player.posY - player.prevPosY) * partialTick);
double z = data.getPosZ() + 0.5 - player.prevPosZ - ((player.posZ - player.prevPosZ) * partialTick);
GL11.glTranslatef((float) x, (float) y, (float) z);
switch(data.getDir()) {
case NORTH:
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
break;
case SOUTH:
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
break;
case EAST:
break;
case WEST:
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
break;
case UP:
GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
break;
case DOWN:
GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F);
break;
default:
break;
}
GL11.glScalef(0.01F, 0.01F, 0.01F);
Tessellator tessellator = Tessellator.instance;
for (float i = 0; i < 6 * data.getLength(); i++) {
setColor(i, data.getConnectionType());
float shift = 100f * i / 6f;
float start = 0.0f;
if (data.isStartPipe() && i == 0) {
start = -6.0f;
}
tessellator.startDrawingQuads();
tessellator.addVertex(19.7f + shift, 3.0f, -3.0f);
tessellator.addVertex(3.0f + shift + start, 3.0f, -3.0f);
tessellator.addVertex(3.0f + shift + start, 3.0f, 3.0f);
tessellator.addVertex(19.7f + shift, 3.0f, 3.0f);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.addVertex(19.7f + shift, -3.0f, 3.0f);
tessellator.addVertex(3.0f + shift + start, -3.0f, 3.0f);
tessellator.addVertex(3.0f + shift + start, -3.0f, -3.0f);
tessellator.addVertex(19.7f + shift, -3.0f, -3.0f);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.addVertex(19.7f + shift, 3.0f, 3.0f);
tessellator.addVertex(3.0f + shift + start, 3.0f, 3.0f);
tessellator.addVertex(3.0f + shift + start, -3.0f, 3.0f);
tessellator.addVertex(19.7f + shift, -3.0f, 3.0f);
tessellator.draw();
tessellator.startDrawingQuads();
tessellator.addVertex(19.7f + shift, -3.0f, -3.0f);
tessellator.addVertex(3.0f + shift + start, -3.0f, -3.0f);
tessellator.addVertex(3.0f + shift + start, 3.0f, -3.0f);
tessellator.addVertex(19.7f + shift, 3.0f, -3.0f);
tessellator.draw();
}
if (data.isStartPipe()) {
setColor(0, data.getConnectionType());
tessellator.startDrawingQuads();
tessellator.addVertex(-3.0f, 3.0f, 3.0f);
tessellator.addVertex(-3.0f, 3.0f, -3.0f);
tessellator.addVertex(-3.0f, -3.0f, -3.0f);
tessellator.addVertex(-3.0f, -3.0f, 3.0f);
tessellator.draw();
}
if (data.isFinalPipe()) {
setColor(6 * data.getLength() - 1, data.getConnectionType());
tessellator.startDrawingQuads();
tessellator.addVertex(100.0f * data.getLength() + 3f, 3.0f, -3.0f);
tessellator.addVertex(100.0f * data.getLength() + 3f, 3.0f, 3.0f);
tessellator.addVertex(100.0f * data.getLength() + 3f, -3.0f, 3.0f);
tessellator.addVertex(100.0f * data.getLength() + 3f, -3.0f, -3.0f);
tessellator.draw();
}
GL11.glPopMatrix();
}
GL11.glEnable(GL11.GL_TEXTURE_2D);
last = System.currentTimeMillis();
}
use of net.minecraft.entity.player.EntityPlayer in project LogisticsPipes by RS485.
the class LogisticsHUDRenderer method getCursor.
private int[] getCursor(IHeadUpDisplayRendererProvider renderer) {
Minecraft mc = FMLClientHandler.instance().getClient();
EntityPlayer player = mc.thePlayer;
Vector3d playerView = Vector3d.getFromAngles((270 - player.rotationYaw) / 360 * -2 * Math.PI, (player.rotationPitch) / 360 * -2 * Math.PI);
Vector3d playerPos = new Vector3d();
playerPos.x = player.posX;
playerPos.y = player.posY;
playerPos.z = player.posZ;
Vector3d panelPos = new Vector3d();
panelPos.x = renderer.getX() + 0.5;
panelPos.y = renderer.getY() + 0.5;
panelPos.z = renderer.getZ() + 0.5;
Vector3d panelView = new Vector3d();
panelView.x = playerPos.x - panelPos.x;
panelView.y = playerPos.y - panelPos.y;
panelView.z = playerPos.z - panelPos.z;
panelPos.add(panelView, 0.44D);
double d = panelPos.x * panelView.x + panelPos.y * panelView.y + panelPos.z * panelView.z;
double c = panelView.x * playerPos.x + panelView.y * playerPos.y + panelView.z * playerPos.z;
double b = panelView.x * playerView.x + panelView.y * playerView.y + panelView.z * playerView.z;
double a = (d - c) / b;
Vector3d viewPos = new Vector3d();
viewPos.x = playerPos.x + a * playerView.x - panelPos.x;
viewPos.y = playerPos.y + a * playerView.y - panelPos.y;
viewPos.z = playerPos.z + a * playerView.z - panelPos.z;
Vector3d panelScalVector1 = new Vector3d();
if (panelView.y == 0) {
panelScalVector1.x = 0;
panelScalVector1.y = 1;
panelScalVector1.z = 0;
} else {
panelScalVector1 = panelView.getOrtogonal(-panelView.x, null, -panelView.z).makeVectorLength(1.0D);
}
Vector3d panelScalVector2 = new Vector3d();
if (panelView.z == 0) {
panelScalVector2.x = 0;
panelScalVector2.y = 0;
panelScalVector2.z = 1;
} else {
panelScalVector2 = panelView.getOrtogonal(1.0D, 0.0D, null).makeVectorLength(1.0D);
}
if (panelScalVector1.y == 0) {
return new int[] {};
}
double cursorY = -viewPos.y / panelScalVector1.y;
Vector3d restViewPos = viewPos.clone();
restViewPos.x += cursorY * panelScalVector1.x;
restViewPos.y = 0;
restViewPos.z += cursorY * panelScalVector1.z;
double cursorX;
if (panelScalVector2.x == 0) {
cursorX = restViewPos.z / panelScalVector2.z;
} else {
cursorX = restViewPos.x / panelScalVector2.x;
}
cursorX *= 50 / 0.47D;
cursorY *= 50 / 0.47D;
if (panelView.z < 0) {
cursorX *= -1;
}
if (panelView.y < 0) {
cursorY *= -1;
}
return new int[] { (int) cursorX, (int) cursorY };
}
Aggregations