some more misc fixes

This commit is contained in:
Ellpeck 2020-01-22 23:21:52 +01:00
parent 8d064816ef
commit 8fb7beb49f
40 changed files with 714 additions and 674 deletions

View file

@ -88,7 +88,7 @@ public final class Helper {
List<ItemFrameEntity> frames = world.getEntitiesWithinAABB(ItemFrameEntity.class, new AxisAlignedBB(pos).grow(0.25)); List<ItemFrameEntity> frames = world.getEntitiesWithinAABB(ItemFrameEntity.class, new AxisAlignedBB(pos).grow(0.25));
for (int i = frames.size() - 1; i >= 0; i--) { for (int i = frames.size() - 1; i >= 0; i--) {
ItemFrameEntity frame = frames.get(i); ItemFrameEntity frame = frames.get(i);
BlockPos framePos = frame.getHangingPosition().offset(frame.getHorizontalFacing()); BlockPos framePos = frame.getHangingPosition().offset(frame.getHorizontalFacing().getOpposite());
if (!pos.equals(framePos)) if (!pos.equals(framePos))
frames.remove(i); frames.remove(i);
} }

View file

@ -84,7 +84,7 @@ public final class ModConfig {
//@Comment("If debug information about Aura around the player should be displayed in the F3 debug menu if the player is in creative mode") //@Comment("If debug information about Aura around the player should be displayed in the F3 debug menu if the player is in creative mode")
public boolean debugText = true; public boolean debugText = true;
//@Comment("If, when the F3 debug menu is open and the player is in creative mode, every Aura spot should be highlighted in the world for debug purposes") //@Comment("If, when the F3 debug menu is open and the player is in creative mode, every Aura spot should be highlighted in the world for debug purposes")
public boolean debugWorld = false; public boolean debugWorld = true;
} }
public static void initOrReload(boolean reload) { public static void initOrReload(boolean reload) {

View file

@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.api.multiblock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.tags.Tag;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld; import net.minecraft.world.IWorld;
@ -28,31 +29,8 @@ public class Matcher {
return new Matcher(Blocks.AIR.getDefaultState(), null); return new Matcher(Blocks.AIR.getDefaultState(), null);
} }
public static Matcher oreDict(Block defaultBlock, String name) { public static Matcher tag(Block defaultBlock, Tag tag) {
return new Matcher(defaultBlock.getDefaultState(), return new Matcher(defaultBlock.getDefaultState(), (world, start, offset, pos, state, c) -> state.getBlock().getTags().contains(tag.getId()));
(world, start, offset, pos, state, otherC) -> state.getBlock() == defaultBlock);
/* TODO return new Matcher(defaultBlock.getDefaultState(), new ICheck() {
private List<BlockState> states;
@Override
public boolean matches(World world, BlockPos start, BlockPos offset, BlockPos pos, BlockState state, char c) {
if (this.states == null) {
this.states = new ArrayList<>();
for (ItemStack stack : OreDictionary.getOres(name)) {
Block block = Block.getBlockFromItem(stack.getItem());
if (block != null && block != Blocks.AIR) {
int damage = stack.getItemDamage();
if (damage == OreDictionary.WILDCARD_VALUE)
this.states.addAll(block.getBlockState().getValidStates());
else
this.states.add(block.getStateFromMeta(damage));
}
}
}
return this.states.isEmpty() || this.states.contains(state);
}
});*/
} }
public interface ICheck { public interface ICheck {

View file

@ -2,6 +2,9 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.packet.PacketClient;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.IModelProvider; import de.ellpeck.naturesaura.reg.IModelProvider;
import de.ellpeck.naturesaura.reg.ModRegistry; import de.ellpeck.naturesaura.reg.ModRegistry;
@ -60,7 +63,7 @@ public class BlockDimensionRail extends AbstractRailBlock implements IModItem, I
if (stack.getItem() == ModItems.RANGE_VISUALIZER) { if (stack.getItem() == ModItems.RANGE_VISUALIZER) {
if (!worldIn.isRemote) { if (!worldIn.isRemote) {
BlockPos goalPos = this.getGoalCoords(worldIn, pos); BlockPos goalPos = this.getGoalCoords(worldIn, pos);
// TODO PacketHandler.sendTo(player, new PacketClient(0, this.goalDim, goalPos.getX(), goalPos.getY(), goalPos.getZ())); PacketHandler.sendTo(player, new PacketClient(0, this.goalDim, goalPos.getX(), goalPos.getY(), goalPos.getZ()));
} }
return true; return true;
} }
@ -77,7 +80,7 @@ public class BlockDimensionRail extends AbstractRailBlock implements IModItem, I
return; return;
AxisAlignedBB box = cart.getCollisionBoundingBox(); AxisAlignedBB box = cart.getCollisionBoundingBox();
// TODO PacketHandler.sendToAllAround(world, pos, 32, new PacketParticles((float) box.minX, (float) box.minY, (float) box.minZ, 25, (int) ((box.maxX - box.minX) * 100F), (int) ((box.maxY - box.minY) * 100F), (int) ((box.maxZ - box.minZ) * 100F))); PacketHandler.sendToAllAround(world, pos, 32, new PacketParticles((float) box.minX, (float) box.minY, (float) box.minZ, 25, (int) ((box.maxX - box.minX) * 100F), (int) ((box.maxY - box.minY) * 100F), (int) ((box.maxZ - box.minZ) * 100F)));
world.playSound(null, pos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 1F, 1F); world.playSound(null, pos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 1F, 1F);
BlockPos goalCoords = this.getGoalCoords(world, pos); BlockPos goalCoords = this.getGoalCoords(world, pos);
@ -118,7 +121,6 @@ public class BlockDimensionRail extends AbstractRailBlock implements IModItem, I
return SHAPE; return SHAPE;
} }
public boolean isFlexibleRail(BlockState state, IBlockReader world, BlockPos pos) { public boolean isFlexibleRail(BlockState state, IBlockReader world, BlockPos pos) {
return false; return false;
} }

View file

@ -98,10 +98,9 @@ public class BlockGoldenLeaves extends LeavesBlock implements
} }
*/ */
@Override @Override
public void tick(BlockState state, World worldIn, BlockPos pos, Random random) { public void randomTick(BlockState state, World worldIn, BlockPos pos, Random random) {
super.tick(state, worldIn, pos, random); super.randomTick(state, worldIn, pos, random);
if (!worldIn.isRemote) { if (!worldIn.isRemote) {
int stage = state.get(STAGE); int stage = state.get(STAGE);
if (stage < HIGHEST_STAGE) { if (stage < HIGHEST_STAGE) {
@ -118,8 +117,7 @@ public class BlockGoldenLeaves extends LeavesBlock implements
public static boolean convert(World world, BlockPos pos) { public static boolean convert(World world, BlockPos pos) {
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
if (state.getBlock().isFoliage(state, world, pos) && if ((state.getBlock().isFoliage(state, world, pos) || state.getBlock() instanceof LeavesBlock) && !(state.getBlock() instanceof BlockAncientLeaves || state.getBlock() instanceof BlockGoldenLeaves)) {
!(state.getBlock() instanceof BlockAncientLeaves || state.getBlock() instanceof BlockGoldenLeaves)) {
if (!world.isRemote) { if (!world.isRemote) {
world.setBlockState(pos, ModBlocks.GOLDEN_LEAVES.getDefaultState() world.setBlockState(pos, ModBlocks.GOLDEN_LEAVES.getDefaultState()
.with(DISTANCE, state.has(DISTANCE) ? state.get(DISTANCE) : 1) .with(DISTANCE, state.has(DISTANCE) ? state.get(DISTANCE) : 1)

View file

@ -3,6 +3,8 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPickupStopper; import de.ellpeck.naturesaura.blocks.tiles.TileEntityPickupStopper;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
@ -43,9 +45,9 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
event.setCanceled(true); event.setCanceled(true);
/* if (item.world.getGameTime() % 3 == 0) TODO particles if (item.world.getGameTime() % 3 == 0)
PacketHandler.sendToAllAround(item.world, pos, 32, PacketHandler.sendToAllAround(item.world, pos, 32,
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 14));*/ new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 14));
return true; return true;
}); });
} }

View file

@ -2,8 +2,9 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityProjectileGenerator; import de.ellpeck.naturesaura.blocks.tiles.TileEntityProjectileGenerator;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -13,6 +14,7 @@ import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents; import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.ProjectileImpactEvent; import net.minecraftforge.event.entity.ProjectileImpactEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -30,15 +32,18 @@ public class BlockProjectileGenerator extends BlockContainerImpl/* implements IT
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (entity.world.isRemote) if (entity.world.isRemote)
return; return;
BlockRayTraceResult ray = (BlockRayTraceResult) event.getRayTraceResult(); RayTraceResult ray = event.getRayTraceResult();
BlockPos pos = ray.getPos(); if (!(ray instanceof BlockRayTraceResult))
return;
BlockRayTraceResult blockRay = (BlockRayTraceResult) ray;
BlockPos pos = blockRay.getPos();
if (pos == null) if (pos == null)
return; return;
TileEntity tile = entity.world.getTileEntity(pos); TileEntity tile = entity.world.getTileEntity(pos);
if (!(tile instanceof TileEntityProjectileGenerator)) if (!(tile instanceof TileEntityProjectileGenerator))
return; return;
TileEntityProjectileGenerator generator = (TileEntityProjectileGenerator) tile; TileEntityProjectileGenerator generator = (TileEntityProjectileGenerator) tile;
if (generator.nextSide != ray.getFace()) if (generator.nextSide != blockRay.getFace())
return; return;
ResourceLocation name = ForgeRegistries.ENTITIES.getKey(entity.getType()); ResourceLocation name = ForgeRegistries.ENTITIES.getKey(entity.getType());
Integer amount = NaturesAuraAPI.PROJECTILE_GENERATIONS.get(name); Integer amount = NaturesAuraAPI.PROJECTILE_GENERATIONS.get(name);
@ -48,9 +53,8 @@ public class BlockProjectileGenerator extends BlockContainerImpl/* implements IT
BlockPos spot = IAuraChunk.getLowestSpot(entity.world, pos, 35, pos); BlockPos spot = IAuraChunk.getLowestSpot(entity.world, pos, 35, pos);
IAuraChunk.getAuraChunk(entity.world, spot).storeAura(spot, amount); IAuraChunk.getAuraChunk(entity.world, spot).storeAura(spot, amount);
// TODO particles PacketHandler.sendToAllAround(entity.world, pos, 32,
/* PacketHandler.sendToAllAround(entity.world, pos, 32, new PacketParticles((float) entity.posX, (float) entity.posY, (float) entity.posZ, 26, pos.getX(), pos.getY(), pos.getZ()));
new PacketParticles((float) entity.posX, (float) entity.posY, (float) entity.posZ, 26, pos.getX(), pos.getY(), pos.getZ()));*/
entity.world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_ENDER_EYE_LAUNCH, SoundCategory.BLOCKS, 0.8F, 1F); entity.world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_ENDER_EYE_LAUNCH, SoundCategory.BLOCKS, 0.8F, 1F);
generator.nextSide = generator.nextSide.rotateY(); generator.nextSide = generator.nextSide.rotateY();

View file

@ -5,6 +5,8 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpawnLamp; import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpawnLamp;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.MobEntity; import net.minecraft.entity.MobEntity;
@ -55,9 +57,8 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable
BlockPos spot = IAuraChunk.getHighestSpot(world, lampPos, 32, lampPos); BlockPos spot = IAuraChunk.getHighestSpot(world, lampPos, 32, lampPos);
IAuraChunk.getAuraChunk(world, spot).drainAura(spot, 200); IAuraChunk.getAuraChunk(world, spot).drainAura(spot, 200);
// TODO particles PacketHandler.sendToAllAround(world, lampPos, 32,
/*PacketHandler.sendToAllAround(world, lampPos, 32, new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), 15));
new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), 15));*/
} }
event.setResult(Event.Result.DENY); event.setResult(Event.Result.DENY);

View file

@ -10,6 +10,7 @@ import net.minecraft.block.Blocks;
import net.minecraft.block.LogBlock; import net.minecraft.block.LogBlock;
import net.minecraft.block.SaplingBlock; import net.minecraft.block.SaplingBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
public final class Multiblocks { public final class Multiblocks {
@ -23,7 +24,7 @@ public final class Multiblocks {
{" ", " WBW ", " WBW ", " WWCWCWW ", " BBW WBB ", " WWCWCWW ", " WBW ", " WBW ", " "}}, {" ", " WBW ", " WBW ", " WWCWCWW ", " BBW WBB ", " WWCWCWW ", " WBW ", " WBW ", " "}},
'C', Blocks.CHISELED_STONE_BRICKS, 'C', Blocks.CHISELED_STONE_BRICKS,
'B', Blocks.STONE_BRICKS, 'B', Blocks.STONE_BRICKS,
'W', Blocks.OAK_PLANKS, // TODO create a matcher that matches by tag for planks 'W', Matcher.tag(Blocks.OAK_PLANKS, BlockTags.PLANKS),
'M', ModBlocks.GOLD_BRICK, 'M', ModBlocks.GOLD_BRICK,
'0', ModBlocks.NATURE_ALTAR, '0', ModBlocks.NATURE_ALTAR,
' ', Matcher.wildcard()); ' ', Matcher.wildcard());

View file

@ -1,6 +1,8 @@
package de.ellpeck.naturesaura.blocks.tiles; package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -28,8 +30,8 @@ public class TileEntityAnimalGenerator extends TileEntityImpl implements ITickab
remain -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, remain); remain -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, remain);
} }
/*PacketHandler.sendToAllAround(this.world, this.pos, 32, TODO particles PacketHandler.sendToAllAround(this.world, this.pos, 32,
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 16));*/ new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 16));
} }
this.timeRemaining -= 10; this.timeRemaining -= 10;

