“FabricMC Spawn Item” Code-Antworten

FabricMC Spawn Item

// Spawn an ItemEntity (dropped item) at the specified position in the specified world.
//	World			            	 World  Double Double Double ItemStack				
	world.spawnEntity(new ItemEntity(world, x,     y,     z,     stack))
Embarrassed Earthworm

FabricMC Spawn Item


Minecraft instance = Minecraft.getInstance();

if(instance.objectMouseOver.getType() != RayTraceResult.Type.BLOCK){return;}

Vector3d blockVector = instance.objectMouseOver.getHitVec();

double bX = blockVector.getX(); double bY = blockVector.getY(); double bZ = blockVector.getZ();
double pX = instance.player.getPosX(); double pY = instance.player.getPosY(); double pZ = instance.player.getPosZ();

if(bX == Math.floor(bX) && bX <= pX){bX--;}
if(bY == Math.floor(bY) && bY <= pY+1){bY--;} // +1 on Y to get y from player eyes instead of feet
if(bZ == Math.floor(bZ) && bZ <= pZ){bZ--;}

BlockState block = instance.world.getBlockState(new BlockPos(bX, bY, bZ));

Confused Cottonmouth

Ähnliche Antworten wie “FabricMC Spawn Item”

Fragen ähnlich wie “FabricMC Spawn Item”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen