Binding particles now respect random offsets. Closes #3014

This commit is contained in:
Vincent Lee committed 2019-11-10 23:30:57 -06:00
1 parent b2050f5625
commit 7708fe4395
2 files changed
+14 -10

No files matched your search

@@ -43,18 +43,16 @@ public class ItemObedienceStick extends ItemMod {
BiFunction<TileEntitySpecialFlower, TileEntity, Boolean> act = pool ? functionalActuator : generatingActuator;
int range = pool ? TileEntityFunctionalFlower.LINK_RANGE : TileEntityGeneratingFlower.LINK_RANGE;
for(BlockPos pos_ : BlockPos.getAllInBoxMutable(pos.add(-range, -range, -range),
for(BlockPos iterPos : BlockPos.getAllInBoxMutable(pos.add(-range, -range, -range),
pos.add(range, range, range))) {
if(pos_.distanceSq(pos) > range * range)
if(iterPos.distanceSq(pos) > range * range)
continue;
TileEntity tile = world.getTileEntity(pos_);
TileEntity tile = world.getTileEntity(iterPos);
if(tile instanceof TileEntitySpecialFlower) {
TileEntitySpecialFlower subtile = ((TileEntitySpecialFlower) tile);
if(act.apply(subtile, tileAt)) {
Vector3 orig = new Vector3(pos_.getX() + 0.5, pos_.getY() + 0.5, pos_.getZ() + 0.5);
Vector3 end = new Vector3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
ItemTwigWand.doParticleBeam(world, orig, end);
ItemTwigWand.doParticleBeamWithOffset(world, iterPos, pos);
}
}
}
@@ -37,6 +37,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.GlobalPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
@@ -104,10 +105,7 @@ public class ItemTwigWand extends ItemMod implements ICoordBoundItem {
if(boundPos.getY() != -1 && !pos.equals(boundPos)) {
if (boundTile instanceof IWandBindable) {
if(((IWandBindable) boundTile).bindTo(player, stack, pos, side)) {
Vector3 orig = new Vector3(boundPos.getX() + 0.5, boundPos.getY() + 0.5, boundPos.getZ() + 0.5);
Vector3 end = new Vector3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
doParticleBeam(world, orig, end);
doParticleBeamWithOffset(world, boundPos, pos);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, boundPos);
setBoundTile(stack, UNBOUND_POS);
}
@@ -205,6 +203,14 @@ public class ItemTwigWand extends ItemMod implements ICoordBoundItem {
return ActionResultType.PASS;
}
public static void doParticleBeamWithOffset(World world, BlockPos orig, BlockPos end) {
Vec3d origOffset = world.getBlockState(orig).getOffset(world, orig);
Vector3 vorig = new Vector3(orig.getX() + origOffset.getX() + 0.5, orig.getY() + origOffset.getY() + 0.5, orig.getZ() + origOffset.getZ() + 0.5);
Vec3d endOffset = world.getBlockState(end).getOffset(world, end);
Vector3 vend = new Vector3(end.getX() + endOffset.getX() + 0.5, end.getY() + endOffset.getY() + 0.5, end.getZ() + endOffset.getZ() + 0.5);
doParticleBeam(world, vorig, vend);
}
public static void doParticleBeam(World world, Vector3 orig, Vector3 end) {
if(!world.isRemote)
return;