use of net.minecraft.util.math.vector.Vector3i in project Overloaded by CJ-MC-Mods.
the class ItemMultiTool method rightClickWithItem.
public void rightClickWithItem(@Nonnull ServerPlayerEntity player, RightClickBlockMessage message) {
BlockPos pos = message.getPos();
Direction sideHit = message.getHitSide();
float hitX = message.getHitX();
float hitY = message.getHitY();
float hitZ = message.getHitZ();
ServerWorld worldIn = player.getLevel();
ItemStack multiTool = player.getMainHandItem();
if (multiTool.getItem() != this) {
return;
}
ItemStack blockStack = getSelectedBlockItemStack(multiTool);
if (blockStack.isEmpty()) {
player.displayClientMessage(new StringTextComponent("No block type selected to place."), true);
return;
}
if (!(blockStack.getItem() instanceof BlockItem)) {
player.displayClientMessage(new StringTextComponent("No valid block type selected to place."), true);
return;
}
LazyOptional<IEnergyStorage> opEnergy = multiTool.getCapability(ENERGY);
if (!opEnergy.isPresent()) {
Overloaded.logger.warn("MultiTool has no Energy Capability? NBT: " + multiTool.getTag());
return;
}
IEnergyStorage energy = opEnergy.orElseThrow(() -> new RuntimeException("Impossible Condition"));
Vector3i sideVector = sideHit.getNormal();
BlockPos.Mutable newPosition = pos.offset(sideVector).mutable();
switch(placeBlock(blockStack, player, worldIn, newPosition, sideHit, energy, hitX, hitY, hitZ)) {
case FAIL_PREREQUISITE:
player.displayClientMessage(new StringTextComponent("Do not have the required items"), true);
return;
case FAIL_DENY:
player.displayClientMessage(new StringTextComponent("Unable to place blocks"), true);
return;
case FAIL_RANGE:
player.displayClientMessage(new StringTextComponent("To far away"), true);
return;
case FAIL_ENERGY:
player.displayClientMessage(new StringTextComponent("Not enough energy"), true);
return;
case SUCCESS:
}
if (player.isShiftKeyDown()) {
BlockPos playerPos = player.blockPosition();
switch(sideHit) {
case UP:
while (newPosition.getY() < playerPos.getY()) {
newPosition.move(sideHit);
if (placeBlock(blockStack, player, worldIn, newPosition, sideHit, energy, hitX, hitY, hitZ) != BlockPlaceResult.SUCCESS)
break;
}
break;
case DOWN:
while (newPosition.getY() > playerPos.getY()) {
newPosition.move(sideHit);
if (placeBlock(blockStack, player, worldIn, newPosition, sideHit, energy, hitX, hitY, hitZ) != BlockPlaceResult.SUCCESS)
break;
}
break;
case NORTH:
while (newPosition.getZ() > playerPos.getZ()) {
newPosition.move(sideHit);
if (placeBlock(blockStack, player, worldIn, newPosition, sideHit, energy, hitX, hitY, hitZ) != BlockPlaceResult.SUCCESS)
break;
}
break;
case SOUTH:
while (newPosition.getZ() < playerPos.getZ()) {
newPosition.move(sideHit);
if (placeBlock(blockStack, player, worldIn, newPosition, sideHit, energy, hitX, hitY, hitZ) != BlockPlaceResult.SUCCESS)
break;
}
break;
case EAST:
while (newPosition.getX() < playerPos.getX()) {
newPosition.move(sideHit);
if (placeBlock(blockStack, player, worldIn, newPosition, sideHit, energy, hitX, hitY, hitZ) != BlockPlaceResult.SUCCESS)
break;
}
break;
case WEST:
while (newPosition.getX() > playerPos.getX()) {
newPosition.move(sideHit);
if (placeBlock(blockStack, player, worldIn, newPosition, sideHit, energy, hitX, hitY, hitZ) != BlockPlaceResult.SUCCESS)
break;
}
break;
}
}
}
use of net.minecraft.util.math.vector.Vector3i in project Overloaded by CJ-MC-Mods.
the class ModelUtils method renderQuads.
public static void renderQuads(List<BakedQuad> listQuads) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder vertexbuffer = tessellator.getBuilder();
int i = 0;
vertexbuffer.begin(7, DefaultVertexFormats.BLOCK);
for (int j = listQuads.size(); i < j; ++i) {
BakedQuad bakedquad = listQuads.get(i);
// vertexbuffer.putBulkData(bakedquad);
vertexbuffer.color(1, 1, 1, 1);
Vector3i vec3i = bakedquad.getDirection().getNormal();
vertexbuffer.normal((float) vec3i.getX(), (float) vec3i.getY(), (float) vec3i.getZ());
}
tessellator.end();
}
Aggregations