“Article de spawn FabricMC” Réponses codées

Article de spawn FabricMC

// 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

Article de spawn FabricMC


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

Réponses similaires à “Article de spawn FabricMC”

Questions similaires à “Article de spawn FabricMC”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code