Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import net.minecraft.util.Vec3;
import org.lwjgl.opengl.GL11;

import java.util.Objects;

/**
* 3D Vector helper class for lightning calculations.
* Adapted from Botania's Vector3 by ChickenBones.
Expand Down Expand Up @@ -181,4 +183,9 @@ public boolean equals(Object o) {
Vec3d v = (Vec3d) o;
return x == v.x && y == v.y && z == v.z;
}

@Override
public int hashCode() {
return Objects.hash(x, y, z);
}
}
7 changes: 3 additions & 4 deletions src/main/java/noppes/npcs/NoppesUtilPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -550,14 +550,13 @@ public static boolean questPartyCompletion(Party party) {
if (data == null)
return false;

if (!data.quest.questInterface.isPartyCompleted(party))
return false;


Quest quest = data.quest;
if (quest == null)
return false;

if (!data.quest.questInterface.isPartyCompleted(party))
return false;

if (data.quest.completion == EnumQuestCompletion.Instant)
EventHooks.onPartyFinished(party, data.quest);

Expand Down
27 changes: 0 additions & 27 deletions src/main/java/noppes/npcs/NoppesUtilServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,6 @@ public static void sendOpenGui(EntityPlayer player,
sendOpenGui(player, gui, npc, 0, 0, 0);
}

public static void sendOpenGuiNoDelay(EntityPlayer player,
EnumGuiType gui, EntityNPCInterface npc) {
sendOpenGuiNoDelay(player, gui, npc, 0, 0, 0);
}

public static void sendOpenGui(final EntityPlayer player,
final EnumGuiType gui, final EntityNPCInterface npc, final int i, final int j, final int k) {
if (!(player instanceof EntityPlayerMP))
Expand All @@ -369,28 +364,6 @@ public static void sendOpenGui(final EntityPlayer player,
ScrollListPacket.sendList((EntityPlayerMP) player, list, EnumScrollData.OPTIONAL);
}

public static void sendOpenGuiNoDelay(final EntityPlayer player,
final EnumGuiType gui, final EntityNPCInterface npc, final int i, final int j, final int k) {
if (!(player instanceof EntityPlayerMP))
return;

setEditingNpc(player, npc);
sendExtraData(player, npc, gui, i, j, k);

if (CustomNpcs.proxy.getServerGuiElement(gui.ordinal(), player, player.worldObj, i, j, k) != null) {
player.openGui(CustomNpcs.instance, gui.ordinal(), player.worldObj, i, j, k);
return;
} else {
GuiOpenPacket.openGUI((EntityPlayerMP) player, gui, i, j, k);
}
ArrayList<String> list = getScrollData(player, gui, npc);
if (list == null || list.isEmpty())
return;

ScrollListPacket.sendList((EntityPlayerMP) player, list, EnumScrollData.OPTIONAL);
}


private static void sendExtraData(EntityPlayer player, EntityNPCInterface npc, EnumGuiType gui, int i, int j, int k) {
if (gui == EnumGuiType.PlayerFollower || gui == EnumGuiType.PlayerFollowerHire || gui == EnumGuiType.PlayerTrader || gui == EnumGuiType.PlayerTransporter) {
sendRoleData(player, npc);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/noppes/npcs/ServerEventsHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void invoke(EntityInteractEvent event) {
mounted = event.target;
if (isRemote)
CustomNpcs.proxy.openGui(MathHelper.floor_double(mounted.posX), MathHelper.floor_double(mounted.posY), MathHelper.floor_double(mounted.posZ), EnumGuiType.MobSpawnerMounter, event.entityPlayer);
} else if (item.getItem() == CustomItems.wand && !isRemote && event.target instanceof EntityVillager) {
} else if (item.getItem() == CustomItems.wand && event.target instanceof EntityVillager) {
if (!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.EDIT_VILLAGER))
return;
event.setCanceled(true);
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/noppes/npcs/blocks/BlockCampfire.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public TileEntity createNewTileEntity(World var1, int var2) {
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
ItemStack item = player.inventory.getCurrentItem();
if (item == null)
return true;
int meta = world.getBlockMetadata(x, y, z);
return false;

if ((item.getItem() == Items.flint || item.getItem() == Items.flint_and_steel) && unlitBlock() == this) {
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
Expand All @@ -56,7 +55,7 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
}

return true;
return false;
}

@Override
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/noppes/npcs/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ public void load() {
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.shortLamp), new ItemShortLampRenderer());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.tallLamp), new ItemTallLampRenderer());
}
Minecraft mc = Minecraft.getMinecraft();

NPCButton = new KeyBinding("NPC Inventory", Keyboard.KEY_N, "key.categories.customnpc");
SpecialKey = new KeyBinding("key.customnpcs.special", Keyboard.KEY_B, "key.categories.customnpc");
Expand Down Expand Up @@ -678,9 +677,7 @@ public void openGui(EntityPlayer player, Object guiscreen) {
if (!player.worldObj.isRemote || !(guiscreen instanceof GuiScreen))
return;

if (guiscreen != null) {
minecraft.displayGuiScreen((GuiScreen) guiscreen);
}
minecraft.displayGuiScreen((GuiScreen) guiscreen);
}


Expand Down Expand Up @@ -775,8 +772,7 @@ public static void bindTexture(ResourceLocation location) {
if (location == null)
return;
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
if (location != null)
texturemanager.bindTexture((ResourceLocation) location);
texturemanager.bindTexture((ResourceLocation) location);
} catch (NullPointerException ex) {

} catch (ReportedException ex) {
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/noppes/npcs/client/ClientTickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,7 @@ private void updateCompassMarks() {

if (player == null || mc.theWorld == null)
return;

if (ClientHudManager.getInstance() == null || ClientHudManager.getInstance().getHudComponents() == null)
return;


// Update compass
HudComponent compass = ClientHudManager.getInstance()
.getHudComponents().get(EnumHudComponent.QuestCompass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ private void showClones() {
return;
}

ArrayList<String> list = new ArrayList<String>();
this.list = ClientCloneController.Instance.getClones(activeTab);
scroll.setList(getSearchList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ private void showClones() {
return;
}

ArrayList<String> list = new ArrayList<String>();

this.list = new ArrayList<String>(ClientCloneController.Instance.getClones(activeTab));
scroll.setList(getSearchList());
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ protected void actionPerformed(GuiButton guibutton) {
if (scroll1.hasSelected()) {
data.biomes.add(scroll1.getSelected());
scroll1.selected = -1;
scroll1.selected = -1;
initGui();
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/noppes/npcs/client/gui/player/GuiNpcAnvil.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, i

// Compute the repair status message based on container.repairCost and player's XP.
String status = "";
int textColor = CustomNpcResourceListener.DefaultTextColor;

if (container.repairCost > 0) {
if (container.repairCost > mc.thePlayer.experienceTotal) {
status = "Repair cost: " + container.repairCost + " XP";
textColor = 0xFF0000; // red when not enough XP
} else {
status = "Repair cost: " + container.repairCost + " XP";
}
Expand All @@ -72,10 +75,6 @@ protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, i
status = "Item is already fully repaired";
}
}
int textColor = CustomNpcResourceListener.DefaultTextColor;
if (container.repairCost > mc.thePlayer.experienceTotal) {
textColor = 0xFF0000; // red when not enough XP
}
fontRendererObj.drawString(status, guiLeft + 5, guiTop + 75, textColor);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private int mapNormalizedOffsetToOriginal(String orig, int normalizedOffset, int
public void init(String text, int width, int height) {
this.text = text == null ? "" : text.replaceAll("\\r?\\n|\\r", "\n");
lines.clear();
String[] split = text.split("\n", -1);
String[] split = this.text.split("\n", -1);

int totalChars = 0;
for (String l : split) {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/noppes/npcs/client/key/KeyPreset.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;

import java.util.Objects;
import java.util.function.Consumer;

public class KeyPreset {
Expand Down Expand Up @@ -189,6 +190,11 @@ public boolean equals(Object preset) {
return false;
}

@Override
public int hashCode() {
return Objects.hash( currentState);
}

public static class KeyState {
public int keyCode = -1;
public boolean hasCtrl, hasAlt, hasShift;
Expand Down Expand Up @@ -232,6 +238,11 @@ public boolean equals(Object preset) {
return false;
}

@Override
public int hashCode() {
return Objects.hash(keyCode, hasCtrl, hasAlt, hasShift);
}

public NBTTagCompound writeToNbt() {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("keyCode", keyCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import noppes.npcs.constants.EnumAnimation;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.items.ItemClaw;
import noppes.npcs.items.ItemRotatedShield;
import noppes.npcs.items.ItemShield;
import org.lwjgl.opengl.GL11;

import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED;
Expand Down Expand Up @@ -314,7 +317,7 @@ protected void renderSpecials(EntityNPCInterface npc, float f) {

Class<?> clazz = itemstack2.getItem().getClass();
boolean pluginMod = itemstack2.getItem().getUnlocalizedName().contains("plug:");
if (clazz.getSimpleName().equals("ItemShield") || clazz.getSimpleName().equals("ItemRotatedShield") || clazz.getSimpleName().equals("ItemClaw"))
if (clazz.equals(ItemShield.class) || clazz.equals(ItemRotatedShield.class) || clazz.equals(ItemClaw.class))
GL11.glTranslatef(0.30f, 0, 0f);

if (itemstack2.getItem() instanceof ItemBlock && (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack2.getItem()).getRenderType()))) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/noppes/npcs/controllers/ScriptContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.TreeMap;

public class ScriptContainer implements IScriptUnit {
private static final String lock = "lock";
private static final Object lock = new Object();
public static ScriptContainer Current;
private static String CurrentType;
public String fullscript = "";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/noppes/npcs/entity/EntityCustomNpc.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void mountEntity(Entity par1Entity) {
@Override
public void updateHitbox() {
Entity entity = modelData.getEntity(this);
if (modelData == null || entity == null) {
if (entity == null) {
baseHeight = 1.9f - modelData.getBodyY() + (modelData.modelScale.head.scaleY - 1) / 2;
super.updateHitbox();
} else {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/noppes/npcs/entity/data/ModelDataShared.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ public ModelPartData getOrCreatePart(String type) {
public float getBodyY() {
if (legParts.type == 3)
return (0.9f - modelScale.body.scaleY) * 0.75f + getLegsY();
if (legParts.type == 3)
return (0.5f - modelScale.body.scaleY) * 0.75f + getLegsY();
return (1 - modelScale.body.scaleY) * 0.75f + getLegsY();
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/noppes/npcs/items/ItemNpcWand.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public boolean onItemUse(ItemStack par1ItemStack, final EntityPlayer player, Wor
par3World.spawnEntityInWorld(npc);
npc.setHealth(npc.getMaxHealth());

NoppesUtilServer.sendOpenGuiNoDelay(player, EnumGuiType.MainMenuDisplay, npc);
NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, npc);
return true;
} else
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/noppes/npcs/roles/RoleCompanion.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public void interact(EntityPlayer player) {
((CompanionTrader) jobInterface).interact(player);
if (player != owner || !npc.isEntityAlive() || npc.isAttacking())
return;
if (player.isSneaking()) {
if (player != null && player.isSneaking()) {
openGui(player);
} else {
setSitting(!isSitting());
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/noppes/npcs/scripted/ScriptBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import noppes.npcs.api.ITileEntity;
import noppes.npcs.api.IWorld;

import java.util.Objects;

public class ScriptBlock implements IBlock {
protected IWorld world;
protected Block block;
Expand Down Expand Up @@ -224,4 +226,9 @@ public boolean equals(Object obj) {
((ScriptBlock) obj).getWorld() == this.getWorld() &&
((ScriptBlock) obj).getPos().equals(this.getPos());
}

@Override
public int hashCode() {
return Objects.hash(getWorld(), block, getPos());
}
}
7 changes: 7 additions & 0 deletions src/main/java/noppes/npcs/scripted/ScriptBlockPos.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import net.minecraft.util.math.BlockPos;
import noppes.npcs.api.IPos;

import java.util.Objects;

public class ScriptBlockPos implements IPos {
public BlockPos blockPos;

Expand Down Expand Up @@ -169,4 +171,9 @@ public String toString() {
public boolean equals(Object object) {
return object instanceof IPos && ((IPos) object).toLong() == this.toLong();
}

@Override
public int hashCode() {
return Objects.hashCode(blockPos);
}
}
6 changes: 6 additions & 0 deletions src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

public class ScriptEntity<T extends Entity> implements IEntity {
Expand Down Expand Up @@ -964,6 +965,11 @@ public boolean equals(Object object) {
return object instanceof IEntity && ((IEntity<?>) object).getMCEntity().equals(this.entity);
}

@Override
public int hashCode() {
return Objects.hash(entity, tempData);
}

public void updateEntity() {
IWorld world = NpcAPI.Instance().getIWorld(entity.worldObj);
entity.dimension = world.getDimensionID();
Expand Down
Loading
Loading