View file

@ -6,6 +6,8 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe; import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -87,9 +89,8 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
for (ItemEntity item : items) { for (ItemEntity item : items) {
item.remove(); item.remove();
// TODO particles PacketHandler.sendToAllAround(this.world, this.pos, 32,
/*PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19));
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19));*/
} }
this.currentRecipe = recipe; this.currentRecipe = recipe;

View file

@ -2,6 +2,8 @@ package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.blocks.BlockAutoCrafter; import de.ellpeck.naturesaura.blocks.BlockAutoCrafter;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@ -107,9 +109,8 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickableTi
this.world.addEntity(remItem); this.world.addEntity(remItem);
} }
// TODO particles PacketHandler.sendToAllAround(this.world, this.pos, 32,
/* PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19));
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19));*/
} }
} }
} }

View file

@ -4,6 +4,8 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.container.BasicAuraContainer; import de.ellpeck.naturesaura.api.aura.container.BasicAuraContainer;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -70,9 +72,8 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickableTile
this.isDrainMode = true; this.isDrainMode = true;
item.remove(); item.remove();
// TODO particles PacketHandler.sendToAllAround(this.world, this.pos, 32,
/* PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 21, this.container.getAuraColor()));
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 21, this.container.getAuraColor()));*/
break; break;
} }
} else { } else {

View file

@ -3,6 +3,9 @@ package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticleStream;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.item.ItemFrameEntity; import net.minecraft.entity.item.ItemFrameEntity;
@ -154,8 +157,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT
private void sendParticles() { private void sendParticles() {
for (int j = 0; j < 2; j++) { for (int j = 0; j < 2; j++) {
BlockPos p = j == 0 ? this.pos : this.getConnectedPos(); BlockPos p = j == 0 ? this.pos : this.getConnectedPos();
// TODO particles PacketHandler.sendToAllAround(this.world, p, 32, new PacketParticleStream(
/* PacketHandler.sendToAllAround(this.world, p, 32, new PacketParticleStream(
p.getX() + (float) this.world.rand.nextGaussian() * 3F, p.getX() + (float) this.world.rand.nextGaussian() * 3F,
p.getY() + 1 + this.world.rand.nextFloat() * 3F, p.getY() + 1 + this.world.rand.nextFloat() * 3F,
p.getZ() + (float) this.world.rand.nextGaussian() * 3F, p.getZ() + (float) this.world.rand.nextGaussian() * 3F,
@ -163,7 +165,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT
p.getY() + 0.5F, p.getY() + 0.5F,
p.getZ() + 0.5F, p.getZ() + 0.5F,
this.world.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forWorld(this.world).getColor(), this.world.rand.nextFloat() + 0.5F this.world.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forWorld(this.world).getColor(), this.world.rand.nextFloat() + 0.5F
));*/ ));
} }
} }

