mirror of
https://github.com/GTNewHorizons/DummyCore.git
synced 2026-11-28 07:56:07 +00:00
1.13 - Removed DC's attribute system, use vanilla MC's from now.
This commit is contained in:
1 parent
3e5bdc149c
commit
eddeec77b5
1 file changed
-247
@@ -1,17 +1,10 @@
|
||||
package DummyCore.Utils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.ai.attributes.IAttribute;
|
||||
import net.minecraft.entity.ai.attributes.IAttributeInstance;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -28,13 +21,10 @@ import DummyCore.Client.MainMenuRegistry;
|
||||
import DummyCore.Events.DummyEvent_OnClientGUIButtonPress;
|
||||
import DummyCore.Events.DummyEvent_OnKeyboardKeyPressed_Server;
|
||||
import DummyCore.Events.DummyEvent_OnPacketRecieved;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -75,64 +65,6 @@ public class DummyEventHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Totally going to get removed!
|
||||
* @param event
|
||||
*/
|
||||
@Deprecated
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onClientTick(RenderTickEvent event)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(isKeyPressed == null) isKeyPressed = new boolean[Keyboard.getKeyCount()];
|
||||
if(FMLClientHandler.instance().getClientPlayerEntity() != null)
|
||||
for(int i = 0; i < isKeyPressed.length; ++i)
|
||||
{
|
||||
if(Keyboard.isKeyDown(Keyboard.getKeyIndex(Keyboard.getKeyName(i))) && !isKeyPressed[i])
|
||||
{
|
||||
isKeyPressed[i] = true;
|
||||
int id = i;
|
||||
String keyName = Keyboard.getKeyName(i);
|
||||
String username = FMLClientHandler.instance().getClientPlayerEntity().getCommandSenderName();
|
||||
DummyData aaa = new DummyData("id",id);
|
||||
DummyData aab = new DummyData("name",keyName);
|
||||
DummyData aac = new DummyData("username",username);
|
||||
DummyData aad = new DummyData("pressed",true);
|
||||
DataStorage.addDataToString(aaa);
|
||||
DataStorage.addDataToString(aab);
|
||||
DataStorage.addDataToString(aac);
|
||||
DataStorage.addDataToString(aad);
|
||||
String dataString = DataStorage.getDataString();
|
||||
DummyPacketIMSG packet = new DummyPacketIMSG("||mod:DummyCore.ButtonPress"+dataString);
|
||||
DummyPacketHandler.sendToServer(packet);
|
||||
}
|
||||
if(!Keyboard.isKeyDown(Keyboard.getKeyIndex(Keyboard.getKeyName(i))) && isKeyPressed[i])
|
||||
{
|
||||
isKeyPressed[i] = false;
|
||||
int id = i;
|
||||
String keyName = Keyboard.getKeyName(i);
|
||||
String username = FMLClientHandler.instance().getClientPlayerEntity().getCommandSenderName();
|
||||
DummyData aaa = new DummyData("id",id);
|
||||
DummyData aab = new DummyData("name",keyName);
|
||||
DummyData aac = new DummyData("username",username);
|
||||
DummyData aad = new DummyData("pressed",false);
|
||||
DataStorage.addDataToString(aaa);
|
||||
DataStorage.addDataToString(aab);
|
||||
DataStorage.addDataToString(aac);
|
||||
DataStorage.addDataToString(aad);
|
||||
String dataString = DataStorage.getDataString();
|
||||
DummyPacketIMSG packet = new DummyPacketIMSG("||mod:DummyCore.ButtonPress"+dataString);
|
||||
DummyPacketHandler.sendToServer(packet);
|
||||
}
|
||||
}
|
||||
}catch(Exception e)
|
||||
{
|
||||
DataStorage.getDataString();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
@@ -267,185 +199,6 @@ public class DummyEventHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerTickEnd(PlayerTickEvent event)
|
||||
{
|
||||
EntityPlayer player = event.player;
|
||||
IInventory inv = player.inventory;
|
||||
for(int k = 0; k < inv.getSizeInventory(); ++k)
|
||||
{
|
||||
ItemStack s = inv.getStackInSlot(k);
|
||||
if(s != null)
|
||||
{
|
||||
if(s.getItem() instanceof IAttributeModifier)
|
||||
{
|
||||
String itype = ((IAttributeModifier)s.getItem()).getType(s, player);
|
||||
if(itype.equals("inventory"))
|
||||
{
|
||||
String last5OfUUID = ((IAttributeModifier)s.getItem()).last5OfUUID(s, player);
|
||||
int operation = ((IAttributeModifier)s.getItem()).getOperation(s, player);
|
||||
double ivalue = ((IAttributeModifier)s.getItem()).getValue(s, player);
|
||||
IAttribute iattrib = ((IAttributeModifier)s.getItem()).getAttribute(s, player);
|
||||
MiscUtils.applyPlayerModifier(player, iattrib, last5OfUUID, ivalue, false, operation, itype);
|
||||
}else
|
||||
{
|
||||
if(itype.equals("hold") && player.getCurrentEquippedItem() == s)
|
||||
{
|
||||
String last5OfUUID = ((IAttributeModifier)s.getItem()).last5OfUUID(s, player);
|
||||
int operation = ((IAttributeModifier)s.getItem()).getOperation(s, player);
|
||||
double ivalue = ((IAttributeModifier)s.getItem()).getValue(s, player);
|
||||
IAttribute iattrib = ((IAttributeModifier)s.getItem()).getAttribute(s, player);
|
||||
MiscUtils.applyPlayerModifier(player, iattrib, last5OfUUID, ivalue, false, operation, itype);
|
||||
}else
|
||||
{
|
||||
if(itype.equals("armor") && (player.inventory.armorInventory[0] == s ||player.inventory.armorInventory[1] == s ||player.inventory.armorInventory[2] == s ||player.inventory.armorInventory[3] == s))
|
||||
{
|
||||
String last5OfUUID = ((IAttributeModifier)s.getItem()).last5OfUUID(s, player);
|
||||
int operation = ((IAttributeModifier)s.getItem()).getOperation(s, player);
|
||||
double ivalue = ((IAttributeModifier)s.getItem()).getValue(s, player);
|
||||
IAttribute iattrib = ((IAttributeModifier)s.getItem()).getAttribute(s, player);
|
||||
MiscUtils.applyPlayerModifier(player, iattrib, last5OfUUID, ivalue, false, operation, itype);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else
|
||||
{
|
||||
List<String> l = Arrays.asList(s.getItem().getUnlocalizedName(),Integer.toString(s.getItemDamage()));
|
||||
if(MiscUtils.shouldIgnoreDamage.contains(s.getItem()))
|
||||
l = Arrays.asList(s.getItem().getUnlocalizedName(),Integer.toString(-1));
|
||||
if(MiscUtils.modifierType.containsKey(l))
|
||||
{
|
||||
String itype = MiscUtils.modifierType.get(l);
|
||||
|
||||
if(itype.equals("inventory"))
|
||||
{
|
||||
String last5OfUUID = MiscUtils.modifierUUID.get(l);
|
||||
int operation = MiscUtils.modifierOperation.get(l);
|
||||
double ivalue = MiscUtils.modifierValue.get(l);
|
||||
IAttribute iattrib = MiscUtils.modifier.get(l);
|
||||
MiscUtils.applyPlayerModifier(player, iattrib, last5OfUUID, ivalue, false, operation, itype);
|
||||
}else
|
||||
{
|
||||
if(itype.equals("hold") && player.getCurrentEquippedItem() == s)
|
||||
{
|
||||
String last5OfUUID = MiscUtils.modifierUUID.get(l);
|
||||
int operation = MiscUtils.modifierOperation.get(l);
|
||||
double ivalue = MiscUtils.modifierValue.get(l);
|
||||
IAttribute iattrib = MiscUtils.modifier.get(l);
|
||||
MiscUtils.applyPlayerModifier(player, iattrib, last5OfUUID, ivalue, false, operation, itype);
|
||||
}else
|
||||
{
|
||||
if(itype.equals("armor") && (player.inventory.armorInventory[0] == s ||player.inventory.armorInventory[1] == s ||player.inventory.armorInventory[2] == s ||player.inventory.armorInventory[3] == s))
|
||||
{
|
||||
String last5OfUUID = MiscUtils.modifierUUID.get(l);
|
||||
int operation = MiscUtils.modifierOperation.get(l);
|
||||
double ivalue = MiscUtils.modifierValue.get(l);
|
||||
IAttribute iattrib = MiscUtils.modifier.get(l);
|
||||
MiscUtils.applyPlayerModifier(player, iattrib, last5OfUUID, ivalue, false, operation, itype);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i1 = 0; i1 < player.getAttributeMap().getAllAttributes().size(); ++i1)
|
||||
{
|
||||
IAttributeInstance ainst = (IAttributeInstance) player.getAttributeMap().getAllAttributes().toArray()[i1];
|
||||
Collection<?> coll = ainst.func_111122_c();
|
||||
for(int j = 0; j < coll.size(); ++j)
|
||||
{
|
||||
if(coll.toArray()[j] instanceof AttributeModifier)
|
||||
{
|
||||
AttributeModifier mod = (AttributeModifier) coll.toArray()[j];
|
||||
String name = mod.getName();
|
||||
boolean remove = true;
|
||||
if(name.contains("dam."))
|
||||
{
|
||||
String sub = mod.getID().toString().substring(mod.getID().toString().length()-5, mod.getID().toString().length());
|
||||
if(name.contains("hold"))
|
||||
{
|
||||
ItemStack s = player.getCurrentEquippedItem();
|
||||
if(s != null)
|
||||
{
|
||||
if(s.getItem() instanceof IAttributeModifier)
|
||||
{
|
||||
String uuid = ((IAttributeModifier)s.getItem()).last5OfUUID(s, player).toLowerCase();
|
||||
if(uuid.equals(sub))
|
||||
remove = false;
|
||||
}
|
||||
List<String> l = Arrays.asList(s.getItem().getUnlocalizedName(),Integer.toString(s.getItemDamage()));
|
||||
if(MiscUtils.shouldIgnoreDamage.contains(s.getItem()))
|
||||
l = Arrays.asList(s.getItem().getUnlocalizedName(),Integer.toString(-1));
|
||||
if(MiscUtils.modifierUUID.containsKey(l))
|
||||
{
|
||||
String uuid = MiscUtils.modifierUUID.get(l).toLowerCase();
|
||||
if(uuid.equals(sub))
|
||||
remove = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(name.contains("inventory"))
|
||||
{
|
||||
IInventory inven = player.inventory;
|
||||
for(int k = 0; k < inven.getSizeInventory(); ++k)
|
||||
{
|
||||
ItemStack s = inven.getStackInSlot(k);
|
||||
if(s != null)
|
||||
{
|
||||
if(s.getItem() instanceof IAttributeModifier)
|
||||
{
|
||||
String uuid = ((IAttributeModifier)s.getItem()).last5OfUUID(s, player).toLowerCase();
|
||||
if(uuid.equals(sub))
|
||||
remove = false;
|
||||
}
|
||||
List<String> l = Arrays.asList(s.getItem().getUnlocalizedName(),Integer.toString(s.getItemDamage()));
|
||||
if(MiscUtils.shouldIgnoreDamage.contains(s.getItem()))
|
||||
l = Arrays.asList(s.getItem().getUnlocalizedName(),Integer.toString(-1));
|
||||
if(MiscUtils.modifierUUID.containsKey(l))
|
||||
{
|
||||
|
||||
String uuid = MiscUtils.modifierUUID.get(l).toLowerCase();
|
||||
if(uuid.equals(sub))
|
||||
remove = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(name.contains("armor"))
|
||||
{
|
||||
for(int k = 0; k < player.inventory.armorInventory.length; ++k)
|
||||
{
|
||||
ItemStack s = player.inventory.armorInventory[k];
|
||||
|
||||
if(s != null)
|
||||
{
|
||||
if(s.getItem() instanceof IAttributeModifier)
|
||||
{
|
||||
String uuid = ((IAttributeModifier)s.getItem()).last5OfUUID(s, player).toLowerCase();
|
||||
if(uuid.equals(sub))
|
||||
remove = false;
|
||||
}
|
||||
List<String> l = Arrays.asList(s.getItem().getUnlocalizedName(),Integer.toString(s.getItemDamage()));
|
||||
if(MiscUtils.shouldIgnoreDamage.contains(s.getItem()))
|
||||
l = Arrays.asList(s.getItem().getUnlocalizedName(),Integer.toString(-1));
|
||||
if(MiscUtils.modifierUUID.containsKey(l))
|
||||
{
|
||||
String uuid = MiscUtils.modifierUUID.get(l).toLowerCase();
|
||||
if(uuid.equals(sub))
|
||||
remove = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(remove)
|
||||
MiscUtils.applyPlayerModifier(player, ainst.getAttribute(), sub, 1, true, 0, "remove");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerTick(TickEvent.ServerTickEvent event)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user