use of WayofTime.alchemicalWizardry.common.tileEntity.TEReagentConduit in project BloodMagic by WayofTime.
the class ItemAttunedCrystal method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
if (world.isRemote) {
return itemStack;
}
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, false);
if (movingobjectposition == null) {
if (player.isSneaking()) {
this.setHasSavedCoordinates(itemStack, false);
player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.clearing"));
}
return itemStack;
} else {
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
int x = movingobjectposition.blockX;
int y = movingobjectposition.blockY;
int z = movingobjectposition.blockZ;
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof IReagentHandler)) {
return itemStack;
}
IReagentHandler relay = (IReagentHandler) tile;
if (player.isSneaking()) {
ReagentContainerInfo[] infos = relay.getContainerInfo(ForgeDirection.UNKNOWN);
if (infos != null) {
List<Reagent> reagentList = new LinkedList();
for (ReagentContainerInfo info : infos) {
if (info != null) {
ReagentStack reagentStack = info.reagent;
if (reagentStack != null) {
Reagent reagent = reagentStack.reagent;
if (reagent != null) {
reagentList.add(reagent);
}
}
}
}
Reagent pastReagent = this.getReagent(itemStack);
if (reagentList.size() <= 0) {
return itemStack;
}
int reagentLocation;
reagentLocation = reagentList.indexOf(pastReagent);
if (reagentLocation == -1 || reagentLocation + 1 >= reagentList.size()) {
this.setReagentWithNotification(itemStack, reagentList.get(0), player);
} else {
this.setReagentWithNotification(itemStack, reagentList.get(reagentLocation + 1), player);
}
}
} else {
if (this.getHasSavedCoordinates(itemStack)) {
Int3 coords = this.getCoordinates(itemStack);
int dimension = this.getDimension(itemStack);
if (coords == null) {
return itemStack;
}
if (dimension != world.provider.dimensionId || Math.abs(coords.xCoord - x) > maxDistance || Math.abs(coords.yCoord - y) > maxDistance || Math.abs(coords.zCoord - z) > maxDistance) {
player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.error.toofar"));
return itemStack;
}
TileEntity pastTile = world.getTileEntity(coords.xCoord, coords.yCoord, coords.zCoord);
if (!(pastTile instanceof TEReagentConduit)) {
player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.error.cannotfind"));
return itemStack;
}
Reagent reagent = this.getReagent(itemStack);
if (reagent == null) {
return itemStack;
}
TEReagentConduit pastRelay = (TEReagentConduit) pastTile;
if (player.isSneaking()) {
pastRelay.removeReagentDestinationViaActual(reagent, x, y, z);
} else {
if (pastRelay.addReagentDestinationViaActual(reagent, x, y, z)) {
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("message.attunedcrystal.linked") + " " + reagent.name));
} else {
player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.error.noconnections"));
}
}
world.markBlockForUpdate(coords.xCoord, coords.yCoord, coords.zCoord);
} else {
int dimension = world.provider.dimensionId;
this.setDimension(itemStack, dimension);
this.setCoordinates(itemStack, new Int3(x, y, z));
player.addChatComponentMessage(new ChatComponentTranslation("message.attunedcrystal.linking"));
}
}
}
}
return itemStack;
}
use of WayofTime.alchemicalWizardry.common.tileEntity.TEReagentConduit in project BloodMagic by WayofTime.
the class RenderReagentConduit method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f) {
if (tileEntity instanceof TEReagentConduit) {
int renderCount = ((TEReagentConduit) tileEntity).renderCount;
float key1 = (tileEntity.xCoord * 54f - tileEntity.yCoord * 38.72f + tileEntity.zCoord * 10.432f);
float key2 = (tileEntity.xCoord * 21.43f - tileEntity.yCoord * 9.96f + tileEntity.zCoord * 12.8f);
Int3 colourMap = ((TEReagentConduit) tileEntity).getColour();
GL11.glPushMatrix();
Tessellator tessellator = Tessellator.instance;
this.bindTexture(field_110629_a);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDepthMask(false);
tessellator.startDrawingQuads();
tessellator.setColorRGBA(colourMap.xCoord, colourMap.yCoord, colourMap.zCoord, 200);
GL11.glTranslated(d0 + 0.5, d1 + 0.5, d2 + 0.5);
// Rotate on planar axis
GL11.glRotatef(tileEntity.getWorldObj().getWorldTime() / 3.0f, 0F, 1F, 0F);
// Rotate vertical axis
GL11.glRotatef(renderCount + key1, 0F, 0F, 1F);
// Rotate cylindrically
GL11.glRotatef(renderCount * 2f + key2, 1F, 0F, 0F);
tessellator.setBrightness(240);
tessellator.addVertexWithUV(-0.5d, 0, -0.5d, 0.0d, 0.0d);
tessellator.addVertexWithUV(0.5d, 0, -0.5d, 1.0d, 0.0d);
tessellator.addVertexWithUV(0.5d, 0, 0.5d, 1.0d, 1.0d);
tessellator.addVertexWithUV(-0.5d, 0, 0.5d, 0.0d, 1.0d);
tessellator.draw();
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
GL11.glPopMatrix();
}
}
use of WayofTime.alchemicalWizardry.common.tileEntity.TEReagentConduit in project BloodMagic by WayofTime.
the class ItemDestinationClearer method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
if (world.isRemote) {
return itemStack;
}
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, false);
if (movingobjectposition == null) {
return itemStack;
} else {
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
int x = movingobjectposition.blockX;
int y = movingobjectposition.blockY;
int z = movingobjectposition.blockZ;
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TEReagentConduit)) {
return itemStack;
}
TEReagentConduit relay = (TEReagentConduit) tile;
relay.reagentTargetList.clear();
player.addChatComponentMessage(new ChatComponentTranslation("message.destinationclearer.cleared"));
}
}
return itemStack;
}
Aggregations