use of net.minecraft.util.math.Vec2f in project DynamicSurroundings by OreCruncher.
the class LightLevelHUD method textureRender.
private static void textureRender(final EntityPlayer player, final RenderManager manager) {
final boolean isThirdPerson = manager.options.thirdPersonView == 2;
EnumFacing playerFacing = player.getHorizontalFacing();
if (isThirdPerson)
playerFacing = playerFacing.getOpposite();
final float rotationAngle = playerFacing.getOpposite().getHorizontalAngle();
sheet.bindTexture();
final BufferBuilder renderer = Tessellator.getInstance().getBuffer();
for (int i = 0; i < nextCoord; i++) {
final LightCoord coord = lightLevels.get(i);
final double x = coord.x - manager.viewerPosX;
final double y = coord.y - manager.viewerPosY;
final double z = coord.z - manager.viewerPosZ;
final Vec2f U = sheet.getMinMaxU(coord.lightLevel);
final Vec2f V = sheet.getMinMaxV(coord.lightLevel);
GlStateManager.pushMatrix();
GlStateManager.translate(x + 0.5D, y, z + 0.5D);
GlStateManager.rotate(-rotationAngle, 0F, 1F, 0F);
GlStateManager.translate(-0.5D, 0.0005D, -0.5D);
GlStateManager.rotate(90F, 1F, 0F, 0F);
final float red = coord.color.red;
final float green = coord.color.green;
final float blue = coord.color.blue;
final float alpha = ColorSet.ALPHA;
renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
renderer.pos(0F, 1F, 0F).tex(U.x, V.x).color(red, green, blue, alpha).endVertex();
renderer.pos(1F, 1F, 0F).tex(U.y, V.x).color(red, green, blue, alpha).endVertex();
renderer.pos(1F, 0F, 0F).tex(U.y, V.y).color(red, green, blue, alpha).endVertex();
renderer.pos(0F, 0F, 0F).tex(U.x, V.y).color(red, green, blue, alpha).endVertex();
Tessellator.getInstance().draw();
GlStateManager.popMatrix();
}
}
use of net.minecraft.util.math.Vec2f in project BloodMagic by WayofTime.
the class AlchemyArrayEffectArrowTurret method update.
@Override
public boolean update(TileEntity tile, int ticksActive) {
BlockPos pos = tile.getPos();
World world = tile.getWorld();
BlockPos chestPos = pos.down();
TileEntity chestTile = world.getTileEntity(chestPos);
if (chestTile == null) {
return false;
}
IItemHandler itemHandler = Utils.getInventory(chestTile, EnumFacing.UP);
if (itemHandler == null) {
return false;
}
ItemStack arrowStack = new ItemStack(Items.AIR);
if (lastChestSlot >= 0 && lastChestSlot < itemHandler.getSlots()) {
ItemStack testStack = itemHandler.extractItem(lastChestSlot, 1, true);
if (testStack.isEmpty() || !(testStack.getItem() instanceof ItemArrow)) {
lastChestSlot = -1;
} else {
arrowStack = testStack;
}
}
if (lastChestSlot < 0) {
for (int i = 0; i < itemHandler.getSlots(); i++) {
ItemStack testStack = itemHandler.extractItem(i, 1, true);
if (!testStack.isEmpty() && testStack.getItem() instanceof ItemArrow) {
arrowStack = testStack;
lastChestSlot = i;
break;
}
}
}
if (lastChestSlot < 0) {
// No arrows in the chest. Welp!
return false;
}
if (canFireOnMob(world, pos, target)) {
Vec2f pitchYaw = getPitchYaw(pos, target);
lastPitch = pitch;
lastYaw = yaw;
pitch = pitchYaw.x;
yaw = pitchYaw.y;
arrowTimer++;
if (arrowTimer >= ARROW_WINDUP) {
// ItemStack arrowStack = new ItemStack(Items.ARROW);
fireOnTarget(world, pos, arrowStack, target);
if (!world.isRemote) {
itemHandler.extractItem(lastChestSlot, 1, false);
}
arrowTimer = 0;
}
return false;
} else {
target = null;
arrowTimer = -1;
}
List<EntityMob> mobsInRange = world.getEntitiesWithinAABB(EntityMob.class, getBounds(pos));
for (EntityMob entity : mobsInRange) {
if (// && isMobInFilter(ent))
canFireOnMob(world, pos, entity)) {
target = entity;
arrowTimer = 0;
return false;
}
}
arrowTimer = -1;
target = null;
return false;
}
Aggregations