View file

@ -1,6 +1,9 @@
package de.ellpeck.naturesaura.blocks.tiles; package de.ellpeck.naturesaura.blocks.tiles;
import com.google.common.primitives.Ints;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.entity.item.FireworkRocketEntity; import net.minecraft.entity.item.FireworkRocketEntity;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -105,10 +108,9 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick
data.add(this.pos.getY()); data.add(this.pos.getY());
data.add(this.pos.getZ()); data.add(this.pos.getZ());
data.addAll(usedColors); data.addAll(usedColors);
// TODO particles PacketHandler.sendToAllLoaded(this.world, this.pos, new PacketParticles(
/* PacketHandler.sendToAllLoaded(this.world, this.pos, new PacketParticles(
(float) this.trackedEntity.posX, (float) this.trackedEntity.posY, (float) this.trackedEntity.posZ, (float) this.trackedEntity.posX, (float) this.trackedEntity.posY, (float) this.trackedEntity.posZ,
24, Ints.toArray(data)));*/ 24, Ints.toArray(data)));
} }
} }

View file

@ -4,13 +4,15 @@ import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticleStream;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT; import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListNBT;
import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
@ -77,10 +79,9 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab
this.world.removeBlock(pos, false); this.world.removeBlock(pos, false);
// TODO particles
int color = Helper.blendColors(0x5ccc30, 0xe53c16, toAdd / (float) addAmount); int color = Helper.blendColors(0x5ccc30, 0xe53c16, toAdd / (float) addAmount);
if (toAdd > 0) { if (toAdd > 0) {
/*for (int i = this.world.rand.nextInt(5) + 5; i >= 0; i--) for (int i = this.world.rand.nextInt(5) + 5; i >= 0; i--)
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream( PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
pos.getX() + 0.25F + this.world.rand.nextFloat() * 0.5F, pos.getX() + 0.25F + this.world.rand.nextFloat() * 0.5F,
pos.getY() + 0.25F + this.world.rand.nextFloat() * 0.5F, pos.getY() + 0.25F + this.world.rand.nextFloat() * 0.5F,
@ -90,9 +91,9 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab
this.pos.getZ() + 0.25F + this.world.rand.nextFloat() * 0.5F, this.pos.getZ() + 0.25F + this.world.rand.nextFloat() * 0.5F,
this.world.rand.nextFloat() * 0.02F + 0.1F, color, 1F this.world.rand.nextFloat() * 0.02F + 0.1F, color, 1F
)); ));
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 8));*/ PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 8));
} }
//PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), 7, color)); PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), 7, color));
} }
} }

View file

@ -1,7 +1,10 @@
package de.ellpeck.naturesaura.blocks.tiles; package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.blocks.BlockFurnaceHeater; import de.ellpeck.naturesaura.blocks.BlockFurnaceHeater;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticleStream;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.FurnaceTileEntity; import net.minecraft.tileentity.FurnaceTileEntity;
@ -44,8 +47,7 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable
did = true; did = true;
if (this.world.getGameTime() % 15 == 0) { if (this.world.getGameTime() % 15 == 0) {
// TODO particles PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
/*PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
this.pos.getX() + (float) this.world.rand.nextGaussian() * 5F, this.pos.getX() + (float) this.world.rand.nextGaussian() * 5F,
this.pos.getY() + 1 + this.world.rand.nextFloat() * 5F, this.pos.getY() + 1 + this.world.rand.nextFloat() * 5F,
this.pos.getZ() + (float) this.world.rand.nextGaussian() * 5F, this.pos.getZ() + (float) this.world.rand.nextGaussian() * 5F,
@ -53,7 +55,7 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable
tilePos.getY() + this.world.rand.nextFloat(), tilePos.getY() + this.world.rand.nextFloat(),
tilePos.getZ() + this.world.rand.nextFloat(), tilePos.getZ() + this.world.rand.nextFloat(),
this.world.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forWorld(this.world).getColor(), this.world.rand.nextFloat() + 0.5F this.world.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forWorld(this.world).getColor(), this.world.rand.nextFloat() + 0.5F
));*/ ));
} }
} }
} }

View file

@ -1,6 +1,8 @@
package de.ellpeck.naturesaura.blocks.tiles; package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.HopperBlock; import net.minecraft.block.HopperBlock;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -60,9 +62,8 @@ public class TileEntityHopperUpgrade extends TileEntityImpl implements ITickable
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 25, this.pos); BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 25, this.pos);
IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 500); IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 500);
// TODO particles PacketHandler.sendToAllAround(this.world, this.pos, 32,
/* PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 10));
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 10));*/
} }
} }
} }

View file

@ -6,6 +6,7 @@ import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.blocks.ModBlocks;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
@ -13,8 +14,8 @@ import net.minecraft.network.play.server.SUpdateTileEntityPacket;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
@ -22,6 +23,7 @@ import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.stream.Stream;
public class TileEntityImpl extends TileEntity { public class TileEntityImpl extends TileEntity {
@ -31,12 +33,6 @@ public class TileEntityImpl extends TileEntity {
super(tileEntityTypeIn); super(tileEntityTypeIn);
} }
// TODO figure out if this was still needed
/* @Override
public boolean shouldRefresh(World world, BlockPos pos, BlockState oldState, BlockState newState) {
return oldState.getBlock() != newState.getBlock();
}*/
@Override @Override
public CompoundNBT write(CompoundNBT compound) { public CompoundNBT write(CompoundNBT compound) {
this.writeNBT(compound, SaveType.TILE); this.writeNBT(compound, SaveType.TILE);
@ -92,11 +88,10 @@ public class TileEntityImpl extends TileEntity {
} }
public void sendToClients() { public void sendToClients() {
// TODO send this shit to the client somehow ServerWorld world = (ServerWorld) this.getWorld();
/* ServerWorld world = (ServerWorld) this.getWorld(); Stream<ServerPlayerEntity> entities = world.getChunkProvider().chunkManager.getTrackingPlayers(new ChunkPos(this.getPos()), false);
Stream<ServerPlayerEntity> entities = world.getChunkProvider().chunkManager.getTrackingPlayers(new ChunkPos(this.getPos().getX() >> 4, this.getPos().getZ() >> 4), false);
SUpdateTileEntityPacket packet = this.getUpdatePacket(); SUpdateTileEntityPacket packet = this.getUpdatePacket();
entities.forEach(()-> packet.packet);*/ entities.forEach(e -> e.connection.sendPacket(packet));
} }
public IItemHandlerModifiable getItemHandler(Direction facing) { public IItemHandlerModifiable getItemHandler(Direction facing) {

View file

@ -2,6 +2,8 @@ package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.ITickableTileEntity;
@ -46,9 +48,8 @@ public class TileEntityMossGenerator extends TileEntityImpl implements ITickable
toAdd -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, toAdd); toAdd -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, toAdd);
} }
// TODO particles PacketHandler.sendToAllAround(this.world, this.pos, 32,
/*PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), 23));
new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), 23));*/
} }
this.world.playEvent(2001, offset, Block.getStateId(state)); this.world.playEvent(2001, offset, Block.getStateId(state));

View file

