This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
/
ClientProxySaturn.java
161 lines (134 loc) · 5.12 KB
/
ClientProxySaturn.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package mattparks.mods.space.saturn.client;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.util.ArrayList;
import java.util.EnumSet;
import mattparks.mods.space.saturn.CommonProxySaturn;
import mattparks.mods.space.saturn.GCSaturn;
import micdoodle8.mods.galacticraft.core.util.PacketUtil;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.SoundPoolEntry;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.Player;
import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;
public class ClientProxySaturn extends CommonProxySaturn
{
public class ClientPacketHandler implements IPacketHandler
{
@Override
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player p)
{
final DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet.data));
final int packetType = PacketUtil.readPacketID(data);
EntityPlayer player = (EntityPlayer) p;
if (packetType == 0)
{
final Class<?>[] decodeAs = { Integer.class, Integer.class, Integer.class };
final Object[] packetReadout = PacketUtil.readPacketData(data, decodeAs);
int entityID = 0;
Entity entity = null;
switch ((Integer) packetReadout[1])
{
case 0:
entityID = (Integer) packetReadout[2];
entity = player.worldObj.getEntityByID(entityID);
{
;
}
player.openContainer.windowId = (Integer) packetReadout[0];
break;
case 1:
entityID = (Integer) packetReadout[2];
entity = player.worldObj.getEntityByID(entityID);
{
;
}
player.openContainer.windowId = (Integer) packetReadout[0];
break;
}
}
}
}
public static class TickHandlerClient implements ITickHandler
{
@Override
public String getLabel()
{
return "Galacticraft Saturn Client";
}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData)
{
;
}
@Override
public EnumSet<TickType> ticks()
{
return EnumSet.of(TickType.CLIENT);
}
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData)
{
final Minecraft minecraft = FMLClientHandler.instance().getClient();
final WorldClient world = minecraft.theWorld;
final EntityClientPlayerMP player = minecraft.thePlayer;
if (type.equals(EnumSet.of(TickType.CLIENT)))
{
if (world != null)
{
for (int i = 0; i < world.loadedEntityList.size(); i++)
{
final Entity e = (Entity) world.loadedEntityList.get(i);
}
}
}
}
}
public static ArrayList<SoundPoolEntry> newMusic = new ArrayList<SoundPoolEntry>();
public static boolean handleLavaMovement(EntityPlayer player)
{
return player.worldObj.isMaterialInBB(player.boundingBox.expand(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D), Material.lava);
}
public static boolean handleWaterMovement(EntityPlayer player)
{
return player.worldObj.isMaterialInBB(player.boundingBox.expand(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D), Material.water);
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity tile = world.getBlockTileEntity(x, y, z);
return null;
}
@Override
public void init(FMLInitializationEvent event)
{
TickRegistry.registerTickHandler(new TickHandlerClient(), Side.CLIENT);
NetworkRegistry.instance().registerChannel(new ClientPacketHandler(), GCSaturn.CHANNEL, Side.CLIENT);
}
@Override
public void preInit(FMLPreInitializationEvent event)
{
;
}
@Override
public void registerRenderInformation()
{
;
}
}