mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 13:18:34 +01:00
some more misc fixes
This commit is contained in:
parent
8d064816ef
commit
8fb7beb49f
40 changed files with 714 additions and 674 deletions
|
@ -88,7 +88,7 @@ public final class Helper {
|
|||
List<ItemFrameEntity> frames = world.getEntitiesWithinAABB(ItemFrameEntity.class, new AxisAlignedBB(pos).grow(0.25));
|
||||
for (int i = frames.size() - 1; i >= 0; 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))
|
||||
frames.remove(i);
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
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")
|
||||
public boolean debugWorld = false;
|
||||
public boolean debugWorld = true;
|
||||
}
|
||||
|
||||
public static void initOrReload(boolean reload) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.api.multiblock;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
|
||||
|
@ -28,31 +29,8 @@ public class Matcher {
|
|||
return new Matcher(Blocks.AIR.getDefaultState(), null);
|
||||
}
|
||||
|
||||
public static Matcher oreDict(Block defaultBlock, String name) {
|
||||
return new Matcher(defaultBlock.getDefaultState(),
|
||||
(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 static Matcher tag(Block defaultBlock, Tag tag) {
|
||||
return new Matcher(defaultBlock.getDefaultState(), (world, start, offset, pos, state, c) -> state.getBlock().getTags().contains(tag.getId()));
|
||||
}
|
||||
|
||||
public interface ICheck {
|
||||
|
|
|
@ -2,6 +2,9 @@ package de.ellpeck.naturesaura.blocks;
|
|||
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
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.IModelProvider;
|
||||
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 (!worldIn.isRemote) {
|
||||
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;
|
||||
}
|
||||
|
@ -77,7 +80,7 @@ public class BlockDimensionRail extends AbstractRailBlock implements IModItem, I
|
|||
return;
|
||||
|
||||
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);
|
||||
|
||||
BlockPos goalCoords = this.getGoalCoords(world, pos);
|
||||
|
@ -118,7 +121,6 @@ public class BlockDimensionRail extends AbstractRailBlock implements IModItem, I
|
|||
return SHAPE;
|
||||
}
|
||||
|
||||
|
||||
public boolean isFlexibleRail(BlockState state, IBlockReader world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -98,10 +98,9 @@ public class BlockGoldenLeaves extends LeavesBlock implements
|
|||
}
|
||||
*/
|
||||
|
||||
|
||||
@Override
|
||||
public void tick(BlockState state, World worldIn, BlockPos pos, Random random) {
|
||||
super.tick(state, worldIn, pos, random);
|
||||
public void randomTick(BlockState state, World worldIn, BlockPos pos, Random random) {
|
||||
super.randomTick(state, worldIn, pos, random);
|
||||
if (!worldIn.isRemote) {
|
||||
int stage = state.get(STAGE);
|
||||
if (stage < HIGHEST_STAGE) {
|
||||
|
@ -118,8 +117,7 @@ public class BlockGoldenLeaves extends LeavesBlock implements
|
|||
|
||||
public static boolean convert(World world, BlockPos pos) {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock().isFoliage(state, world, pos) &&
|
||||
!(state.getBlock() instanceof BlockAncientLeaves || state.getBlock() instanceof BlockGoldenLeaves)) {
|
||||
if ((state.getBlock().isFoliage(state, world, pos) || state.getBlock() instanceof LeavesBlock) && !(state.getBlock() instanceof BlockAncientLeaves || state.getBlock() instanceof BlockGoldenLeaves)) {
|
||||
if (!world.isRemote) {
|
||||
world.setBlockState(pos, ModBlocks.GOLDEN_LEAVES.getDefaultState()
|
||||
.with(DISTANCE, state.has(DISTANCE) ? state.get(DISTANCE) : 1)
|
||||
|
|
|
@ -3,6 +3,8 @@ package de.ellpeck.naturesaura.blocks;
|
|||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||
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.material.Material;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
|
@ -43,9 +45,9 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
|
|||
|
||||
event.setCanceled(true);
|
||||
|
||||
/* if (item.world.getGameTime() % 3 == 0) TODO particles
|
||||
if (item.world.getGameTime() % 3 == 0)
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,8 +2,9 @@ package de.ellpeck.naturesaura.blocks;
|
|||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
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.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -13,6 +14,7 @@ import net.minecraft.util.SoundCategory;
|
|||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.ProjectileImpactEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
@ -30,15 +32,18 @@ public class BlockProjectileGenerator extends BlockContainerImpl/* implements IT
|
|||
Entity entity = event.getEntity();
|
||||
if (entity.world.isRemote)
|
||||
return;
|
||||
BlockRayTraceResult ray = (BlockRayTraceResult) event.getRayTraceResult();
|
||||
BlockPos pos = ray.getPos();
|
||||
RayTraceResult ray = event.getRayTraceResult();
|
||||
if (!(ray instanceof BlockRayTraceResult))
|
||||
return;
|
||||
BlockRayTraceResult blockRay = (BlockRayTraceResult) ray;
|
||||
BlockPos pos = blockRay.getPos();
|
||||
if (pos == null)
|
||||
return;
|
||||
TileEntity tile = entity.world.getTileEntity(pos);
|
||||
if (!(tile instanceof TileEntityProjectileGenerator))
|
||||
return;
|
||||
TileEntityProjectileGenerator generator = (TileEntityProjectileGenerator) tile;
|
||||
if (generator.nextSide != ray.getFace())
|
||||
if (generator.nextSide != blockRay.getFace())
|
||||
return;
|
||||
ResourceLocation name = ForgeRegistries.ENTITIES.getKey(entity.getType());
|
||||
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);
|
||||
IAuraChunk.getAuraChunk(entity.world, spot).storeAura(spot, amount);
|
||||
|
||||
// TODO particles
|
||||
/* PacketHandler.sendToAllAround(entity.world, pos, 32,
|
||||
new PacketParticles((float) entity.posX, (float) entity.posY, (float) entity.posZ, 26, pos.getX(), pos.getY(), pos.getZ()));*/
|
||||
PacketHandler.sendToAllAround(entity.world, pos, 32,
|
||||
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);
|
||||
|
||||
generator.nextSide = generator.nextSide.rotateY();
|
||||
|
|
|
@ -5,6 +5,8 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
|||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
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.material.Material;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
|
@ -55,9 +57,8 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable
|
|||
BlockPos spot = IAuraChunk.getHighestSpot(world, lampPos, 32, lampPos);
|
||||
IAuraChunk.getAuraChunk(world, spot).drainAura(spot, 200);
|
||||
|
||||
// TODO particles
|
||||
/*PacketHandler.sendToAllAround(world, lampPos, 32,
|
||||
new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), 15));*/
|
||||
PacketHandler.sendToAllAround(world, lampPos, 32,
|
||||
new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), 15));
|
||||
}
|
||||
|
||||
event.setResult(Event.Result.DENY);
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.block.Blocks;
|
|||
import net.minecraft.block.LogBlock;
|
||||
import net.minecraft.block.SaplingBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public final class Multiblocks {
|
||||
|
@ -23,7 +24,7 @@ public final class Multiblocks {
|
|||
{" ", " WBW ", " WBW ", " WWCWCWW ", " BBW WBB ", " WWCWCWW ", " WBW ", " WBW ", " "}},
|
||||
'C', Blocks.CHISELED_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,
|
||||
'0', ModBlocks.NATURE_ALTAR,
|
||||
' ', Matcher.wildcard());
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
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.util.math.BlockPos;
|
||||
|
||||
|
@ -28,8 +30,8 @@ public class TileEntityAnimalGenerator extends TileEntityImpl implements ITickab
|
|||
remain -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, remain);
|
||||
}
|
||||
|
||||
/*PacketHandler.sendToAllAround(this.world, this.pos, 32, TODO particles
|
||||
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 16));*/
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 16));
|
||||
}
|
||||
|
||||
this.timeRemaining -= 10;
|
||||
|
|
|
@ -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.recipes.AnimalSpawnerRecipe;
|
||||
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.item.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -87,9 +89,8 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
|||
|
||||
for (ItemEntity item : items) {
|
||||
item.remove();
|
||||
// TODO particles
|
||||
/*PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19));*/
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19));
|
||||
}
|
||||
|
||||
this.currentRecipe = recipe;
|
||||
|
|
|
@ -2,6 +2,8 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
|||
|
||||
import de.ellpeck.naturesaura.blocks.BlockAutoCrafter;
|
||||
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.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
@ -107,9 +109,8 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickableTi
|
|||
this.world.addEntity(remItem);
|
||||
}
|
||||
|
||||
// TODO particles
|
||||
/* PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19));*/
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
|||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.api.aura.container.BasicAuraContainer;
|
||||
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.entity.item.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -70,9 +72,8 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickableTile
|
|||
this.isDrainMode = true;
|
||||
item.remove();
|
||||
|
||||
// TODO particles
|
||||
/* PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 21, this.container.getAuraColor()));*/
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 21, this.container.getAuraColor()));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -3,6 +3,9 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
|||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.ModConfig;
|
||||
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.BlockState;
|
||||
import net.minecraft.entity.item.ItemFrameEntity;
|
||||
|
@ -154,8 +157,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickableT
|
|||
private void sendParticles() {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
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.getY() + 1 + this.world.rand.nextFloat() * 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.getZ() + 0.5F,
|
||||
this.world.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forWorld(this.world).getColor(), this.world.rand.nextFloat() + 0.5F
|
||||
));*/
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
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.ItemEntity;
|
||||
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.getZ());
|
||||
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,
|
||||
24, Ints.toArray(data)));*/
|
||||
24, Ints.toArray(data)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,13 +4,15 @@ import de.ellpeck.naturesaura.Helper;
|
|||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
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 de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
@ -77,10 +79,9 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab
|
|||
|
||||
this.world.removeBlock(pos, false);
|
||||
|
||||
// TODO particles
|
||||
int color = Helper.blendColors(0x5ccc30, 0xe53c16, toAdd / (float) addAmount);
|
||||
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(
|
||||
pos.getX() + 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.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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
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.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.FurnaceTileEntity;
|
||||
|
@ -44,8 +47,7 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable
|
|||
did = true;
|
||||
|
||||
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.getY() + 1 + this.world.rand.nextFloat() * 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.getZ() + this.world.rand.nextFloat(),
|
||||
this.world.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forWorld(this.world).getColor(), this.world.rand.nextFloat() + 0.5F
|
||||
));*/
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
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.entity.item.ItemEntity;
|
||||
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);
|
||||
IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 500);
|
||||
|
||||
// TODO particles
|
||||
/* PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 10));*/
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
|||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
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.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
|
@ -22,6 +23,7 @@ import net.minecraftforge.items.IItemHandler;
|
|||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class TileEntityImpl extends TileEntity {
|
||||
|
||||
|
@ -31,12 +33,6 @@ public class TileEntityImpl extends TileEntity {
|
|||
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
|
||||
public CompoundNBT write(CompoundNBT compound) {
|
||||
this.writeNBT(compound, SaveType.TILE);
|
||||
|
@ -92,11 +88,10 @@ public class TileEntityImpl extends TileEntity {
|
|||
}
|
||||
|
||||
public void sendToClients() {
|
||||
// TODO send this shit to the client somehow
|
||||
/* ServerWorld world = (ServerWorld) this.getWorld();
|
||||
Stream<ServerPlayerEntity> entities = world.getChunkProvider().chunkManager.getTrackingPlayers(new ChunkPos(this.getPos().getX() >> 4, this.getPos().getZ() >> 4), false);
|
||||
ServerWorld world = (ServerWorld) this.getWorld();
|
||||
Stream<ServerPlayerEntity> entities = world.getChunkProvider().chunkManager.getTrackingPlayers(new ChunkPos(this.getPos()), false);
|
||||
SUpdateTileEntityPacket packet = this.getUpdatePacket();
|
||||
entities.forEach(()-> packet.packet);*/
|
||||
entities.forEach(e -> e.connection.sendPacket(packet));
|
||||
}
|
||||
|
||||
public IItemHandlerModifiable getItemHandler(Direction facing) {
|
||||
|
|
|
@ -2,6 +2,8 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
|||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
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.BlockState;
|
||||
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);
|
||||
}
|
||||
|
||||
// TODO particles
|
||||
/*PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), 23));*/
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), 23));
|
||||
}
|
||||
|
||||
this.world.playEvent(2001, offset, Block.getStateId(state));
|
||||
|
|
|
@ -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.recipes.AltarRecipe;
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
|
@ -100,15 +103,14 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi
|
|||
chunk.drainAura(spot, toStore);
|
||||
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(
|
||||
this.pos.getX() + (float) rand.nextGaussian() * 10F,
|
||||
this.pos.getY() + rand.nextFloat() * 10F,
|
||||
this.pos.getZ() + (float) rand.nextGaussian() * 10F,
|
||||
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
|
||||
));*/
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,10 +123,8 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi
|
|||
if (stored > 0) {
|
||||
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));
|
||||
*/
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -141,10 +141,8 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi
|
|||
if (this.container.getStoredAura() >= req) {
|
||||
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));
|
||||
*/
|
||||
|
||||
this.timer++;
|
||||
if (this.timer >= this.currentRecipe.time) {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
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.tileentity.ITickableTileEntity;
|
||||
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);
|
||||
}
|
||||
|
||||
// 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,
|
||||
pos.getX(), pos.getY(), pos.getZ(), canGen ? 1 : 0));*/
|
||||
pos.getX(), pos.getY(), pos.getZ(), canGen ? 1 : 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import de.ellpeck.naturesaura.Helper;
|
|||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.recipes.OfferingRecipe;
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
|
@ -74,10 +76,9 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable
|
|||
|
||||
// TODO weather effects
|
||||
//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,
|
||||
this.pos.getX(), this.pos.getY(), this.pos.getZ()));*/
|
||||
this.pos.getX(), this.pos.getY(), this.pos.getZ()));
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
|||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
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.Blocks;
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -2,10 +2,13 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
|||
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
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.potion.Effect;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionUtils;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
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);
|
||||
}
|
||||
|
||||
// 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,
|
||||
PotionUtils.getPotionColor(type), canGen ? 1 : 0));*/
|
||||
PotionUtils.getPotionColor(type), canGen ? 1 : 0));
|
||||
|
||||
addedOne = true;
|
||||
break;
|
||||
|
|
|
@ -3,6 +3,8 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
|||
import de.ellpeck.naturesaura.ModConfig;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
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.tileentity.ITickableTileEntity;
|
||||
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);
|
||||
IAuraChunk.getAuraChunk(this.world, pos).drainAura(pos, amountToUse);
|
||||
|
||||
// TODO particles
|
||||
/*PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 20));*/
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 20));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public class TileEntityTimeChanger extends TileEntityImpl implements ITickableTi
|
|||
continue;
|
||||
|
||||
if (this.goalTime > 0) {
|
||||
long current = this.world.getGameTime();
|
||||
long current = this.world.getDayTime();
|
||||
long toAdd = Math.min(75, this.goalTime - current);
|
||||
if (toAdd <= 0) {
|
||||
this.goalTime = 0;
|
||||
|
@ -93,7 +93,7 @@ public class TileEntityTimeChanger extends TileEntityImpl implements ITickableTi
|
|||
this.sendToClients();
|
||||
}
|
||||
} 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 z = this.pos.getZ() + 0.5 + Math.cos(angle) * 3F;
|
||||
int color = this.goalTime % 24000 > 12000 ? 0xe2e2e2 : 0xffe926;
|
||||
|
|
|
@ -3,6 +3,9 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
|||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
|
||||
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.Blocks;
|
||||
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) -> {
|
||||
TileEntity tile = this.world.getTileEntity(pos);
|
||||
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.getY() + 0.85F,
|
||||
(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.world.rand.nextFloat() * 0.04F + 0.04F, 0x89cc37, this.world.rand.nextFloat() * 1F + 1F
|
||||
));*/
|
||||
));
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
/* PacketHandler.sendToAllAround(this.world, this.ritualPos, 32,
|
||||
new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), 0));*/
|
||||
PacketHandler.sendToAllAround(this.world, this.ritualPos, 32,
|
||||
new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), 0));
|
||||
|
||||
if (this.timer >= this.recipe.time) {
|
||||
this.recurseTreeDestruction(this.ritualPos, this.ritualPos);
|
||||
|
@ -88,8 +90,8 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
|
|||
this.recipe.result.copy());
|
||||
this.world.addEntity(item);
|
||||
|
||||
/*PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 3));*/
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
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,
|
||||
SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 0.65F, 1F);
|
||||
|
||||
|
@ -102,8 +104,8 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
|
|||
if (tile instanceof TileEntityWoodStand) {
|
||||
TileEntityWoodStand stand = (TileEntityWoodStand) tile;
|
||||
if (!stand.items.getStackInSlot(0).isEmpty()) {
|
||||
/* PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles(stand.pos.getX(), stand.pos.getY(), stand.pos.getZ(), 1));*/
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
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,
|
||||
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);
|
||||
if (state.getBlock() instanceof LogBlock || state.getBlock() instanceof LeavesBlock) {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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.IDrainSpotEffect;
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
|
@ -12,6 +14,7 @@ import net.minecraft.nbt.ListNBT;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import org.apache.commons.lang3.mutable.MutableInt;
|
||||
|
@ -113,8 +116,9 @@ public class AuraChunk implements IAuraChunk {
|
|||
private void addDrainSpot(BlockPos pos, MutableInt spot) {
|
||||
int expX = pos.getX() >> 4;
|
||||
int expZ = pos.getZ() >> 4;
|
||||
if (expX != this.chunk.getPos().x || expZ != this.chunk.getPos().z)
|
||||
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);
|
||||
ChunkPos myPos = this.chunk.getPos();
|
||||
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);
|
||||
}
|
||||
|
@ -147,19 +151,18 @@ public class AuraChunk implements IAuraChunk {
|
|||
}
|
||||
|
||||
if (this.needsSync) {
|
||||
// TODO packets
|
||||
/*PacketHandler.sendToAllLoaded(world,
|
||||
new BlockPos(this.chunk.x * 16, 0, this.chunk.z * 16),
|
||||
this.makePacket());*/
|
||||
ChunkPos pos = this.chunk.getPos();
|
||||
PacketHandler.sendToAllLoaded(world,
|
||||
new BlockPos(pos.x * 16, 0, pos.z * 16),
|
||||
this.makePacket());
|
||||
this.needsSync = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public IMessage makePacket() {
|
||||
return new PacketAuraChunk(this.chunk.x, this.chunk.z, this.drainSpots);
|
||||
public PacketAuraChunk makePacket() {
|
||||
ChunkPos pos = this.chunk.getPos();
|
||||
return new PacketAuraChunk(pos.x, pos.z, this.drainSpots);
|
||||
}
|
||||
*/
|
||||
|
||||
public void getSpotsInArea(BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer) {
|
||||
for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) {
|
||||
|
|
|
@ -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.IDrainSpotEffect;
|
||||
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.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -75,9 +77,8 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
|||
BlockPos closestSpot = IAuraChunk.getHighestSpot(world, plantPos, 25, pos);
|
||||
IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 3500);
|
||||
|
||||
// TODO particles
|
||||
/* PacketHandler.sendToAllAround(world, plantPos, 32,
|
||||
new PacketParticles(plantPos.getX(), plantPos.getY(), plantPos.getZ(), 6));*/
|
||||
PacketHandler.sendToAllAround(world, plantPos, 32,
|
||||
new PacketParticles(plantPos.getX(), plantPos.getY(), plantPos.getZ(), 6));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package de.ellpeck.naturesaura.entities;
|
|||
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
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.Blocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -48,10 +50,9 @@ public class EntityMoverMinecart extends AbstractMinecartEntity {
|
|||
BlockPos pos = this.getPosition();
|
||||
|
||||
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,
|
||||
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)
|
||||
return;
|
||||
|
|
|
@ -16,6 +16,7 @@ import de.ellpeck.naturesaura.compat.Compat;
|
|||
import de.ellpeck.naturesaura.items.AuraCache;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.items.RangeVisualizer;
|
||||
import de.ellpeck.naturesaura.packet.PacketAuraChunk;
|
||||
import de.ellpeck.naturesaura.particles.ParticleHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -54,6 +55,7 @@ import org.apache.commons.lang3.mutable.MutableInt;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
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");
|
||||
private static final ItemStack ITEM_FRAME = new ItemStack(Items.ITEM_FRAME);
|
||||
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 heldEye = ItemStack.EMPTY;
|
||||
private static ItemStack heldOcular = ItemStack.EMPTY;
|
||||
private float height;
|
||||
private float previousHeight;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDebugRender(RenderGameOverlayEvent.Text event) {
|
||||
|
@ -97,13 +102,12 @@ public class ClientEvents {
|
|||
|
||||
@SubscribeEvent
|
||||
public void onRenderLast(RenderWorldLastEvent event) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
ParticleHandler.renderParticles(event.getPartialTicks());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onClientTick(TickEvent.ClientTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
if (event.phase != TickEvent.Phase.END) {
|
||||
heldCache = ItemStack.EMPTY;
|
||||
heldEye = ItemStack.EMPTY;
|
||||
heldOcular = ItemStack.EMPTY;
|
||||
|
@ -112,7 +116,16 @@ public class ClientEvents {
|
|||
if (mc.world == null) {
|
||||
ParticleHandler.clearParticles();
|
||||
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) {
|
||||
int amount = MathHelper.floor(190 * ModConfig.client.excessParticleAmount);
|
||||
for (int i = 0; i < amount; i++) {
|
||||
|
@ -195,6 +208,7 @@ public class ClientEvents {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldRender(RenderWorldLastEvent event) {
|
||||
|
@ -203,7 +217,7 @@ public class ClientEvents {
|
|||
float partial = event.getPartialTicks();
|
||||
GL11.glTranslated(
|
||||
-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);
|
||||
|
||||
if (mc.gameSettings.showDebugInfo && mc.player.isCreative() && ModConfig.client.debugWorld) {
|
||||
|
@ -271,7 +285,8 @@ public class ClientEvents {
|
|||
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);
|
||||
if (box == null)
|
||||
return;
|
||||
|
@ -306,7 +321,7 @@ public class ClientEvents {
|
|||
float scale = 0.75F;
|
||||
GlStateManager.scalef(scale, scale, scale);
|
||||
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.popMatrix();
|
||||
|
@ -357,13 +372,13 @@ public class ClientEvents {
|
|||
|
||||
int color = heldOcular.isEmpty() ? 0x53a008 : 0xa05308;
|
||||
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))
|
||||
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.scalef(textScale, textScale, textScale);
|
||||
mc.fontRenderer.drawString(text, textX / textScale, textY / textScale, 0x53a008);
|
||||
mc.fontRenderer.drawStringWithShadow(text, textX / textScale, textY / textScale, 0x53a008);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
if (!heldOcular.isEmpty()) {
|
||||
|
@ -398,7 +413,7 @@ public class ClientEvents {
|
|||
BlockState state = mc.world.getBlockState(pos);
|
||||
ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.world, pos, mc.player);
|
||||
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) {
|
||||
ItemStack tileStack = ((TileEntityNatureAltar) tile).getItemHandler(null).getStackInSlot(0);
|
||||
|
@ -406,7 +421,7 @@ public class ClientEvents {
|
|||
IAuraContainer stackCont = tileStack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||
if (stackCont != null) {
|
||||
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 y = res.getScaledHeight() / 2;
|
||||
if (stack.isEmpty())
|
||||
mc.fontRenderer.drawString(
|
||||
mc.fontRenderer.drawStringWithShadow(
|
||||
TextFormatting.GRAY.toString() + TextFormatting.ITALIC + I18n.format("info.naturesaura.empty"),
|
||||
x + 5, y - 11, 0xFFFFFF);
|
||||
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);
|
||||
|
||||
int x = res.getScaledWidth() / 2 - 40;
|
||||
|
@ -458,9 +475,9 @@ public class ClientEvents {
|
|||
if (width > 0)
|
||||
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)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,16 +7,26 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
|||
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
||||
import de.ellpeck.naturesaura.chunk.AuraChunkProvider;
|
||||
import de.ellpeck.naturesaura.misc.WorldData;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
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.TickEvent;
|
||||
import net.minecraftforge.event.world.ChunkWatchEvent;
|
||||
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 {
|
||||
|
||||
private static final Method GET_LOADED_CHUNKS_METHOD = ObfuscationReflectionHelper.findMethod(ChunkManager.class, "func_223491_f");
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChunkCapsAttach(AttachCapabilitiesEvent<Chunk> event) {
|
||||
Chunk chunk = event.getObject();
|
||||
|
@ -32,13 +42,22 @@ public class CommonEvents {
|
|||
public void onWorldTick(TickEvent.WorldTickEvent event) {
|
||||
if (!event.world.isRemote && event.phase == TickEvent.Phase.END) {
|
||||
if (event.world.getGameTime() % 20 == 0) {
|
||||
// TODO update loaded aura chunks
|
||||
/*Iterator<Chunk> chunks = event.world.getPersistentChunkIterable(((ServerWorld) event.world).getPlayerChunkMap().getChunkIterator());
|
||||
while (chunks.hasNext()) {
|
||||
Chunk chunk = chunks.next();
|
||||
event.world.getProfiler().startSection(NaturesAura.MOD_ID + ":onWorldTick");
|
||||
try {
|
||||
ChunkManager manager = ((ServerChunkProvider) event.world.getChunkProvider()).chunkManager;
|
||||
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);
|
||||
if (auraChunk != null)
|
||||
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);
|
||||
if (!chunk.getWorld().isRemote) {
|
||||
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
|
||||
// TODO packets
|
||||
/*if (auraChunk != null)
|
||||
PacketHandler.sendTo(event.getPlayer(), auraChunk.makePacket());*/
|
||||
if (auraChunk != null)
|
||||
PacketHandler.sendTo(event.getPlayer(), auraChunk.makePacket());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ import de.ellpeck.naturesaura.NaturesAura;
|
|||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.render.ITrinketItem;
|
||||
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.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -105,7 +107,7 @@ public class ShockwaveCreator extends ItemImpl implements ITrinketItem {
|
|||
if (worldIn instanceof ServerWorld)
|
||||
((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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
package de.ellpeck.naturesaura.packet;
|
||||
|
||||
public interface IPacket {
|
||||
}
|
|
@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.packet;
|
|||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
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.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -16,12 +16,21 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PacketAuraChunk implements IPacket {
|
||||
public class PacketAuraChunk {
|
||||
|
||||
private int chunkX;
|
||||
private int chunkZ;
|
||||
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) {
|
||||
PacketAuraChunk packet = new PacketAuraChunk();
|
||||
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)
|
||||
public static void onMessage(PacketAuraChunk message, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
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().enqueueWork(() -> ClientEvents.PENDING_AURA_CHUNKS.add(message));
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,11 +11,19 @@ import net.minecraftforge.fml.network.NetworkEvent;
|
|||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PacketClient implements IPacket {
|
||||
|
||||
public class PacketClient {
|
||||
private int type;
|
||||
private int[] data;
|
||||
|
||||
public PacketClient(int type, int... data) {
|
||||
this.type = type;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
private PacketClient() {
|
||||
|
||||
}
|
||||
|
||||
public static PacketClient fromBytes(PacketBuffer buf) {
|
||||
PacketClient client = new PacketClient();
|
||||
client.type = buf.readByte();
|
||||
|
@ -33,8 +41,6 @@ public class PacketClient implements IPacket {
|
|||
buf.writeInt(i);
|
||||
}
|
||||
|
||||
public static class Handler {
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void onMessage(PacketClient message, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
|
@ -48,8 +54,6 @@ public class PacketClient implements IPacket {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,37 +12,26 @@ import net.minecraftforge.fml.network.simple.SimpleChannel;
|
|||
|
||||
public final class PacketHandler {
|
||||
|
||||
private static String version = "1";
|
||||
private static final String VERSION = "1";
|
||||
private static SimpleChannel network;
|
||||
|
||||
public static void init() {
|
||||
network = NetworkRegistry.newSimpleChannel(
|
||||
NaturesAura.createRes("network"),
|
||||
() -> version,
|
||||
version::equals,
|
||||
version::equals);
|
||||
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);
|
||||
network = NetworkRegistry.newSimpleChannel(NaturesAura.createRes("network"), () -> VERSION, VERSION::equals, VERSION::equals);
|
||||
network.registerMessage(0, PacketParticleStream.class, PacketParticleStream::toBytes, PacketParticleStream::fromBytes, PacketParticleStream::onMessage);
|
||||
network.registerMessage(1, PacketParticles.class, PacketParticles::toBytes, PacketParticles::fromBytes, PacketParticles::onMessage);
|
||||
network.registerMessage(2, PacketAuraChunk.class, PacketAuraChunk::toBytes, PacketAuraChunk::fromBytes, PacketAuraChunk::onMessage);
|
||||
network.registerMessage(3, PacketClient.class, PacketClient::toBytes, PacketClient::fromBytes, PacketClient::onMessage);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void sendToAllLoaded(World world, BlockPos pos, IPacket message) {
|
||||
sendToAllLoaded(message);
|
||||
public static void sendToAllLoaded(World world, BlockPos pos, Object message) {
|
||||
network.send(PacketDistributor.TRACKING_CHUNK.with(() -> world.getChunkAt(pos)), message);
|
||||
}
|
||||
|
||||
public static void sendToAllLoaded(IPacket message) {
|
||||
network.send(PacketDistributor.ALL.noArg(), message);
|
||||
public static void sendToAllAround(IWorld world, BlockPos pos, int range, Object 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) {
|
||||
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) {
|
||||
public static void sendTo(PlayerEntity player, Object message) {
|
||||
network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package de.ellpeck.naturesaura.packet;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
@ -10,7 +8,7 @@ import net.minecraftforge.fml.network.NetworkEvent;
|
|||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PacketParticleStream implements IPacket {
|
||||
public class PacketParticleStream {
|
||||
|
||||
private float startX;
|
||||
private float startY;
|
||||
|
@ -36,8 +34,7 @@ public class PacketParticleStream implements IPacket {
|
|||
this.scale = scale;
|
||||
}
|
||||
|
||||
public PacketParticleStream() {
|
||||
|
||||
private PacketParticleStream() {
|
||||
}
|
||||
|
||||
public static PacketParticleStream fromBytes(PacketBuffer buf) {
|
||||
|
@ -68,8 +65,6 @@ public class PacketParticleStream implements IPacket {
|
|||
buf.writeFloat(packet.scale);
|
||||
}
|
||||
|
||||
public static class Handler {
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void onMessage(PacketParticleStream message, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> NaturesAuraAPI.instance().spawnParticleStream(
|
||||
|
@ -80,4 +75,3 @@ public class PacketParticleStream implements IPacket {
|
|||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import net.minecraftforge.fml.network.NetworkEvent;
|
|||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PacketParticles implements IPacket {
|
||||
public class PacketParticles {
|
||||
|
||||
private float posX;
|
||||
private float posY;
|
||||
|
@ -26,6 +26,17 @@ public class PacketParticles implements IPacket {
|
|||
private int type;
|
||||
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) {
|
||||
PacketParticles packet = new PacketParticles();
|
||||
|
||||
|
@ -54,8 +65,6 @@ public class PacketParticles implements IPacket {
|
|||
}
|
||||
}
|
||||
|
||||
public static class Handler {
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void onMessage(PacketParticles message, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
|
@ -66,7 +75,6 @@ public class PacketParticles implements IPacket {
|
|||
BlockPos pos = new BlockPos(message.posX, message.posY, message.posZ);
|
||||
Multiblocks.TREE_RITUAL.forEach(pos, 'G', (dustPos, matcher) -> {
|
||||
BlockState state = world.getBlockState(dustPos);
|
||||
//AxisAlignedBB box = state.getBoundingBox(world, dustPos); // TODO
|
||||
AxisAlignedBB box = state.getShape(world, dustPos).getBoundingBox();
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
dustPos.getX() + box.minX + (box.maxX - box.minX) * world.rand.nextFloat(),
|
||||
|
@ -430,4 +438,3 @@ public class PacketParticles implements IPacket {
|
|||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue