Skip to content

Commit

Permalink
Try to fix server crashes and a bunch of wrong calls.
Browse files Browse the repository at this point in the history
Still have to find out why the cloak toggling don't work on the server...
  • Loading branch information
Ethryan committed Dec 25, 2024
1 parent fdd2e4c commit 4f4fd35
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 62 deletions.
72 changes: 39 additions & 33 deletions src/main/java/witchinggadgets/common/items/baubles/ItemCloak.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,50 +198,56 @@ public void setStoredItems(ItemStack item, ItemStack[] stackList) {
}

@Override
public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List<String> list, boolean par4) {
GameSettings keybind = Minecraft.getMinecraft().gameSettings;
list.add(StatCollector.translateToLocalFormatted(Lib.DESCRIPTION + "gearSlot.bauble.Cloak"));
list.add(
StatCollector.translateToLocal(Lib.DESCRIPTION + "enableCloak")
.replaceAll(
"%s1",
StatCollector.translateToLocalFormatted(keybind.keyBindSneak.getKeyDescription()))
.replaceAll(
"%s2",
StatCollector.translateToLocalFormatted(keybind.keyBindJump.getKeyDescription())));
if (stack.hasTagCompound() && stack.getTagCompound().getBoolean("noGlide")) {
list.add(StatCollector.translateToLocal(Lib.DESCRIPTION + "noGlide"));
}
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean par4) {
if (player.worldObj.isRemote) {
GameSettings keybind = Minecraft.getMinecraft().gameSettings;
list.add(StatCollector.translateToLocalFormatted(Lib.DESCRIPTION + "gearSlot.bauble.Cloak"));
list.add(
StatCollector.translateToLocal(Lib.DESCRIPTION + "enableCloak")
.replaceAll(
"%s1",
StatCollector.translateToLocalFormatted(keybind.keyBindSneak.getKeyDescription()))
.replaceAll(
"%s2",
StatCollector.translateToLocalFormatted(keybind.keyBindJump.getKeyDescription())));
if (stack.hasTagCompound() && stack.getTagCompound().getBoolean("noGlide")) {
list.add(StatCollector.translateToLocal(Lib.DESCRIPTION + "noGlide"));
}

if (Loader.isModLoaded("Botania")) {
ItemStack cosmetic = getCosmeticItem(stack);
if (cosmetic != null) list.add(
String.format(StatCollector.translateToLocal("botaniamisc.hasCosmetic"), cosmetic.getDisplayName())
.replaceAll("&", "\u00a7"));
if (Loader.isModLoaded("Botania")) {
ItemStack cosmetic = getCosmeticItem(stack);
if (cosmetic != null) list.add(
String.format(
StatCollector.translateToLocal("botaniamisc.hasCosmetic"),
cosmetic.getDisplayName()).replaceAll("&", "\u00a7"));
}
}
}

public void onItemTicked(EntityPlayer player, ItemStack stack) {
GameSettings keybind = Minecraft.getMinecraft().gameSettings;
if (keybind.keyBindSneak.getIsKeyPressed() && keybind.keyBindJump.isPressed() && stack.getItemDamage() == 4) {
stack.getTagCompound().setBoolean("noGlide", !stack.getTagCompound().getBoolean("noGlide"));
if (player.worldObj.isRemote) {
GameSettings keybind = Minecraft.getMinecraft().gameSettings;
if (keybind.keyBindSneak.getIsKeyPressed() && keybind.keyBindJump.isPressed()
&& stack.getItemDamage() == 4) {
stack.getTagCompound().setBoolean("noGlide", !stack.getTagCompound().getBoolean("noGlide"));
}

if (activateKey.getIsKeyPressed() && Minecraft.getMinecraft().currentScreen == null) {
if (stack.getItemDamage() < subNames.length)
if (subNames[stack.getItemDamage()].equals("storage") && !player.worldObj.isRemote) player.openGui(
WitchingGadgets.instance,
this.equals(WGContent.ItemKama) ? 5 : 4,
player.worldObj,
MathHelper.floor_double(player.posX),
MathHelper.floor_double(player.posY),
MathHelper.floor_double(player.posZ));
}
}
if (player.ticksExisted < 1) {
onItemUnequipped(player, stack);
onItemEquipped(player, stack);
}

if (activateKey.getIsKeyPressed() && Minecraft.getMinecraft().currentScreen == null) {
if (stack.getItemDamage() < subNames.length)
if (subNames[stack.getItemDamage()].equals("storage") && !player.worldObj.isRemote) player.openGui(
WitchingGadgets.instance,
this.equals(WGContent.ItemKama) ? 5 : 4,
player.worldObj,
MathHelper.floor_double(player.posX),
MathHelper.floor_double(player.posY),
MathHelper.floor_double(player.posZ));
}

if (stack.getItemDamage() < subNames.length) {
if (subNames[stack.getItemDamage()].equals("spectral") && !player.worldObj.isRemote
&& stack.hasTagCompound()
Expand Down
41 changes: 22 additions & 19 deletions src/main/java/witchinggadgets/common/items/baubles/ItemKama.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,28 @@ public BaubleType getBaubleType(ItemStack stack) {
}

@Override
public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List<String> list, boolean par4) {
GameSettings keybind = Minecraft.getMinecraft().gameSettings;
list.add(StatCollector.translateToLocalFormatted(Lib.DESCRIPTION + "gearSlot.bauble.Belt"));
list.add(
StatCollector.translateToLocal(Lib.DESCRIPTION + "enableCloak")
.replaceAll(
"%s1",
StatCollector.translateToLocalFormatted(keybind.keyBindSneak.getKeyDescription()))
.replaceAll(
"%s2",
StatCollector.translateToLocalFormatted(keybind.keyBindJump.getKeyDescription())));
if (stack.hasTagCompound() && stack.getTagCompound().getBoolean("noGlide"))
list.add(StatCollector.translateToLocal(Lib.DESCRIPTION + "noGlide"));

if (Loader.isModLoaded("Botania")) {
ItemStack cosmetic = getCosmeticItem(stack);
if (cosmetic != null) list.add(
String.format(StatCollector.translateToLocal("botaniamisc.hasCosmetic"), cosmetic.getDisplayName())
.replaceAll("&", "\u00a7"));
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean par4) {
if (player.worldObj.isRemote) {
GameSettings keybind = Minecraft.getMinecraft().gameSettings;
list.add(StatCollector.translateToLocalFormatted(Lib.DESCRIPTION + "gearSlot.bauble.Belt"));
list.add(
StatCollector.translateToLocal(Lib.DESCRIPTION + "enableCloak")
.replaceAll(
"%s1",
StatCollector.translateToLocalFormatted(keybind.keyBindSneak.getKeyDescription()))
.replaceAll(
"%s2",
StatCollector.translateToLocalFormatted(keybind.keyBindJump.getKeyDescription())));
if (stack.hasTagCompound() && stack.getTagCompound().getBoolean("noGlide"))
list.add(StatCollector.translateToLocal(Lib.DESCRIPTION + "noGlide"));

if (Loader.isModLoaded("Botania")) {
ItemStack cosmetic = getCosmeticItem(stack);
if (cosmetic != null) list.add(
String.format(
StatCollector.translateToLocal("botaniamisc.hasCosmetic"),
cosmetic.getDisplayName()).replaceAll("&", "\u00a7"));
}
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/main/java/witchinggadgets/common/util/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,21 +335,21 @@ public static ItemStack getShard(Aspect a) {

public static ItemStack[] getActiveMagicalCloak(EntityPlayer player) {
ArrayList<ItemStack> list = new ArrayList<>();
if (BaublesApi.getBaubles(player).getStackInSlot(3) != null && BaublesApi.getBaubles(player)
.getStackInSlot(BaubleExpandedSlots.getIndexOfTypeInRegisteredTypes(BaubleExpandedSlots.capeType))
.getItem() instanceof ItemCloak)
list.add(
BaublesApi.getBaubles(player).getStackInSlot(
BaubleExpandedSlots.getIndexOfTypeInRegisteredTypes(BaubleExpandedSlots.capeType)));
ItemStack capeSlot = BaublesApi.getBaubles(player)
.getStackInSlot(BaubleExpandedSlots.getIndexesOfAssignedSlotsOfType(BaubleExpandedSlots.capeType)[0]);
if (capeSlot != null && capeSlot.getItem() instanceof ItemCloak) list.add(capeSlot);
return list.toArray(new ItemStack[0]);
}

public static void updateActiveMagicalCloak(EntityPlayer player, ItemStack cloak) {
if (cloak != null && cloak.getItem().equals(WGContent.ItemKama)) {
if (BaublesApi.getBaubles(player).getStackInSlot(3) != null
&& BaublesApi.getBaubles(player).getStackInSlot(3).getItem() instanceof ItemCloak) {
if (BaublesApi.getBaubles(player).getStackInSlot(3).getItemDamage() == cloak.getItemDamage())
BaublesApi.getBaubles(player).setInventorySlotContents(3, cloak);
ItemStack capeSlot = BaublesApi.getBaubles(player).getStackInSlot(
BaubleExpandedSlots.getIndexesOfAssignedSlotsOfType(BaubleExpandedSlots.capeType)[0]);
if (capeSlot != null && capeSlot.getItem() instanceof ItemCloak) {
if (capeSlot.getItemDamage() == cloak.getItemDamage())
BaublesApi.getBaubles(player).setInventorySlotContents(
BaubleExpandedSlots.getIndexesOfAssignedSlotsOfType(BaubleExpandedSlots.capeType)[0],
cloak);
BaublesApi.getBaubles(player).markDirty();
}
}
Expand Down

0 comments on commit 4f4fd35

Please sign in to comment.