本文整理匯總了Java中net.minecraft.util.math.Vec3i類的典型用法代碼示例。如果您正苦於以下問題:Java Vec3i類的具體用法?Java Vec3i怎麽用?Java Vec3i使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Vec3i類屬於net.minecraft.util.math包,在下文中一共展示了Vec3i類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: viewToFaceVec
import net.minecraft.util.math.Vec3i; //導入依賴的package包/類
public static Vec3i viewToFaceVec(Vec3d viewVector, double length)
{
//normalize vector so we can work with it better
viewVector = viewVector.normalize();
int majorAxis = 0;
if(Math.abs(viewVector.yCoord)>=Math.abs(viewVector.xCoord) && Math.abs(viewVector.yCoord)>=Math.abs(viewVector.zCoord)) majorAxis=1;
else if(Math.abs(viewVector.zCoord)>=Math.abs(viewVector.xCoord) && Math.abs(viewVector.zCoord)>=Math.abs(viewVector.yCoord)) majorAxis=2;
length = Math.round(length);
switch(majorAxis)
{
case 0:
return new Vec3i(Math.signum(viewVector.xCoord)*length,0,0);
case 1:
return new Vec3i(0,Math.signum(viewVector.yCoord)*length,0);
case 2:
return new Vec3i(0,0,Math.signum(viewVector.zCoord)*length);
default:
break;
}
return new Vec3i(1,0,0);
}
示例2: move
import net.minecraft.util.math.Vec3i; //導入依賴的package包/類
@Override
public void move(MoverType type, double x, double y, double z)
{
if (this.freezeTime <= 0)
{
Vec3i oldPos = new Vec3i((int) Math.floor(this.getPosition().getX()),
(int) Math.floor(this.getPosition().getY()), (int) Math.floor(this.getPosition().getZ()));
super.move(type, x, y, z);
Vec3i newPos = new Vec3i((int) Math.floor(this.getPosition().getX()),
(int) Math.floor(this.getPosition().getY()), (int) Math.floor(this.getPosition().getZ()));
if (!oldPos.equals(newPos))
{
if (world.getBlockState(new BlockPos(oldPos)).getBlock() == ModRegistry.FANCY_LIGHT)
{
world.setBlockToAir(new BlockPos(oldPos));
}
if (world.getBlockState(new BlockPos(newPos)).getBlock() == Blocks.AIR)
{
world.setBlockState(new BlockPos(newPos), ModRegistry.FANCY_LIGHT.getDefaultState());
}
}
} else
{
}
}
示例3: onWorldDraw
import net.minecraft.util.math.Vec3i; //導入依賴的package包/類
@Override
protected void onWorldDraw(float delta, float x, float y, float z) {
float mx, my, mz;
if (!safeShow) return;
if (--safeUpdate < 0) {
safeUpdate = 13;
reCheckSafe(fix(x), fix(y), fix(z));
}
if (safeGhost) GL11.glDisable(GL11.GL_DEPTH_TEST);
else GL11.glEnable( GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_FOG);
GL11.glBegin(GL11.GL_LINES);
for (int i = 0; i < safeCur; ++i) {
Vec3i pos = safePoses[i];
Color color = safeMarks[i];
GL11.glColor3ub(color.rb, color.gb, color.bb);
mx = pos.getX() - x; my = pos.getY() - y; mz = pos.getZ() - z;
GL11.glVertex3f(mx+0.9f,my+0.01f,mz+0.9f);
GL11.glVertex3f(mx+0.1f,my+0.01f,mz+0.1f);
GL11.glVertex3f(mx+0.9f,my+0.01f,mz+0.1f);
GL11.glVertex3f(mx+0.1f,my+0.01f,mz+0.9f);
}
GL11.glEnd();
}
示例4: renderModelBrightnessColorQuads
import net.minecraft.util.math.Vec3i; //導入依賴的package包/類
private void renderModelBrightnessColorQuads(float brightness, float red, float green, float blue, List<BakedQuad> listQuads)
{
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexbuffer = tessellator.getBuffer();
int i = 0;
for (int j = listQuads.size(); i < j; ++i)
{
BakedQuad bakedquad = (BakedQuad)listQuads.get(i);
vertexbuffer.begin(7, DefaultVertexFormats.ITEM);
vertexbuffer.addVertexData(bakedquad.getVertexData());
if (bakedquad.hasTintIndex())
{
vertexbuffer.putColorRGB_F4(red * brightness, green * brightness, blue * brightness);
}
else
{
vertexbuffer.putColorRGB_F4(brightness, brightness, brightness);
}
Vec3i vec3i = bakedquad.getFace().getDirectionVec();
vertexbuffer.putNormal((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
tessellator.draw();
}
}
示例5: getStoneTypeAt
import net.minecraft.util.math.Vec3i; //導入依賴的package包/類
public static EnumRockClass getStoneTypeAt(World w, BlockPos at)
{
if (lastRememberedSeed != w.getSeed())
{
rand.setSeed(w.getSeed());
offsetStone = new Vec3i(rand.nextInt(300000) - rand.nextInt(300000), 0, rand.nextInt(300000) - rand.nextInt(300000));
offsetDirt = new Vec3i(rand.nextInt(300000) - rand.nextInt(300000), 0, rand.nextInt(300000) - rand.nextInt(300000));
}
BlockPos actual = at.add(offsetStone);
try
{
FeatureProvider provider = ((BiomeProviderExP)w.getBiomeProvider()).featureProvider;
return EnumRockClass.values()[Math.abs(provider.getByte(actual, provider.cacheRocks)) % 16];
}
catch (Exception ex)
{
ex.printStackTrace();
return EnumRockClass.ANDESITE;
}
}
示例6: getDirtTypeAt
import net.minecraft.util.math.Vec3i; //導入依賴的package包/類
public static EnumDirtClass getDirtTypeAt(World w, BlockPos at)
{
if (lastRememberedSeed != w.getSeed())
{
rand.setSeed(w.getSeed());
offsetStone = new Vec3i(rand.nextInt(300000) - rand.nextInt(300000), 0, rand.nextInt(300000) - rand.nextInt(300000));
offsetDirt = new Vec3i(rand.nextInt(300000) - rand.nextInt(300000), 0, rand.nextInt(300000) - rand.nextInt(300000));
}
BlockPos actual = at.add(offsetDirt);
try
{
FeatureProvider provider = ((BiomeProviderExP)w.getBiomeProvider()).featureProvider;
return EnumDirtClass.values()[Math.abs(provider.getByte(actual, provider.cacheSoil)) % 16];
}
catch (Exception ex)
{
ex.printStackTrace();
return EnumDirtClass.ACRISOL;
}
}
示例7: getAllInBox
import net.minecraft.util.math.Vec3i; //導入依賴的package包/類
public Iterable<BlockPos> getAllInBox(BlockPos pos, final EnumFacing facing)
{
Iterable<BlockPos> searchables = null;
pos = pos.add(this.getCoreOffset(facing));
if (facing.getAxis() == Axis.Z)
searchables = BlockPos.getAllInBox(
pos.subtract(new Vec3i(this.getOffsetX(), this.getOffsetY(), this.getOffsetZ())),
pos.add(this.getWidth() - 1 - this.getOffsetX(), this.getHeight() - 1 - this.getOffsetY(),
this.getLength() - 1 - this.getOffsetZ()));
else
searchables = BlockPos.getAllInBox(
pos.subtract(new Vec3i(this.getOffsetZ(), this.getOffsetY(), this.getOffsetX())),
pos.add(this.getLength() - 1 - this.getOffsetZ(), this.getHeight() - 1 - this.getOffsetY(),
this.getWidth() - 1 - this.getOffsetX()));
return searchables;
}
示例8: shouldExecute
import net.minecraft.util.math.Vec3i; //導入依賴的package包/類
@Override
public boolean shouldExecute() {
if (living.getEntityData().getInteger(NBT_KEY_LAST_MEAL) > living.ticksExisted)
living.getEntityData().setInteger(NBT_KEY_LAST_MEAL, -Time.DAY);
PathNavigate navigate = living.getNavigator();
if (living.getHealth() < living.getMaxHealth() || living.ticksExisted - living.getEntityData().getInteger(NBT_KEY_LAST_MEAL) > Time.DAY) {
List<EntityItem> list = living.world.getEntitiesWithinAABB(EntityItem.class, AABBHelper.getAABBFromEntity(living, 32), this);
list.sort(this);
for (int i = list.size() - 1; i > -1; i--) {
EntityItem item = list.get(i);
navigate.tryMoveToEntityLiving(item, 1);
Path path = navigate.getPath();
if (path != null) {
PathPoint point = path.getFinalPathPoint();
if (item.getPosition().distanceSq(new Vec3i(point.x, point.y, point.z)) < 2) {
meat = item;
return true;
}
}
}
}
return false;
}
示例9: rotateFacePerspective
import net.minecraft.util.math.Vec3i; //導入依賴的package包/類
/**
* Rotates given surface vector around the center of the texture by the given degree.
*
*/
protected static Vec3i rotateFacePerspective(Vec3i vec, Rotation rotation, TextureScale scale)
{
switch(rotation)
{
case ROTATE_90:
return new Vec3i(vec.getY(), scale.sliceCountMask - vec.getX(), vec.getZ());
case ROTATE_180:
return new Vec3i(scale.sliceCountMask - vec.getX(), scale.sliceCountMask - vec.getY(), vec.getZ());
case ROTATE_270:
return new Vec3i(scale.sliceCountMask - vec.getY(), vec.getX(), vec.getZ());
case ROTATE_NONE:
default:
return vec;
}
}
示例10: CubicQuadPainter
import net.minecraft.util.math.Vec3i; //導入依賴的package包/類
protected CubicQuadPainter(ModelState modelState, Surface surface, PaintLayer paintLayer)
{
super(modelState, surface, paintLayer);
this.species = modelState.hasSpecies() ? modelState.getSpecies() : 0;
int x = modelState.getPosX();
int y = modelState.getPosY();
int z = modelState.getPosZ();
this.pos = new Vec3i(x, y, z);
int shift = this.texture.textureScale.power;
int speciesBits = species << 16;
int xBits = (((y >> shift) & 0xFF) << 8) | ((z >> shift) & 0xFF) | speciesBits;
int yBits = (((x >> shift) & 0xFF) << 8) | ((z >> shift) & 0xFF) | speciesBits;
int zBits = (((x >> shift) & 0xFF) << 8) | ((y >> shift) & 0xFF) | speciesBits;
this.variationHashX = MathHelper.hash(xBits);
this.variationHashY = MathHelper.hash(yBits);
this.variationHashZ = MathHelper.hash(zBits);
}
示例11: sizeInChunksNear
import net.minecraft.util.math.Vec3i; //導入依賴的package包/類
public int sizeInChunksNear(BlockPos pos, int chunkRadius)
{
int result = 0;
int i = 0;
Vec3i offset = Useful.getDistanceSortedCircularOffset(i);
while(offset.getY() <= chunkRadius)
{
result += sizeInChunkAt(pos.add(offset.getX() * 16, 0, offset.getZ() * 16));
offset = Useful.getDistanceSortedCircularOffset(++i);
}
return result;
}
示例12: existingChunksNear
import net.minecraft.util.math.Vec3i; //導入依賴的package包/類
public Iterator<T> existingChunksNear(BlockPos pos, int chunkRadius)
{
return new AbstractIterator<T>()
{
private int i = 0;
@Override
protected T computeNext()
{
Vec3i offset = Useful.getDistanceSortedCircularOffset(i++);
while(offset != null && offset.getY() <= chunkRadius)
{
T result = getIfExists(pos.add(offset.getX() * 16, 0, offset.getZ() * 16));
if(result != null) return result;
offset = Useful.getDistanceSortedCircularOffset(i++);
}
return (T)this.endOfData();
}
};
}
示例13: setOrigin
import net.minecraft.util.math.Vec3i; //導入依賴的package包/類
public void setOrigin(int x, int y, int z)
{
this.origin = new Vec3i(clamp(x), clamp(y), clamp(z));
this.distances = new ArrayList<DistanceRankedVoxel>(getBitsPerAxis() * getBitsPerAxis() * getBitsPerAxis());
this.firstDistanceIndex = 0;
for(int i = 0; i < getBitsPerAxis(); i++)
{
for(int j = 0; j < getBitsPerAxis(); j++)
{
for(int k = 0; k < getBitsPerAxis(); k++)
{
DistanceRankedVoxel point = new DistanceRankedVoxel(i, j, k, origin);
this.distances.add(point);
}
}
}
this.distances.sort(DistanceComparator.INSTANCE);
}
示例14: TaskStackArea
import net.minecraft.util.math.Vec3i; //導入依賴的package包/類
public TaskStackArea(World world, UUID wandUUID, BlockPos posOrig, BlockPos endPosRelative,
TemplateEnderUtilities template, Area3D area, int blocksPerTick)
{
this.dimension = world.provider.getDimension();
this.wandUUID = wandUUID;
this.posOrig = posOrig;
this.sizeAbs = new Vec3i(Math.abs(endPosRelative.getX()) + 1, Math.abs(endPosRelative.getY()) + 1, Math.abs(endPosRelative.getZ()) + 1);
this.template = template;
this.templateNumBlocks = template.getBlockList().size();
this.area = area;
this.blocksPerTick = blocksPerTick;
this.currentArea = new Vec3i(-area.getXNeg(), -area.getYNeg(), -area.getZNeg());
if (this.currentArea.getX() == 0 && this.currentArea.getY() == 0 && this.currentArea.getZ() == 0)
{
this.incrementArea();
}
this.currentStartPos = this.getStartPos();
}
示例15: getVillages
import net.minecraft.util.math.Vec3i; //導入依賴的package包/類
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get information about the villages this block is inside")
public Map<?, ?> getVillages(TileEntityVillageHighlighter vh) {
Map<Integer, Object> map = Maps.newHashMap();
int i = 1;
for (Village village : vh.getWorld().villageCollection.getVillageList()) {
if (village.isBlockPosWithinSqVillageRadius(vh.getPos())) {
Map<String, Object> villageMap = Maps.newHashMap();
Vec3i d = village.getCenter().subtract(vh.getPos());
villageMap.put("x", d.getX());
villageMap.put("y", d.getY());
villageMap.put("z", d.getZ());
villageMap.put("doors", village.getNumVillageDoors());
villageMap.put("villagers", village.getNumVillagers());
villageMap.put("radius", village.getVillageRadius());
map.put(i++, villageMap);
}
}
return map;
}