@ -7,6 +7,9 @@ import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.api.recipes.AltarRecipe; import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticleStream;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.Ingredient;
@ -100,15 +103,14 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi
chunk.drainAura(spot, toStore); chunk.drainAura(spot, toStore);
this.container.storeAura(toStore, false); this.container.storeAura(toStore, false);
// TODO particles if (this.world.getGameTime() % 3 == 0)
/*if (this.world.getGameTime() % 3 == 0)
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream( PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
this.pos.getX() + (float) rand.nextGaussian() * 10F, this.pos.getX() + (float) rand.nextGaussian() * 10F,
this.pos.getY() + rand.nextFloat() * 10F, this.pos.getY() + rand.nextFloat() * 10F,
this.pos.getZ() + (float) rand.nextGaussian() * 10F, this.pos.getZ() + (float) rand.nextGaussian() * 10F,
this.pos.getX() + 0.5F, this.pos.getY() + 0.5F, this.pos.getZ() + 0.5F, this.pos.getX() + 0.5F, this.pos.getY() + 0.5F, this.pos.getZ() + 0.5F,
rand.nextFloat() * 0.1F + 0.1F, 0x89cc37, rand.nextFloat() * 1F + 1F rand.nextFloat() * 0.1F + 0.1F, 0x89cc37, rand.nextFloat() * 1F + 1F
));*/ ));
} }
} }
@ -121,10 +123,8 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi
if (stored > 0) { if (stored > 0) {
this.container.drainAura(stored, false); this.container.drainAura(stored, false);
// TODO particles if (this.world.getGameTime() % 4 == 0)
/*if (this.world.getGameTime() % 4 == 0)
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 4)); PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 4));
*/
} }
} }
} else { } else {
@ -141,10 +141,8 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi
if (this.container.getStoredAura() >= req) { if (this.container.getStoredAura() >= req) {
this.container.drainAura(req, false); this.container.drainAura(req, false);
// TODO particles if (this.timer % 4 == 0)
/*if (this.timer % 4 == 0)
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 4)); PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 4));
*/
this.timer++; this.timer++;
if (this.timer >= this.currentRecipe.time) { if (this.timer >= this.currentRecipe.time) {

View file

@ -1,6 +1,8 @@
package de.ellpeck.naturesaura.blocks.tiles; package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.LogBlock; import net.minecraft.block.LogBlock;
import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntityType; import net.minecraft.tileentity.TileEntityType;
@ -31,10 +33,9 @@ public class TileEntityOakGenerator extends TileEntityImpl implements ITickableT
toAdd -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, toAdd); toAdd -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, toAdd);
} }
// TODO particles PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(
/* PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(
this.pos.getX(), this.pos.getY(), this.pos.getZ(), 12, this.pos.getX(), this.pos.getY(), this.pos.getZ(), 12,
pos.getX(), pos.getY(), pos.getZ(), canGen ? 1 : 0));*/ pos.getX(), pos.getY(), pos.getZ(), canGen ? 1 : 0));
} }
} }
} }

View file

@ -4,6 +4,8 @@ import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.recipes.OfferingRecipe; import de.ellpeck.naturesaura.api.recipes.OfferingRecipe;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
@ -74,10 +76,9 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable
// TODO weather effects // TODO weather effects
//this.world.addWeatherEffect(new LightningBoltEntity(this.world, this.pos.getX(), this.pos.getY(), this.pos.getZ(), true)); //this.world.addWeatherEffect(new LightningBoltEntity(this.world, this.pos.getX(), this.pos.getY(), this.pos.getZ(), true));
// TODO particles PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(
/* PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(
(float) item.posX, (float) item.posY, (float) item.posZ, 13, (float) item.posX, (float) item.posY, (float) item.posZ, 13,
this.pos.getX(), this.pos.getY(), this.pos.getZ()));*/ this.pos.getX(), this.pos.getY(), this.pos.getZ()));
break; break;
} }

View file

@ -3,6 +3,8 @@ package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.entity.item.ItemFrameEntity; import net.minecraft.entity.item.ItemFrameEntity;
@ -74,8 +76,7 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickableTileEnt
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 10, this.pos); BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 10, this.pos);
IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 1000); IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 1000);
// TODO particles PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), 9));
// PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), 9));
return; return;
} }

View file

@ -2,10 +2,13 @@ package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.entity.AreaEffectCloudEntity; import net.minecraft.entity.AreaEffectCloudEntity;
import net.minecraft.potion.Effect; import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance; import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionUtils;
import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -49,10 +52,9 @@ public class TileEntityPotionGenerator extends TileEntityImpl implements ITickab
toAdd -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, toAdd); toAdd -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, toAdd);
} }
// TODO particles PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(
/* PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(
this.pos.getX(), this.pos.getY(), this.pos.getZ(), 5, this.pos.getX(), this.pos.getY(), this.pos.getZ(), 5,
PotionUtils.getPotionColor(type), canGen ? 1 : 0));*/ PotionUtils.getPotionColor(type), canGen ? 1 : 0));
addedOne = true; addedOne = true;
break; break;

View file

@ -3,6 +3,8 @@ package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -82,9 +84,8 @@ public class TileEntityRFConverter extends TileEntityImpl implements ITickableTi
BlockPos pos = IAuraChunk.getHighestSpot(this.world, this.pos, 45, this.pos); BlockPos pos = IAuraChunk.getHighestSpot(this.world, this.pos, 45, this.pos);
IAuraChunk.getAuraChunk(this.world, pos).drainAura(pos, amountToUse); IAuraChunk.getAuraChunk(this.world, pos).drainAura(pos, amountToUse);
// TODO particles PacketHandler.sendToAllAround(this.world, this.pos, 32,
/*PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 20));
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 20));*/
} }
} }

View file

@ -40,7 +40,7 @@ public class TileEntityTimeChanger extends TileEntityImpl implements ITickableTi
continue; continue;
if (this.goalTime > 0) { if (this.goalTime > 0) {
long current = this.world.getGameTime(); long current = this.world.getDayTime();
long toAdd = Math.min(75, this.goalTime - current); long toAdd = Math.min(75, this.goalTime - current);
if (toAdd <= 0) { if (toAdd <= 0) {
this.goalTime = 0; this.goalTime = 0;
@ -93,7 +93,7 @@ public class TileEntityTimeChanger extends TileEntityImpl implements ITickableTi
this.sendToClients(); this.sendToClients();
} }
} else if (this.goalTime > 0 && this.world.rand.nextFloat() >= 0.25F) { } else if (this.goalTime > 0 && this.world.rand.nextFloat() >= 0.25F) {
double angle = Math.toRadians(this.world.getGameTime() * 5F % 360); double angle = Math.toRadians(this.world.getDayTime() * 5F % 360);
double x = this.pos.getX() + 0.5 + Math.sin(angle) * 3F; double x = this.pos.getX() + 0.5 + Math.sin(angle) * 3F;
double z = this.pos.getZ() + 0.5 + Math.cos(angle) * 3F; double z = this.pos.getZ() + 0.5 + Math.cos(angle) * 3F;
int color = this.goalTime % 24000 > 12000 ? 0xe2e2e2 : 0xffe926; int color = this.goalTime % 24000 > 12000 ? 0xe2e2e2 : 0xffe926;

View file

@ -3,6 +3,9 @@ package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe; import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticleStream;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.LeavesBlock; import net.minecraft.block.LeavesBlock;
@ -61,20 +64,19 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> { Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> {
TileEntity tile = this.world.getTileEntity(pos); TileEntity tile = this.world.getTileEntity(pos);
if (tile instanceof TileEntityWoodStand && !((TileEntityWoodStand) tile).items.getStackInSlot(0).isEmpty()) { if (tile instanceof TileEntityWoodStand && !((TileEntityWoodStand) tile).items.getStackInSlot(0).isEmpty()) {
// TODO particles PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
/* PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
(float) pos.getX() + 0.2F + this.world.rand.nextFloat() * 0.6F, (float) pos.getX() + 0.2F + this.world.rand.nextFloat() * 0.6F,
(float) pos.getY() + 0.85F, (float) pos.getY() + 0.85F,
(float) pos.getZ() + 0.2F + this.world.rand.nextFloat() * 0.6F, (float) pos.getZ() + 0.2F + this.world.rand.nextFloat() * 0.6F,
this.ritualPos.getX() + 0.5F, this.ritualPos.getY() + this.world.rand.nextFloat() * 3F + 2F, this.ritualPos.getZ() + 0.5F, this.ritualPos.getX() + 0.5F, this.ritualPos.getY() + this.world.rand.nextFloat() * 3F + 2F, this.ritualPos.getZ() + 0.5F,
this.world.rand.nextFloat() * 0.04F + 0.04F, 0x89cc37, this.world.rand.nextFloat() * 1F + 1F this.world.rand.nextFloat() * 0.04F + 0.04F, 0x89cc37, this.world.rand.nextFloat() * 1F + 1F
));*/ ));
} }
return true; return true;
}); });
/* PacketHandler.sendToAllAround(this.world, this.ritualPos, 32, PacketHandler.sendToAllAround(this.world, this.ritualPos, 32,
new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), 0));*/ new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), 0));
if (this.timer >= this.recipe.time) { if (this.timer >= this.recipe.time) {
this.recurseTreeDestruction(this.ritualPos, this.ritualPos); this.recurseTreeDestruction(this.ritualPos, this.ritualPos);
@ -88,8 +90,8 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
this.recipe.result.copy()); this.recipe.result.copy());
this.world.addEntity(item); this.world.addEntity(item);
/*PacketHandler.sendToAllAround(this.world, this.pos, 32, PacketHandler.sendToAllAround(this.world, this.pos, 32,
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 3));*/ new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 3));
this.world.playSound(null, this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5, this.world.playSound(null, this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5,
SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 0.65F, 1F); SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 0.65F, 1F);
@ -102,8 +104,8 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
if (tile instanceof TileEntityWoodStand) { if (tile instanceof TileEntityWoodStand) {
TileEntityWoodStand stand = (TileEntityWoodStand) tile; TileEntityWoodStand stand = (TileEntityWoodStand) tile;
if (!stand.items.getStackInSlot(0).isEmpty()) { if (!stand.items.getStackInSlot(0).isEmpty()) {
/* PacketHandler.sendToAllAround(this.world, this.pos, 32, PacketHandler.sendToAllAround(this.world, this.pos, 32,
new PacketParticles(stand.pos.getX(), stand.pos.getY(), stand.pos.getZ(), 1));*/ new PacketParticles(stand.pos.getX(), stand.pos.getY(), stand.pos.getZ(), 1));
this.world.playSound(null, stand.pos.getX() + 0.5, stand.pos.getY() + 0.5, stand.pos.getZ() + 0.5, this.world.playSound(null, stand.pos.getX() + 0.5, stand.pos.getY() + 0.5, stand.pos.getZ() + 0.5,
SoundEvents.BLOCK_WOOD_STEP, SoundCategory.BLOCKS, 0.5F, 1F); SoundEvents.BLOCK_WOOD_STEP, SoundCategory.BLOCKS, 0.5F, 1F);
@ -139,7 +141,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
BlockState state = this.world.getBlockState(offset); BlockState state = this.world.getBlockState(offset);
if (state.getBlock() instanceof LogBlock || state.getBlock() instanceof LeavesBlock) { if (state.getBlock() instanceof LogBlock || state.getBlock() instanceof LeavesBlock) {
this.world.setBlockState(offset, Blocks.AIR.getDefaultState()); this.world.setBlockState(offset, Blocks.AIR.getDefaultState());
//PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), 2)); PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), 2));
this.recurseTreeDestruction(offset, start); this.recurseTreeDestruction(offset, start);
} }

View file

@ -4,6 +4,8 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.packet.PacketAuraChunk;
import de.ellpeck.naturesaura.packet.PacketHandler;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
@ -12,6 +14,7 @@ import net.minecraft.nbt.ListNBT;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Tuple; import net.minecraft.util.Tuple;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableInt;
@ -113,8 +116,9 @@ public class AuraChunk implements IAuraChunk {
private void addDrainSpot(BlockPos pos, MutableInt spot) { private void addDrainSpot(BlockPos pos, MutableInt spot) {
int expX = pos.getX() >> 4; int expX = pos.getX() >> 4;
int expZ = pos.getZ() >> 4; int expZ = pos.getZ() >> 4;
if (expX != this.chunk.getPos().x || expZ != this.chunk.getPos().z) ChunkPos myPos = this.chunk.getPos();
throw new IllegalArgumentException("Tried to add drain spot " + pos + " to chunk at " + this.chunk.getPos().x + ", " + this.chunk.getPos().z + " when it should've been added to chunk at " + expX + ", " + expZ); if (expX != myPos.x || expZ != myPos.z)
throw new IllegalArgumentException("Tried to add drain spot " + pos + " to chunk at " + myPos.x + ", " + myPos.z + " when it should've been added to chunk at " + expX + ", " + expZ);
this.drainSpots.put(pos, spot); this.drainSpots.put(pos, spot);
} }
@ -147,19 +151,18 @@ public class AuraChunk implements IAuraChunk {
} }
if (this.needsSync) { if (this.needsSync) {
// TODO packets ChunkPos pos = this.chunk.getPos();
/*PacketHandler.sendToAllLoaded(world, PacketHandler.sendToAllLoaded(world,
new BlockPos(this.chunk.x * 16, 0, this.chunk.z * 16), new BlockPos(pos.x * 16, 0, pos.z * 16),
this.makePacket());*/ this.makePacket());
this.needsSync = false; this.needsSync = false;
} }
} }
/* public PacketAuraChunk makePacket() {
public IMessage makePacket() { ChunkPos pos = this.chunk.getPos();
return new PacketAuraChunk(this.chunk.x, this.chunk.z, this.drainSpots); return new PacketAuraChunk(pos.x, pos.z, this.drainSpots);
} }
*/
public void getSpotsInArea(BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer) { public void getSpotsInArea(BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer) {
for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) { for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) {

View file

@ -6,6 +6,8 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -75,9 +77,8 @@ public class PlantBoostEffect implements IDrainSpotEffect {
BlockPos closestSpot = IAuraChunk.getHighestSpot(world, plantPos, 25, pos); BlockPos closestSpot = IAuraChunk.getHighestSpot(world, plantPos, 25, pos);
IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 3500); IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 3500);
// TODO particles PacketHandler.sendToAllAround(world, plantPos, 32,
/* PacketHandler.sendToAllAround(world, plantPos, 32, new PacketParticles(plantPos.getX(), plantPos.getY(), plantPos.getZ(), 6));
new PacketParticles(plantPos.getX(), plantPos.getY(), plantPos.getZ(), 6));*/
} }
} }
} }

View file

@ -2,6 +2,8 @@ package de.ellpeck.naturesaura.entities;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -48,10 +50,9 @@ public class EntityMoverMinecart extends AbstractMinecartEntity {
BlockPos pos = this.getPosition(); BlockPos pos = this.getPosition();
if (!this.spotOffsets.isEmpty() && this.world.getGameTime() % 10 == 0) if (!this.spotOffsets.isEmpty() && this.world.getGameTime() % 10 == 0)
// TODO particles PacketHandler.sendToAllAround(this.world, pos, 32, new PacketParticles(
/*PacketHandler.sendToAllAround(this.world, pos, 32, new PacketParticles(
(float) this.posX, (float) this.posY, (float) this.posZ, 22, (float) this.posX, (float) this.posY, (float) this.posZ, 22,
MathHelper.floor(this.motionX * 100F), MathHelper.floor(this.motionY * 100F), MathHelper.floor(this.motionZ * 100F)));*/ MathHelper.floor(this.getMotion().getX() * 100F), MathHelper.floor(this.getMotion().getY() * 100F), MathHelper.floor(this.getMotion().getZ() * 100F)));
if (pos.distanceSq(this.lastPosition) < 8 * 8) if (pos.distanceSq(this.lastPosition) < 8 * 8)
return; return;

View file

