aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTec <daniel112092@gmail.com>2019-07-15 09:54:07 +0200
committerTec <daniel112092@gmail.com>2019-07-15 09:54:07 +0200
commitcf618db325bceec9b90887ec2b37db800ea7704f (patch)
tree5b99ea8cc4cede39d4a750ca1a64605f3aea070c
parent150f34aebae02b71ffc6eba115c3910c69f37885 (diff)
downloadGT5-Unofficial-cf618db325bceec9b90887ec2b37db800ea7704f.tar.gz
GT5-Unofficial-cf618db325bceec9b90887ec2b37db800ea7704f.tar.bz2
GT5-Unofficial-cf618db325bceec9b90887ec2b37db800ea7704f.zip
Spawn particles only around ThePlayer not all
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java65
1 files changed, 55 insertions, 10 deletions
diff --git a/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java b/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java
index df6bfa7801..ce79c42003 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/anomaly/AnomalyHandler.java
@@ -6,17 +6,31 @@ import com.github.technus.tectech.chunkData.IChunkMetaDataHandler;
import com.github.technus.tectech.loader.network.ChunkDataMessage;
import com.github.technus.tectech.loader.network.NetworkDispatcher;
import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition;
+import cpw.mods.fml.common.eventhandler.EventPriority;
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
+import crazypants.util.BaublesUtil;
+import crazypants.util.GalacticraftUtil;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import net.minecraft.block.Block;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityClientPlayerMP;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
+import net.minecraftforge.common.util.FakePlayer;
+import net.minecraftforge.event.entity.player.PlayerDropsEvent;
+import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.world.ChunkEvent;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.ListIterator;
public class AnomalyHandler implements IChunkMetaDataHandler {
private static final double SWAP_THRESHOLD = dAtomDefinition.getSomethingHeavy().getMass() * 10000D;
@@ -95,23 +109,24 @@ public class AnomalyHandler implements IChunkMetaDataHandler {
@Override
public void tickPlayer(HashMap<Integer, ChunkDataHandler.ChunkHashMap> data, TickEvent.PlayerTickEvent aEvent) {
if (aEvent.side.isClient()) {
- ChunkCoordIntPair pair = new ChunkCoordIntPair(aEvent.player.chunkCoordX, aEvent.player.chunkCoordZ);
- NBTTagCompound compound = data.get(aEvent.player.worldObj.provider.dimensionId).get(pair);
+ EntityClientPlayerMP player=Minecraft.getMinecraft().thePlayer;
+ ChunkCoordIntPair pair = new ChunkCoordIntPair(player.chunkCoordX, player.chunkCoordZ);
+ NBTTagCompound compound = data.get(player.worldObj.provider.dimensionId).get(pair);
if (compound != null) {
for (int i = 0, pow = (int)Math.min(32,compound.getDouble(INTENSITY) / PER_PARTICLE); i < pow; i++) {
- TecTech.proxy.em_particle(aEvent.player.worldObj,
- aEvent.player.posX - 32D + TecTech.RANDOM.nextFloat() * 64D,
- aEvent.player.posY - 32D + TecTech.RANDOM.nextFloat() * 64D,
- aEvent.player.posZ - 32D + TecTech.RANDOM.nextFloat() * 64D);
+ TecTech.proxy.em_particle(player.worldObj,
+ player.posX - 32D + TecTech.RANDOM.nextFloat() * 64D,
+ player.posY - 32D + TecTech.RANDOM.nextFloat() * 64D,
+ player.posZ - 32D + TecTech.RANDOM.nextFloat() * 64D);
}
}
- data.get(aEvent.player.worldObj.provider.dimensionId).forEach((chunkCoordIntPair, dat) -> {
- if (Math.abs(chunkCoordIntPair.getCenterXPos() - aEvent.player.posX) + Math.abs(chunkCoordIntPair.getCenterZPosition() - aEvent.player.posZ) < 256) {
+ data.get(player.worldObj.provider.dimensionId).forEach((chunkCoordIntPair, dat) -> {
+ if (Math.abs(chunkCoordIntPair.getCenterXPos() - player.posX) + Math.abs(chunkCoordIntPair.getCenterZPosition() - player.posZ) < 256) {
for (int i = 0, pow = (int)Math.min(32,dat.getDouble(INTENSITY) / PER_PARTICLE); i < pow; i++) {
- TecTech.proxy.em_particle(aEvent.player.worldObj,
+ TecTech.proxy.em_particle(player.worldObj,
(chunkCoordIntPair.chunkXPos << 4) + TecTech.RANDOM.nextFloat() * 48D - 16D,
- aEvent.player.posY + TecTech.RANDOM.nextFloat() * 128D - 64D,
+ player.posY + TecTech.RANDOM.nextFloat() * 128D - 64D,
(chunkCoordIntPair.chunkZPos << 4) + TecTech.RANDOM.nextFloat() * 48D - 16D);
}
}
@@ -120,6 +135,13 @@ public class AnomalyHandler implements IChunkMetaDataHandler {
}
@Override
+ public void tickServer(HashMap<Integer, ChunkDataHandler.ChunkHashMap> data, TickEvent.ServerTickEvent event) {
+ if(event.side.isServer()){
+
+ }
+ }
+
+ @Override
public void pullData(ChunkEvent.Load aEvent) {
NetworkDispatcher.INSTANCE.sendToServer(new ChunkDataMessage.ChunkDataQuery(aEvent, this));
}
@@ -157,4 +179,27 @@ public class AnomalyHandler implements IChunkMetaDataHandler {
}
TecTech.chunkDataHandler.getChunkData(this, world).markForTransmissionToClient(chunk);
}
+
+ @SubscribeEvent
+ public void onPlayerClone(PlayerEvent.Clone evt) {
+ if (evt.wasDeath && !evt.isCanceled()) {
+ if (evt.original != null && evt.entityPlayer != null && !(evt.entityPlayer instanceof FakePlayer)) {
+ int i;
+ ItemStack item;
+ for (i = 0; i < evt.original.field_71071_by.field_70462_a.length; ++i) {
+ item = evt.original.field_71071_by.field_70462_a[i];
+ if (this.isSoulBound(item) && this.addToPlayerInventory(evt.entityPlayer, item)) {
+ evt.original.field_71071_by.field_70462_a[i] = null;
+ }
+ }
+
+ for (i = 0; i < evt.original.field_71071_by.field_70460_b.length; ++i) {
+ item = evt.original.field_71071_by.field_70460_b[i];
+ if (this.isSoulBound(item) && this.addToPlayerInventory(evt.entityPlayer, item)) {
+ evt.original.field_71071_by.field_70460_b[i] = null;
+ }
+ }
+ }
+ }
+ }
}