use of net.minecraft.util.math.Vec3i in project Wurst7 by Wurst-Imperium.
the class TreeBotHack method breakBlock.
private boolean breakBlock(BlockPos pos) {
Direction side = TreeBotUtils.getLineOfSightSide(RotationUtils.getEyesPos(), pos);
Vec3d relCenter = BlockUtils.getBoundingBox(pos).offset(-pos.getX(), -pos.getY(), -pos.getZ()).getCenter();
Vec3d center = Vec3d.of(pos).add(relCenter);
Vec3i dirVec = side.getVector();
Vec3d relHitVec = new Vec3d(relCenter.x * dirVec.getX(), relCenter.y * dirVec.getY(), relCenter.z * dirVec.getZ());
Vec3d hitVec = center.add(relHitVec);
// face block
WURST.getRotationFaker().faceVectorPacket(hitVec);
// damage block
if (!MC.interactionManager.updateBlockBreakingProgress(pos, side))
return false;
// swing arm
MC.player.networkHandler.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
return true;
}
use of net.minecraft.util.math.Vec3i in project Spelunker by Leximon.
the class ChunkOres method remapToWorldCoordinates.
/**
* remaps all local coordinates to world coordinates
* @param bottomSectionCord the bottom section cord of the world
* @return this
*/
public ChunkOres remapToWorldCoordinates(int bottomSectionCord) {
remapped = true;
HashMap<Vec3i, Block> clone = new HashMap<>(this);
clear();
for (Map.Entry<Vec3i, Block> pair : clone.entrySet()) {
Vec3i p = pair.getKey();
put(new Vec3i(ChunkSectionPos.getBlockCoord(pos.getX()) + p.getX(), ChunkSectionPos.getBlockCoord(pos.getY() + bottomSectionCord) + p.getY(), ChunkSectionPos.getBlockCoord(pos.getZ()) + p.getZ()), pair.getValue());
}
return this;
}
use of net.minecraft.util.math.Vec3i in project Spelunker by Leximon.
the class PlayerEntityMixin method moveEndInject.
@Inject(method = "tick", at = @At("HEAD"))
private void moveEndInject(CallbackInfo ci) {
if (!hasStatusEffect(SpelunkerMod.STATUS_EFFECT_SPELUNKER)) {
if (!spelunkerEffectChunks.isEmpty())
spelunkerEffectChunks.clear();
forceOreChunkUpdate = true;
return;
}
if (SpelunkerConfig.serverValidating && world.isClient())
return;
int cx = ChunkSectionPos.getSectionCoord(getX());
int cy = ChunkSectionPos.getSectionCoord(getY());
int cz = ChunkSectionPos.getSectionCoord(getZ());
// update if player crosses chunk border
if (cx != lastCx || cy != lastCy || cz != lastCz || forceOreChunkUpdate) {
forceOreChunkUpdate = false;
HashMap<Vec3i, ChunkSection> newChunks = SpelunkerEffectManager.getSurroundingChunkSections(world, getPos());
// calc difference and find ores
HashSet<Vec3i> remove = new HashSet<>();
spelunkerEffectChunks.removeIf(p -> {
if (!newChunks.containsKey(p)) {
remove.add(p);
return true;
}
return false;
});
ArrayList<ChunkOres> add = new ArrayList<>();
for (Map.Entry<Vec3i, ChunkSection> section : newChunks.entrySet()) {
Vec3i pos = section.getKey();
if (!spelunkerEffectChunks.contains(pos)) {
add.add(SpelunkerEffectManager.findOresInChunk(world, pos));
spelunkerEffectChunks.add(pos);
}
}
// handle new and removed chunk sections
if (world.isClient()) {
SpelunkerModClient.spelunkerEffectRenderer.updateChunks(world, remove, add);
} else if (SpelunkerConfig.serverValidating) {
PacketByteBuf buf = SpelunkerEffectManager.writePacket(world, true, remove, add);
ServerPlayNetworking.send((ServerPlayerEntity) (Object) this, SpelunkerMod.PACKET_ORE_CHUNKS, buf);
}
}
lastCx = cx;
lastCy = cy;
lastCz = cz;
}
use of net.minecraft.util.math.Vec3i in project Zone by wje5.
the class ObjHandler method renderQuads.
public static void renderQuads(List<BakedQuad> listQuads) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
int i = 0;
for (int j = listQuads.size(); i < j; ++i) {
BakedQuad bakedquad = listQuads.get(i);
bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
bufferbuilder.addVertexData(bakedquad.getVertexData());
// if (bakedquad.hasTintIndex()) {
// bufferbuilder.putColorRGB_F4(red * brightness, green * brightness, blue * brightness);
// } else {
// bufferbuilder.putColorRGB_F4(brightness, brightness, brightness);
// }
Vec3i vec3i = bakedquad.getFace().getDirectionVec();
bufferbuilder.putNormal(vec3i.getX(), vec3i.getY(), vec3i.getZ());
tessellator.draw();
}
}
use of net.minecraft.util.math.Vec3i in project tetra by mickelus.
the class ExtendedStructureTESR method renderChild.
private void renderChild(FeatureChild featureChild, MatrixStack matrixStack, IVertexBuilder vertexBuilder, double x, double y, double z) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
BlockPos offset = featureChild.offset;
AxisAlignedBB aabb = new AxisAlignedBB(x + offset.getX() + 0.5, y + offset.getY() + 0.5, z + offset.getZ() + 0.5, x + offset.getX() + 0.5, y + offset.getY() + 0.5, z + offset.getZ() + 0.5);
// build outline box
WorldRenderer.drawBoundingBox(matrixStack, vertexBuilder, aabb.grow(0.5020000000949949026D), 1, 1, 0, 1);
// build arrow
bufferBuilder.begin(3, DefaultVertexFormats.POSITION_COLOR);
Vec3i facing = featureChild.facing.getDirectionVec();
bufferBuilder.pos(x + offset.getX() + 0.5, y + offset.getY() + 0.5, z + offset.getZ() + 0.5).color(0.0F, 0.0F, 0.0F, 0.0F).endVertex();
bufferBuilder.pos(x + offset.getX() + 0.5 + 0.3 * facing.getX(), y + offset.getY() + 0.5 + 0.3 * facing.getY(), z + offset.getZ() + 0.5 + 0.3 * facing.getZ()).color(1, 1, 1, 1.0F).endVertex();
tessellator.draw();
// draw middle block
DebugRenderer.renderBox(aabb.grow(0.1), 0, 0, 0, 0.8f);
}
Aggregations