@ -16,6 +16,7 @@ import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.items.AuraCache; import de.ellpeck.naturesaura.items.AuraCache;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.items.RangeVisualizer; import de.ellpeck.naturesaura.items.RangeVisualizer;
import de.ellpeck.naturesaura.packet.PacketAuraChunk;
import de.ellpeck.naturesaura.particles.ParticleHandler; import de.ellpeck.naturesaura.particles.ParticleHandler;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -54,6 +55,7 @@ import org.apache.commons.lang3.mutable.MutableInt;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -65,9 +67,12 @@ public class ClientEvents {
public static final ResourceLocation BOOK_GUI = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/book.png"); public static final ResourceLocation BOOK_GUI = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/book.png");
private static final ItemStack ITEM_FRAME = new ItemStack(Items.ITEM_FRAME); private static final ItemStack ITEM_FRAME = new ItemStack(Items.ITEM_FRAME);
private static final Map<ResourceLocation, Tuple<ItemStack, Boolean>> SHOWING_EFFECTS = new HashMap<>(); private static final Map<ResourceLocation, Tuple<ItemStack, Boolean>> SHOWING_EFFECTS = new HashMap<>();
public static final List<PacketAuraChunk> PENDING_AURA_CHUNKS = new ArrayList<>();
private static ItemStack heldCache = ItemStack.EMPTY; private static ItemStack heldCache = ItemStack.EMPTY;
private static ItemStack heldEye = ItemStack.EMPTY; private static ItemStack heldEye = ItemStack.EMPTY;
private static ItemStack heldOcular = ItemStack.EMPTY; private static ItemStack heldOcular = ItemStack.EMPTY;
private float height;
private float previousHeight;
@SubscribeEvent @SubscribeEvent
public void onDebugRender(RenderGameOverlayEvent.Text event) { public void onDebugRender(RenderGameOverlayEvent.Text event) {
@ -97,13 +102,12 @@ public class ClientEvents {
@SubscribeEvent @SubscribeEvent
public void onRenderLast(RenderWorldLastEvent event) { public void onRenderLast(RenderWorldLastEvent event) {
Minecraft mc = Minecraft.getInstance();
ParticleHandler.renderParticles(event.getPartialTicks()); ParticleHandler.renderParticles(event.getPartialTicks());
} }
@SubscribeEvent @SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) { public void onClientTick(TickEvent.ClientTickEvent event) {
if (event.phase == TickEvent.Phase.END) { if (event.phase != TickEvent.Phase.END) {
heldCache = ItemStack.EMPTY; heldCache = ItemStack.EMPTY;
heldEye = ItemStack.EMPTY; heldEye = ItemStack.EMPTY;
heldOcular = ItemStack.EMPTY; heldOcular = ItemStack.EMPTY;
@ -112,7 +116,16 @@ public class ClientEvents {
if (mc.world == null) { if (mc.world == null) {
ParticleHandler.clearParticles(); ParticleHandler.clearParticles();
RangeVisualizer.clear(); RangeVisualizer.clear();
} else if (!mc.isGamePaused()) { PENDING_AURA_CHUNKS.clear();
} else {
PENDING_AURA_CHUNKS.removeIf(next -> next.tryHandle(mc.world));
if (mc.player != null) {
this.previousHeight = this.height;
this.height += (mc.player.getEyeHeight() - this.height) * 0.5F;
}
if (!mc.isGamePaused()) {
if (mc.world.getGameTime() % 20 == 0) { if (mc.world.getGameTime() % 20 == 0) {
int amount = MathHelper.floor(190 * ModConfig.client.excessParticleAmount); int amount = MathHelper.floor(190 * ModConfig.client.excessParticleAmount);
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
@ -195,6 +208,7 @@ public class ClientEvents {
} }
} }
} }
}
@SubscribeEvent @SubscribeEvent
public void onWorldRender(RenderWorldLastEvent event) { public void onWorldRender(RenderWorldLastEvent event) {
@ -203,7 +217,7 @@ public class ClientEvents {
float partial = event.getPartialTicks(); float partial = event.getPartialTicks();
GL11.glTranslated( GL11.glTranslated(
-mc.player.prevPosX - (mc.player.posX - mc.player.prevPosX) * partial, -mc.player.prevPosX - (mc.player.posX - mc.player.prevPosX) * partial,
-mc.player.prevPosY - (mc.player.posY - mc.player.prevPosY) * partial, -mc.player.prevPosY - (mc.player.posY - mc.player.prevPosY) * partial - (double) MathHelper.lerp(partial, this.previousHeight, this.height),
-mc.player.prevPosZ - (mc.player.posZ - mc.player.prevPosZ) * partial); -mc.player.prevPosZ - (mc.player.posZ - mc.player.prevPosZ) * partial);
if (mc.gameSettings.showDebugInfo && mc.player.isCreative() && ModConfig.client.debugWorld) { if (mc.gameSettings.showDebugInfo && mc.player.isCreative() && ModConfig.client.debugWorld) {
@ -271,7 +285,8 @@ public class ClientEvents {
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
private void renderVisualize(IVisualizable visualize, World world, BlockPos pos) { private void renderVisualize(IVisualizable visualize, World
world, BlockPos pos) {
AxisAlignedBB box = visualize.getVisualizationBounds(world, pos); AxisAlignedBB box = visualize.getVisualizationBounds(world, pos);
if (box == null) if (box == null)
return; return;
@ -306,7 +321,7 @@ public class ClientEvents {
float scale = 0.75F; float scale = 0.75F;
GlStateManager.scalef(scale, scale, scale); GlStateManager.scalef(scale, scale, scale);
String s = heldCache.getDisplayName().getFormattedText(); String s = heldCache.getDisplayName().getFormattedText();
mc.fontRenderer.drawString(s, (x + 80) / scale - mc.fontRenderer.getStringWidth(s), (y - 7) / scale, color); mc.fontRenderer.drawStringWithShadow(s, (x + 80) / scale - mc.fontRenderer.getStringWidth(s), (y - 7) / scale, color);
GlStateManager.color3f(1F, 1F, 1F); GlStateManager.color3f(1F, 1F, 1F);
GlStateManager.popMatrix(); GlStateManager.popMatrix();
@ -357,13 +372,13 @@ public class ClientEvents {
int color = heldOcular.isEmpty() ? 0x53a008 : 0xa05308; int color = heldOcular.isEmpty() ? 0x53a008 : 0xa05308;
if (totalPercentage > (heldOcular.isEmpty() ? 1F : 1.5F)) if (totalPercentage > (heldOcular.isEmpty() ? 1F : 1.5F))
mc.fontRenderer.drawString("+", startX + plusOffX, startY - 0.5F, color); mc.fontRenderer.drawStringWithShadow("+", startX + plusOffX, startY - 0.5F, color);
if (totalPercentage < (heldOcular.isEmpty() ? 0F : -0.5F)) if (totalPercentage < (heldOcular.isEmpty() ? 0F : -0.5F))
mc.fontRenderer.drawString("-", startX + plusOffX, startY - 0.5F + (heldOcular.isEmpty() ? 44 : 70), color); mc.fontRenderer.drawStringWithShadow("-", startX + plusOffX, startY - 0.5F + (heldOcular.isEmpty() ? 44 : 70), color);
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.scalef(textScale, textScale, textScale); GlStateManager.scalef(textScale, textScale, textScale);
mc.fontRenderer.drawString(text, textX / textScale, textY / textScale, 0x53a008); mc.fontRenderer.drawStringWithShadow(text, textX / textScale, textY / textScale, 0x53a008);
GlStateManager.popMatrix(); GlStateManager.popMatrix();
if (!heldOcular.isEmpty()) { if (!heldOcular.isEmpty()) {
@ -398,7 +413,7 @@ public class ClientEvents {
BlockState state = mc.world.getBlockState(pos); BlockState state = mc.world.getBlockState(pos);
ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.world, pos, mc.player); ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.world, pos, mc.player);
this.drawContainerInfo(container.getStoredAura(), container.getMaxAura(), container.getAuraColor(), this.drawContainerInfo(container.getStoredAura(), container.getMaxAura(), container.getAuraColor(),
mc, res, 35, blockStack.getDisplayName().toString(), null); mc, res, 35, blockStack.getDisplayName().getFormattedText(), null);
if (tile instanceof TileEntityNatureAltar) { if (tile instanceof TileEntityNatureAltar) {
ItemStack tileStack = ((TileEntityNatureAltar) tile).getItemHandler(null).getStackInSlot(0); ItemStack tileStack = ((TileEntityNatureAltar) tile).getItemHandler(null).getStackInSlot(0);
@ -406,7 +421,7 @@ public class ClientEvents {
IAuraContainer stackCont = tileStack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null); IAuraContainer stackCont = tileStack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
if (stackCont != null) { if (stackCont != null) {
this.drawContainerInfo(stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(), this.drawContainerInfo(stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(),
mc, res, 55, tileStack.getDisplayName().toString(), null); mc, res, 55, tileStack.getDisplayName().getFormattedText(), null);
} }
} }
} }
@ -422,7 +437,7 @@ public class ClientEvents {
int x = res.getScaledWidth() / 2; int x = res.getScaledWidth() / 2;
int y = res.getScaledHeight() / 2; int y = res.getScaledHeight() / 2;
if (stack.isEmpty()) if (stack.isEmpty())
mc.fontRenderer.drawString( mc.fontRenderer.drawStringWithShadow(
TextFormatting.GRAY.toString() + TextFormatting.ITALIC + I18n.format("info.naturesaura.empty"), TextFormatting.GRAY.toString() + TextFormatting.ITALIC + I18n.format("info.naturesaura.empty"),
x + 5, y - 11, 0xFFFFFF); x + 5, y - 11, 0xFFFFFF);
else else
@ -445,7 +460,9 @@ public class ClientEvents {
} }
} }
private void drawContainerInfo(int stored, int max, int color, Minecraft mc, MainWindow res, int yOffset, String name, String textBelow) { private void drawContainerInfo(int stored, int max,
int color, Minecraft mc, MainWindow res, int yOffset, String name, String
textBelow) {
GlStateManager.color3f((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F); GlStateManager.color3f((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
int x = res.getScaledWidth() / 2 - 40; int x = res.getScaledWidth() / 2 - 40;
@ -458,9 +475,9 @@ public class ClientEvents {
if (width > 0) if (width > 0)
AbstractGui.blit(x, y, 0, 6, width, 6, 256, 256); AbstractGui.blit(x, y, 0, 6, width, 6, 256, 256);
mc.fontRenderer.drawString(name, x + 40 - mc.fontRenderer.getStringWidth(name) / 2F, y - 9, color); mc.fontRenderer.drawStringWithShadow(name, x + 40 - mc.fontRenderer.getStringWidth(name) / 2F, y - 9, color);
if (textBelow != null) if (textBelow != null)
mc.fontRenderer.drawString(textBelow, x + 40 - mc.fontRenderer.getStringWidth(textBelow) / 2F, y + 7, color); mc.fontRenderer.drawStringWithShadow(textBelow, x + 40 - mc.fontRenderer.getStringWidth(textBelow) / 2F, y + 7, color);
} }
} }

View file

@ -7,16 +7,26 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.chunk.AuraChunk; import de.ellpeck.naturesaura.chunk.AuraChunk;
import de.ellpeck.naturesaura.chunk.AuraChunkProvider; import de.ellpeck.naturesaura.chunk.AuraChunkProvider;
import de.ellpeck.naturesaura.misc.WorldData; import de.ellpeck.naturesaura.misc.WorldData;
import de.ellpeck.naturesaura.packet.PacketHandler;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.server.ChunkHolder;
import net.minecraft.world.server.ChunkManager;
import net.minecraft.world.server.ServerChunkProvider;
import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.world.ChunkWatchEvent; import net.minecraftforge.event.world.ChunkWatchEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class CommonEvents { public class CommonEvents {
private static final Method GET_LOADED_CHUNKS_METHOD = ObfuscationReflectionHelper.findMethod(ChunkManager.class, "func_223491_f");
@SubscribeEvent @SubscribeEvent
public void onChunkCapsAttach(AttachCapabilitiesEvent<Chunk> event) { public void onChunkCapsAttach(AttachCapabilitiesEvent<Chunk> event) {
Chunk chunk = event.getObject(); Chunk chunk = event.getObject();
@ -32,13 +42,22 @@ public class CommonEvents {
public void onWorldTick(TickEvent.WorldTickEvent event) { public void onWorldTick(TickEvent.WorldTickEvent event) {
if (!event.world.isRemote && event.phase == TickEvent.Phase.END) { if (!event.world.isRemote && event.phase == TickEvent.Phase.END) {
if (event.world.getGameTime() % 20 == 0) { if (event.world.getGameTime() % 20 == 0) {
// TODO update loaded aura chunks event.world.getProfiler().startSection(NaturesAura.MOD_ID + ":onWorldTick");
/*Iterator<Chunk> chunks = event.world.getPersistentChunkIterable(((ServerWorld) event.world).getPlayerChunkMap().getChunkIterator()); try {
while (chunks.hasNext()) { ChunkManager manager = ((ServerChunkProvider) event.world.getChunkProvider()).chunkManager;
Chunk chunk = chunks.next(); Iterable<ChunkHolder> chunks = (Iterable<ChunkHolder>) GET_LOADED_CHUNKS_METHOD.invoke(manager);
for (ChunkHolder holder : chunks) {
Chunk chunk = holder.func_219298_c();
if (chunk == null)
continue;
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null); AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
if (auraChunk != null)
auraChunk.update(); auraChunk.update();
}*/ }
} catch (IllegalAccessException | InvocationTargetException e) {
NaturesAura.LOGGER.fatal(e);
}
event.world.getProfiler().endSection();
} }
} }
} }
@ -62,9 +81,8 @@ public class CommonEvents {
Chunk chunk = event.getWorld().getChunk(event.getPos().x, event.getPos().z); Chunk chunk = event.getWorld().getChunk(event.getPos().x, event.getPos().z);
if (!chunk.getWorld().isRemote) { if (!chunk.getWorld().isRemote) {
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null); AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
// TODO packets if (auraChunk != null)
/*if (auraChunk != null) PacketHandler.sendTo(event.getPlayer(), auraChunk.makePacket());
PacketHandler.sendTo(event.getPlayer(), auraChunk.makePacket());*/
} }
} }

View file

@ -5,6 +5,8 @@ import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.render.ITrinketItem; import de.ellpeck.naturesaura.api.render.ITrinketItem;
import de.ellpeck.naturesaura.items.tools.Armor; import de.ellpeck.naturesaura.items.tools.Armor;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -105,7 +107,7 @@ public class ShockwaveCreator extends ItemImpl implements ITrinketItem {
if (worldIn instanceof ServerWorld) if (worldIn instanceof ServerWorld)
((ServerWorld) worldIn).spawnParticle(ParticleTypes.POOF, living.posX, living.posY + 0.01F, living.posZ, 15, 0D, 0D, 0D, 0.15D); ((ServerWorld) worldIn).spawnParticle(ParticleTypes.POOF, living.posX, living.posY + 0.01F, living.posZ, 15, 0D, 0D, 0D, 0.15D);
// TODO PacketHandler.sendToAllAround(worldIn, pos, 32, new PacketParticles((float) living.posX, (float) living.posY, (float) living.posZ, 11)); PacketHandler.sendToAllAround(worldIn, pos, 32, new PacketParticles((float) living.posX, (float) living.posY, (float) living.posZ, 11));
} }
} }

View file

@ -1,4 +0,0 @@
package de.ellpeck.naturesaura.packet;
public interface IPacket {
}

View file

@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.packet;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.chunk.AuraChunk; import de.ellpeck.naturesaura.chunk.AuraChunk;
import net.minecraft.client.Minecraft; import de.ellpeck.naturesaura.events.ClientEvents;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -16,12 +16,21 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Supplier; import java.util.function.Supplier;
public class PacketAuraChunk implements IPacket { public class PacketAuraChunk {
private int chunkX; private int chunkX;
private int chunkZ; private int chunkZ;
private Map<BlockPos, MutableInt> drainSpots; private Map<BlockPos, MutableInt> drainSpots;
public PacketAuraChunk(int chunkX, int chunkZ, Map<BlockPos, MutableInt> drainSpots) {
this.chunkX = chunkX;
this.chunkZ = chunkZ;
this.drainSpots = drainSpots;
}
private PacketAuraChunk() {
}
public static PacketAuraChunk fromBytes(PacketBuffer buf) { public static PacketAuraChunk fromBytes(PacketBuffer buf) {
PacketAuraChunk packet = new PacketAuraChunk(); PacketAuraChunk packet = new PacketAuraChunk();
packet.chunkX = buf.readInt(); packet.chunkX = buf.readInt();
@ -50,22 +59,20 @@ public class PacketAuraChunk implements IPacket {
} }
} }
public static class Handler { public boolean tryHandle(World world) {
Chunk chunk = world.getChunk(this.chunkX, this.chunkZ);
if (chunk.isEmpty())
return false;
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk).orElse(null);
if (auraChunk == null)
return false;
auraChunk.setSpots(this.drainSpots);
return true;
}
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static void onMessage(PacketAuraChunk message, Supplier<NetworkEvent.Context> ctx) { public static void onMessage(PacketAuraChunk message, Supplier<NetworkEvent.Context> ctx) {
ctx.get().enqueueWork(() -> { ctx.get().enqueueWork(() -> ClientEvents.PENDING_AURA_CHUNKS.add(message));
World world = Minecraft.getInstance().world;
if (world != null) {
Chunk chunk = world.getChunk(message.chunkX, message.chunkZ);
if (chunk.getCapability(NaturesAuraAPI.capAuraChunk).isPresent()) {
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk).orElse(null);
auraChunk.setSpots(message.drainSpots);
}
}
});
ctx.get().setPacketHandled(true); ctx.get().setPacketHandled(true);
} }
} }
}

View file

@ -11,11 +11,19 @@ import net.minecraftforge.fml.network.NetworkEvent;
import java.util.function.Supplier; import java.util.function.Supplier;
public class PacketClient implements IPacket { public class PacketClient {
private int type; private int type;
private int[] data; private int[] data;
public PacketClient(int type, int... data) {
this.type = type;
this.data = data;
}
private PacketClient() {
}
public static PacketClient fromBytes(PacketBuffer buf) { public static PacketClient fromBytes(PacketBuffer buf) {
PacketClient client = new PacketClient(); PacketClient client = new PacketClient();
client.type = buf.readByte(); client.type = buf.readByte();
@ -33,8 +41,6 @@ public class PacketClient implements IPacket {
buf.writeInt(i); buf.writeInt(i);
} }
public static class Handler {
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static void onMessage(PacketClient message, Supplier<NetworkEvent.Context> ctx) { public static void onMessage(PacketClient message, Supplier<NetworkEvent.Context> ctx) {
ctx.get().enqueueWork(() -> { ctx.get().enqueueWork(() -> {
@ -48,8 +54,6 @@ public class PacketClient implements IPacket {
} }
} }
}); });
ctx.get().setPacketHandled(true); ctx.get().setPacketHandled(true);
} }
} }
}

View file

@ -12,37 +12,26 @@ import net.minecraftforge.fml.network.simple.SimpleChannel;
public final class PacketHandler { public final class PacketHandler {
private static String version = "1"; private static final String VERSION = "1";
private static SimpleChannel network; private static SimpleChannel network;
public static void init() { public static void init() {
network = NetworkRegistry.newSimpleChannel( network = NetworkRegistry.newSimpleChannel(NaturesAura.createRes("network"), () -> VERSION, VERSION::equals, VERSION::equals);
NaturesAura.createRes("network"), network.registerMessage(0, PacketParticleStream.class, PacketParticleStream::toBytes, PacketParticleStream::fromBytes, PacketParticleStream::onMessage);
() -> version, network.registerMessage(1, PacketParticles.class, PacketParticles::toBytes, PacketParticles::fromBytes, PacketParticles::onMessage);
version::equals, network.registerMessage(2, PacketAuraChunk.class, PacketAuraChunk::toBytes, PacketAuraChunk::fromBytes, PacketAuraChunk::onMessage);
version::equals); network.registerMessage(3, PacketClient.class, PacketClient::toBytes, PacketClient::fromBytes, PacketClient::onMessage);
network.registerMessage(0, PacketParticleStream.class, PacketParticleStream::toBytes, PacketParticleStream::fromBytes, PacketParticleStream.Handler::onMessage);
network.registerMessage(1, PacketParticles.class, PacketParticles::toBytes, PacketParticles::fromBytes, PacketParticles.Handler::onMessage);
network.registerMessage(2, PacketAuraChunk.class, PacketAuraChunk::toBytes, PacketAuraChunk::fromBytes, PacketAuraChunk.Handler::onMessage);
network.registerMessage(3, PacketClient.class, PacketClient::toBytes, PacketClient::fromBytes, PacketClient.Handler::onMessage);
} }
@Deprecated public static void sendToAllLoaded(World world, BlockPos pos, Object message) {
public static void sendToAllLoaded(World world, BlockPos pos, IPacket message) { network.send(PacketDistributor.TRACKING_CHUNK.with(() -> world.getChunkAt(pos)), message);
sendToAllLoaded(message);
} }
public static void sendToAllLoaded(IPacket message) { public static void sendToAllAround(IWorld world, BlockPos pos, int range, Object message) {
network.send(PacketDistributor.ALL.noArg(), message); network.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(pos.getX(), pos.getY(), pos.getZ(), range, world.getDimension().getType())), message);
} }
public static void sendToAllAround(IWorld world, BlockPos pos, int range, IPacket message) { public static void sendTo(PlayerEntity player, Object message) {
network.send(PacketDistributor.NEAR.with(
() -> new PacketDistributor.TargetPoint(pos.getX(), pos.getY(), pos.getZ(), range, world.getDimension().getType())),
message);
}
public static void sendTo(PlayerEntity player, IPacket message) {
network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), message); network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), message);
} }
} }

View file

@ -1,8 +1,6 @@
package de.ellpeck.naturesaura.packet; package de.ellpeck.naturesaura.packet;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import io.netty.buffer.ByteBuf;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@ -10,7 +8,7 @@ import net.minecraftforge.fml.network.NetworkEvent;
import java.util.function.Supplier; import java.util.function.Supplier;
public class PacketParticleStream implements IPacket { public class PacketParticleStream {
private float startX; private float startX;
private float startY; private float startY;
@ -36,8 +34,7 @@ public class PacketParticleStream implements IPacket {
this.scale = scale; this.scale = scale;
} }
public PacketParticleStream() { private PacketParticleStream() {
} }
public static PacketParticleStream fromBytes(PacketBuffer buf) { public static PacketParticleStream fromBytes(PacketBuffer buf) {
@ -68,8 +65,6 @@ public class PacketParticleStream implements IPacket {
buf.writeFloat(packet.scale); buf.writeFloat(packet.scale);
} }
public static class Handler {
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static void onMessage(PacketParticleStream message, Supplier<NetworkEvent.Context> ctx) { public static void onMessage(PacketParticleStream message, Supplier<NetworkEvent.Context> ctx) {
ctx.get().enqueueWork(() -> NaturesAuraAPI.instance().spawnParticleStream( ctx.get().enqueueWork(() -> NaturesAuraAPI.instance().spawnParticleStream(
@ -80,4 +75,3 @@ public class PacketParticleStream implements IPacket {
ctx.get().setPacketHandled(true); ctx.get().setPacketHandled(true);
} }
} }
}

View file

@ -18,7 +18,7 @@ import net.minecraftforge.fml.network.NetworkEvent;
import java.util.function.Supplier; import java.util.function.Supplier;
public class PacketParticles implements IPacket { public class PacketParticles {
private float posX; private float posX;
private float posY; private float posY;
@ -26,6 +26,17 @@ public class PacketParticles implements IPacket {
private int type; private int type;
private int[] data; private int[] data;
public PacketParticles(float posX, float posY, float posZ, int type, int... data) {
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
this.type = type;
this.data = data;
}
private PacketParticles() {
}
public static PacketParticles fromBytes(PacketBuffer buf) { public static PacketParticles fromBytes(PacketBuffer buf) {
PacketParticles packet = new PacketParticles(); PacketParticles packet = new PacketParticles();
@ -54,8 +65,6 @@ public class PacketParticles implements IPacket {
} }
} }
public static class Handler {
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static void onMessage(PacketParticles message, Supplier<NetworkEvent.Context> ctx) { public static void onMessage(PacketParticles message, Supplier<NetworkEvent.Context> ctx) {
ctx.get().enqueueWork(() -> { ctx.get().enqueueWork(() -> {
@ -66,7 +75,6 @@ public class PacketParticles implements IPacket {
BlockPos pos = new BlockPos(message.posX, message.posY, message.posZ); BlockPos pos = new BlockPos(message.posX, message.posY, message.posZ);
Multiblocks.TREE_RITUAL.forEach(pos, 'G', (dustPos, matcher) -> { Multiblocks.TREE_RITUAL.forEach(pos, 'G', (dustPos, matcher) -> {
BlockState state = world.getBlockState(dustPos); BlockState state = world.getBlockState(dustPos);
//AxisAlignedBB box = state.getBoundingBox(world, dustPos); // TODO
AxisAlignedBB box = state.getShape(world, dustPos).getBoundingBox(); AxisAlignedBB box = state.getShape(world, dustPos).getBoundingBox();
NaturesAuraAPI.instance().spawnMagicParticle( NaturesAuraAPI.instance().spawnMagicParticle(
dustPos.getX() + box.minX + (box.maxX - box.minX) * world.rand.nextFloat(), dustPos.getX() + box.minX + (box.maxX - box.minX) * world.rand.nextFloat(),
@ -430,4 +438,3 @@ public class PacketParticles implements IPacket {
ctx.get().setPacketHandled(true); ctx.get().setPacketHandled(true);
} }
} }
}