From b2d44dfbbb714fcb30a526a20405e9436855a233 Mon Sep 17 00:00:00 2001 From: Tec Date: Tue, 16 Jul 2019 12:07:50 +0200 Subject: Do not unload in SSP --- .../technus/tectech/mechanics/data/ChunkDataHandler.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/technus/tectech/mechanics/data/ChunkDataHandler.java b/src/main/java/com/github/technus/tectech/mechanics/data/ChunkDataHandler.java index f6d84d6b12..8109db9b86 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/data/ChunkDataHandler.java +++ b/src/main/java/com/github/technus/tectech/mechanics/data/ChunkDataHandler.java @@ -5,6 +5,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.ChunkCoordIntPair; import net.minecraftforge.event.world.ChunkDataEvent; @@ -102,10 +103,12 @@ public class ChunkDataHandler { @SideOnly(Side.CLIENT) @SubscribeEvent public void onUnLoadChunk(ChunkEvent.Unload aEvent){ - pullSyncHandlers.forEach(chunkMetaDataHandler -> dimensionWiseMetaChunkData - .get(chunkMetaDataHandler.getTagName()) - .get(aEvent.world.provider.dimensionId) - .remove(aEvent.getChunk().getChunkCoordIntPair())); + if(aEvent.world.isRemote && !Minecraft.getMinecraft().isSingleplayer()) { + pullSyncHandlers.forEach(chunkMetaDataHandler -> dimensionWiseMetaChunkData + .get(chunkMetaDataHandler.getTagName()) + .get(aEvent.world.provider.dimensionId) + .remove(aEvent.getChunk().getChunkCoordIntPair())); + } } @SideOnly(Side.CLIENT) -- cgit From ba2ebe760a7000b058ef504505d73aabefc6a576 Mon Sep 17 00:00:00 2001 From: Tec Date: Tue, 16 Jul 2019 12:14:14 +0200 Subject: Change Cancer Command --- .../tectech/mechanics/anomaly/CancerCommand.java | 90 ++++++++++++++++++++++ .../tectech/mechanics/commands/CancerCommand.java | 87 --------------------- 2 files changed, 90 insertions(+), 87 deletions(-) create mode 100644 src/main/java/com/github/technus/tectech/mechanics/anomaly/CancerCommand.java delete mode 100644 src/main/java/com/github/technus/tectech/mechanics/commands/CancerCommand.java diff --git a/src/main/java/com/github/technus/tectech/mechanics/anomaly/CancerCommand.java b/src/main/java/com/github/technus/tectech/mechanics/anomaly/CancerCommand.java new file mode 100644 index 0000000000..c19cca64d5 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/anomaly/CancerCommand.java @@ -0,0 +1,90 @@ +package com.github.technus.tectech.mechanics.anomaly; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.loader.NetworkDispatcher; +import com.github.technus.tectech.mechanics.data.PlayerDataMessage; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentText; + +import java.util.ArrayList; +import java.util.List; + +import static com.github.technus.tectech.mechanics.anomaly.AnomalyHandler.SPACE_CANCER; + +public class CancerCommand implements ICommand { + ArrayList aliases=new ArrayList<>(); + + public CancerCommand(){ + aliases.add("cancer_EM"); + aliases.add("cancer"); + aliases.add("sanser"); + aliases.add("sancer"); + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + if (sender instanceof EntityPlayerMP && !sender.getEntityWorld().isRemote) { + double amount; + try { + amount = Double.parseDouble(args[0]); + }catch (NumberFormatException e){ + sender.addChatMessage(new ChatComponentText("Cannot parse amount!")); + return; + } + if(amount<0||amount>2){ + sender.addChatMessage(new ChatComponentText("Invalid amount provided!")); + return; + } + EntityPlayerMP player=(EntityPlayerMP)sender; + NBTTagCompound playerTag = TecTech.playerPersistence.getDataOrSetToNewTag(player); + if(player.capabilities.isCreativeMode){ + sender.addChatMessage(new ChatComponentText("Doesn't really work in creative mode!")); + }else { + playerTag.setDouble(SPACE_CANCER, amount); + TecTech.playerPersistence.saveData(player); + NetworkDispatcher.INSTANCE.sendTo(new PlayerDataMessage.PlayerDataData(player), player); + } + } + } + + @Override + public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) { + return false; + } + + @Override + public List getCommandAliases() { + return aliases; + } + + @Override + public String getCommandName() { + return aliases.get(0); + } + + @Override + public List addTabCompletionOptions(ICommandSender sender, String[] args) { + return null; + } + + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return "cancer_EM [Amount 0.0-2.0]"; + } + + @Override + public int compareTo(Object o) { + if(o instanceof ICommand){ + return getCommandName().compareTo(((ICommand) o).getCommandName()); + } + return 0; + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender sender) { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/commands/CancerCommand.java b/src/main/java/com/github/technus/tectech/mechanics/commands/CancerCommand.java deleted file mode 100644 index 64caeb1caf..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/commands/CancerCommand.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.github.technus.tectech.mechanics.commands; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.loader.NetworkDispatcher; -import com.github.technus.tectech.mechanics.data.PlayerDataMessage; -import net.minecraft.command.ICommand; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ChatComponentText; - -import java.util.ArrayList; -import java.util.List; - -import static com.github.technus.tectech.mechanics.anomaly.AnomalyHandler.SPACE_CANCER; - -public class CancerCommand implements ICommand { - ArrayList aliases=new ArrayList<>(); - - public CancerCommand(){ - aliases.add("cancer"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - if (sender instanceof EntityPlayerMP && !sender.getEntityWorld().isRemote) { - double amount; - try { - amount = Double.parseDouble(args[0]); - }catch (NumberFormatException e){ - sender.addChatMessage(new ChatComponentText("Cannot parse amount!")); - return; - } - if(amount<0||amount>2){ - sender.addChatMessage(new ChatComponentText("Invalid amount provided!")); - return; - } - EntityPlayerMP player=(EntityPlayerMP)sender; - NBTTagCompound playerTag = TecTech.playerPersistence.getDataOrSetToNewTag(player); - if(player.capabilities.isCreativeMode){ - sender.addChatMessage(new ChatComponentText("Doesn't really work in creative mode!")); - }else { - playerTag.setDouble(SPACE_CANCER, amount); - TecTech.playerPersistence.saveData(player); - NetworkDispatcher.INSTANCE.sendTo(new PlayerDataMessage.PlayerDataData(player), player); - } - } - } - - @Override - public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) { - return false; - } - - @Override - public List getCommandAliases() { - return aliases; - } - - @Override - public String getCommandName() { - return aliases.get(0); - } - - @Override - public List addTabCompletionOptions(ICommandSender sender, String[] args) { - return null; - } - - @Override - public String getCommandUsage(ICommandSender p_71518_1_) { - return "cancer [Amount 0.0-2.0]"; - } - - @Override - public int compareTo(Object o) { - if(o instanceof ICommand){ - return getCommandName().compareTo(((ICommand) o).getCommandName()); - } - return 0; - } - - @Override - public boolean canCommandSenderUseCommand(ICommandSender sender) { - return true; - } -} -- cgit From a26324b8d84f1185d1452ff6ce77f1978efad2e7 Mon Sep 17 00:00:00 2001 From: Tec Date: Tue, 16 Jul 2019 12:14:42 +0200 Subject: Add proxy get Player --- src/main/java/com/github/technus/tectech/proxy/ClientProxy.java | 6 ++++++ src/main/java/com/github/technus/tectech/proxy/CommonProxy.java | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java index 255cf56e96..d66cc8bf82 100644 --- a/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java +++ b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java @@ -14,6 +14,7 @@ import cpw.mods.fml.common.Loader; 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.client.gui.FontRenderer; import net.minecraft.client.gui.GuiNewChat; import net.minecraft.client.particle.EntityExplodeFX; @@ -138,4 +139,9 @@ public class ClientProxy extends CommonProxy { public void renderAABB(AxisAlignedBB box) { renderAABB(Minecraft.getMinecraft().theWorld,box); } + + @Override + public EntityClientPlayerMP getPlayer(){ + return Minecraft.getMinecraft().thePlayer; + } } diff --git a/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java b/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java index 598a8b148f..6f5f367d7f 100644 --- a/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java +++ b/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java @@ -81,4 +81,8 @@ public class CommonProxy implements IGuiHandler { } return false; } + + public EntityPlayer getPlayer(){ + return null; + } } -- cgit From ce2ee8cb6a41031d4b1b4912a0d6017feaf68840 Mon Sep 17 00:00:00 2001 From: Tec Date: Tue, 16 Jul 2019 12:15:06 +0200 Subject: Remove that print line --- .../com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java b/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java index 8e2a1c1a9b..15567bc477 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java +++ b/src/main/java/com/github/technus/tectech/thing/item/FrontRotationTriggerItem.java @@ -40,7 +40,6 @@ public final class FrontRotationTriggerItem extends Item { IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); if (metaTE instanceof IFrontRotation) { ((IFrontRotation) metaTE).rotateAroundFrontPlane(!aPlayer.isSneaking()); - System.out.println("DID SHIT"); return true; } } else if (tTileEntity instanceof IFrontRotation) { -- cgit From 312baeb8c15e01551885606989a2a3268b89573c Mon Sep 17 00:00:00 2001 From: Tec Date: Tue, 16 Jul 2019 12:19:20 +0200 Subject: Update imports --- src/main/java/com/github/technus/tectech/TecTech.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index 096aafc468..264c8dd797 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -2,10 +2,10 @@ package com.github.technus.tectech; import com.github.technus.tectech.loader.MainLoader; import com.github.technus.tectech.loader.TecTechConfig; -import com.github.technus.tectech.mechanics.commands.CancerCommand; +import com.github.technus.tectech.mechanics.anomaly.AnomalyHandler; +import com.github.technus.tectech.mechanics.anomaly.CancerCommand; import com.github.technus.tectech.mechanics.commands.ConvertFloat; import com.github.technus.tectech.mechanics.commands.ConvertInteger; -import com.github.technus.tectech.mechanics.anomaly.AnomalyHandler; import com.github.technus.tectech.mechanics.data.ChunkDataHandler; import com.github.technus.tectech.mechanics.data.PlayerPersistence; import com.github.technus.tectech.mechanics.elementalMatter.core.commands.GiveEM; -- cgit From 0989424cca10758930071d0846070e521f856957 Mon Sep 17 00:00:00 2001 From: Tec Date: Tue, 16 Jul 2019 12:27:31 +0200 Subject: Route get player to proxy --- .../technus/tectech/mechanics/anomaly/AnomalyHandler.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 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 c4e6c026ea..4eb2cc45a2 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 @@ -2,11 +2,11 @@ package com.github.technus.tectech.mechanics.anomaly; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.Util; -import com.github.technus.tectech.mechanics.data.ChunkDataHandler; -import com.github.technus.tectech.mechanics.data.IChunkMetaDataHandler; import com.github.technus.tectech.loader.MainLoader; -import com.github.technus.tectech.mechanics.data.ChunkDataMessage; import com.github.technus.tectech.loader.NetworkDispatcher; +import com.github.technus.tectech.mechanics.data.ChunkDataHandler; +import com.github.technus.tectech.mechanics.data.ChunkDataMessage; +import com.github.technus.tectech.mechanics.data.IChunkMetaDataHandler; import com.github.technus.tectech.mechanics.data.PlayerDataMessage; import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.atom.dAtomDefinition; import cpw.mods.fml.common.gameevent.TickEvent; @@ -14,8 +14,6 @@ import gregtech.api.GregTech_API; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -152,7 +150,7 @@ public class AnomalyHandler implements IChunkMetaDataHandler { @Override public void tickPlayer(HashMap data, TickEvent.PlayerTickEvent aEvent) { if (aEvent.side.isClient()) { - EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; + EntityPlayer player = TecTech.proxy.getPlayer(); ChunkCoordIntPair pair = new ChunkCoordIntPair(player.chunkCoordX, player.chunkCoordZ); NBTTagCompound compound = data.get(player.worldObj.provider.dimensionId).get(pair); if (compound != null) { @@ -199,10 +197,10 @@ public class AnomalyHandler implements IChunkMetaDataHandler { @Override public void tickRender(HashMap data, TickEvent.RenderTickEvent aEvent) { - EntityClientPlayerMP player=Minecraft.getMinecraft().thePlayer; + EntityPlayer player=TecTech.proxy.getPlayer(); if(player!=null) { if(!player.capabilities.isCreativeMode) { - NBTTagCompound tagCompound = TecTech.playerPersistence.getDataOrSetToNewTag(Minecraft.getMinecraft().thePlayer); + NBTTagCompound tagCompound = TecTech.playerPersistence.getDataOrSetToNewTag(player); if (tagCompound != null) { float cancer = tagCompound.getFloat(SPACE_CANCER); if (cancer > 0) { -- cgit