mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 23:29:41 +00:00
Merge branch 'dev' into animation-events
This commit is contained in:
commit
113d27b364
19 files changed
+349
-81
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package kamkeel.addon;
|
||||
|
||||
import kamkeel.addon.client.DBCClient;
|
||||
import kamkeel.addon.client.GeckoAddonClient;
|
||||
|
||||
public class AddonManager {
|
||||
@@ -17,5 +18,9 @@ public class AddonManager {
|
||||
// Gecko Addon Initialization
|
||||
new GeckoAddon();
|
||||
new GeckoAddonClient();
|
||||
|
||||
// DBC Addon
|
||||
new DBCAddon();
|
||||
new DBCClient();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package kamkeel.addon;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class DBCAddon {
|
||||
public static DBCAddon instance;
|
||||
public boolean supportEnabled = true;
|
||||
|
||||
/**
|
||||
* This class is a shell class to be changed via mixins
|
||||
* The Addon Mod will replace all blank functions within
|
||||
* this class to change the ongoing code.
|
||||
*/
|
||||
public DBCAddon(){
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void dbcCopyData(EntityLivingBase copied, EntityLivingBase entity){}
|
||||
|
||||
public boolean canDBCAttack(EntityNPCInterface npc, float attackStrength, Entity receiver){
|
||||
return false;
|
||||
}
|
||||
|
||||
public void doDBCDamage(EntityNPCInterface npc, float attackStrength, Entity receiver){}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package kamkeel.addon.client;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import noppes.npcs.client.gui.mainmenu.GuiNpcStats;
|
||||
import noppes.npcs.client.gui.model.GuiCreationScreen;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface2;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.model.ModelMPM;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class DBCClient {
|
||||
public static DBCClient Instance;
|
||||
public boolean supportEnabled = true;
|
||||
|
||||
/**
|
||||
* This class is a shell class to be changed via mixins
|
||||
* The Addon Mod will replace all blank functions within
|
||||
* this class to change the ongoing code.
|
||||
* The fewer classes modified by mixins the safer.
|
||||
* These are for mixins affecting only client-side classes.
|
||||
*/
|
||||
public DBCClient(){
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
// Stat Buttons
|
||||
public void showDBCStatButtons(GuiNpcStats stats, EntityLivingBase entity){}
|
||||
public void showDBCStatActionPerformed(GuiNpcStats stats, GuiNpcButton btn){}
|
||||
}
|
||||
@@ -466,8 +466,11 @@ public class PacketHandlerServer{
|
||||
if(type == EnumPacketServer.ScriptPlayerGet) {
|
||||
getScripts(data,buffer,player);
|
||||
} else if(type == EnumPacketServer.ScriptPlayerSave) {
|
||||
int tab = buffer.getInt(buffer.readerIndex());
|
||||
saveScripts(data,buffer,player);
|
||||
ScriptController.Instance.lastPlayerUpdate = System.currentTimeMillis();
|
||||
if(tab == -1)
|
||||
ScriptController.Instance.savePlayerScriptsSync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,8 +479,11 @@ public class PacketHandlerServer{
|
||||
if (type == EnumPacketServer.ScriptForgeGet) {
|
||||
getScripts(data,buffer,player);
|
||||
} else if (type == EnumPacketServer.ScriptForgeSave) {
|
||||
int tab = buffer.getInt(buffer.readerIndex());
|
||||
saveScripts(data,buffer,player);
|
||||
ScriptController.Instance.lastForgeUpdate = System.currentTimeMillis();
|
||||
if(tab == -1)
|
||||
ScriptController.Instance.saveForgeScriptsSync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -486,8 +492,11 @@ public class PacketHandlerServer{
|
||||
if(type == EnumPacketServer.ScriptGlobalNPCGet) {
|
||||
getScripts(data,buffer,player);
|
||||
} else if(type == EnumPacketServer.ScriptGlobalNPCSave) {
|
||||
int tab = buffer.getInt(buffer.readerIndex());
|
||||
saveScripts(data,buffer,player);
|
||||
ScriptController.Instance.lastGlobalNpcUpdate = System.currentTimeMillis();
|
||||
if(tab == -1)
|
||||
ScriptController.Instance.saveGlobalScriptsSync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.event.entity.EntityStruckByLightningEvent;
|
||||
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
|
||||
import net.minecraftforge.event.entity.item.ItemTossEvent;
|
||||
@@ -23,10 +24,12 @@ import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.constants.SyncType;
|
||||
import noppes.npcs.controllers.PartyController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.quests.QuestItem;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.item.ScriptCustomItem;
|
||||
|
||||
@@ -236,6 +239,21 @@ public class ScriptPlayerEventHandler {
|
||||
if(event.player == null || event.player.worldObj == null)
|
||||
return;
|
||||
|
||||
if(!event.player.worldObj.isRemote && !(event.player instanceof FakePlayer)){
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player);
|
||||
PlayerQuestData questData = playerData.questData;
|
||||
QuestItem.pickedUp = event.pickedUp.getEntityItem();
|
||||
|
||||
Party playerParty = playerData.getPlayerParty();
|
||||
if(playerParty != null){
|
||||
QuestItem.pickedUpParty = event.pickedUp.getEntityItem();
|
||||
QuestItem.pickedUpPlayer = event.player;
|
||||
PartyController.Instance().checkQuestCompletion(playerParty, EnumQuestType.Item);
|
||||
}
|
||||
|
||||
questData.checkQuestCompletion(playerData, EnumQuestType.Item);
|
||||
}
|
||||
|
||||
if(event.player.worldObj instanceof WorldServer) {
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
|
||||
@@ -410,7 +428,7 @@ public class ScriptPlayerEventHandler {
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
if(source instanceof EntityPlayer) {
|
||||
if(event.source.getEntity() instanceof EntityPlayer) {
|
||||
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.source.getEntity());
|
||||
EventHooks.onPlayerKills(handler,scriptPlayer, event.entityLiving);
|
||||
}
|
||||
@@ -431,7 +449,7 @@ public class ScriptPlayerEventHandler {
|
||||
event.setCanceled(EventHooks.onPlayerAttacked(handler, pevent));
|
||||
}
|
||||
|
||||
if(source instanceof EntityPlayer) {
|
||||
if(event.source.getEntity() instanceof EntityPlayer) {
|
||||
noppes.npcs.scripted.event.PlayerEvent.AttackEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.AttackEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source);
|
||||
event.setCanceled(EventHooks.onPlayerAttack(handler, pevent1));
|
||||
}
|
||||
@@ -453,7 +471,7 @@ public class ScriptPlayerEventHandler {
|
||||
}
|
||||
|
||||
if(source instanceof EntityPlayer) {
|
||||
noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source);
|
||||
noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((IPlayer)NpcAPI.Instance().getIEntity(source), event.entityLiving, event.ammount, event.source);
|
||||
event.setCanceled(EventHooks.onPlayerDamagedEntity(handler, pevent1));
|
||||
event.ammount = pevent1.damage;
|
||||
}
|
||||
|
||||
@@ -457,25 +457,7 @@ public class ServerEventsHandler {
|
||||
PartyController.Instance().pingPartyQuestObjectiveUpdate(party);
|
||||
PartyController.Instance().checkQuestCompletion(party, EnumQuestType.Kill);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void pickUp(EntityItemPickupEvent event){
|
||||
if(event.entityPlayer.worldObj.isRemote || event.entityPlayer instanceof FakePlayer)
|
||||
return;
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.entityPlayer);
|
||||
PlayerQuestData questData = playerData.questData;
|
||||
QuestItem.pickedUp = event.item.getEntityItem();
|
||||
|
||||
Party playerParty = playerData.getPlayerParty();
|
||||
if(playerParty != null){
|
||||
QuestItem.pickedUpParty = event.item.getEntityItem();
|
||||
QuestItem.pickedUpPlayer = event.entityPlayer;
|
||||
PartyController.Instance().checkQuestCompletion(playerParty, EnumQuestType.Item);
|
||||
}
|
||||
|
||||
questData.checkQuestCompletion(playerData, EnumQuestType.Item);
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void world(PlayerEvent.SaveToFile event){
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entity);
|
||||
|
||||
@@ -25,6 +25,8 @@ import noppes.npcs.constants.EnumGuiType;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockScripted extends BlockContainer {
|
||||
|
||||
public int renderId = -1;
|
||||
public static final AxisAlignedBB AABB = AxisAlignedBB.getBoundingBox(0.001f, 0.001f, 0.001f, 0.998f, 0.998f, 0.998f);
|
||||
public static final AxisAlignedBB AABB_EMPTY = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0);
|
||||
|
||||
@@ -109,12 +111,12 @@ public class BlockScripted extends BlockContainer {
|
||||
|
||||
@Override
|
||||
public boolean canRenderInPass(int pass) {
|
||||
return false;
|
||||
return super.canRenderInPass(pass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return 0;
|
||||
return renderId;
|
||||
}
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
|
||||
@@ -15,9 +15,11 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import noppes.npcs.*;
|
||||
import noppes.npcs.api.IBlock;
|
||||
import noppes.npcs.api.block.ITextPlane;
|
||||
import noppes.npcs.client.renderer.blocks.BlockScriptedRenderer;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
@@ -48,6 +50,8 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler {
|
||||
|
||||
public ItemStack itemModel = new ItemStack(CustomItems.scripted);
|
||||
public Block blockModel = null;
|
||||
private boolean hideModel;
|
||||
private int metadata;
|
||||
|
||||
public boolean needsClientUpdate = false;
|
||||
|
||||
@@ -68,6 +72,7 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler {
|
||||
|
||||
public TileEntity renderTile;
|
||||
public boolean renderTileErrored = true;
|
||||
public boolean renderFullBlock = true;
|
||||
public ITickable renderTileUpdate = null;
|
||||
|
||||
public TextPlane text1 = new TextPlane();
|
||||
@@ -219,12 +224,32 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler {
|
||||
EventHooks.onScriptBlockUpdate(this);
|
||||
ticksExisted = 0;
|
||||
if(needsClientUpdate){
|
||||
markDirty();
|
||||
worldObj.func_147451_t(xCoord, yCoord, zCoord);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord,zCoord,getBlockType(),3);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, CustomItems.scripted);
|
||||
|
||||
Chunk chunk = worldObj.getChunkFromChunkCoords(xCoord >> 4, zCoord >> 4);
|
||||
chunk.setBlockMetadata(xCoord & 15, yCoord, zCoord & 15, metadata);
|
||||
blockMetadata = metadata;
|
||||
|
||||
needsClientUpdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (worldObj.isRemote) {
|
||||
boolean markForUpdate = false;
|
||||
boolean prevHideModel = this.hideModel;
|
||||
boolean hideModel = BlockScriptedRenderer.overrideModel();
|
||||
|
||||
if (hideModel != prevHideModel) {
|
||||
this.hideModel = hideModel;
|
||||
markForUpdate = true;
|
||||
}
|
||||
|
||||
if (markForUpdate) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -232,11 +257,22 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler {
|
||||
handleUpdateTag(pkt.func_148857_g());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldRenderInPass(int arg0) {
|
||||
if (blockModel != null && blockModel.isOpaqueCube()
|
||||
&& !BlockScriptedRenderer.overrideModel()) {
|
||||
return true;
|
||||
}
|
||||
return super.shouldRenderInPass(arg0);
|
||||
}
|
||||
|
||||
public void handleUpdateTag(NBTTagCompound tag){
|
||||
int light = lightValue;
|
||||
setDisplayNBT(tag);
|
||||
if(light != lightValue)
|
||||
checkLight(worldObj,xCoord,yCoord,zCoord);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public boolean checkLight(World world, int x, int y, int z)
|
||||
@@ -273,6 +309,9 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler {
|
||||
if(NoppesUtilPlayer.compareItems(item, itemModel, false, false) && b != blockModel)
|
||||
return;
|
||||
|
||||
metadata = item.getItemDamage();
|
||||
blockMetadata = metadata;
|
||||
|
||||
itemModel = item;
|
||||
blockModel = b;
|
||||
needsClientUpdate = true;
|
||||
@@ -408,6 +447,11 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler {
|
||||
return this.customTileData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
super.markDirty();
|
||||
}
|
||||
|
||||
public class TextPlane implements ITextPlane {
|
||||
public boolean textHasChanged = true;
|
||||
public TextBlock textBlock;
|
||||
|
||||
@@ -27,10 +27,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import noppes.npcs.CommonProxy;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.PacketHandlerPlayer;
|
||||
import noppes.npcs.*;
|
||||
import noppes.npcs.api.IWorld;
|
||||
import noppes.npcs.blocks.tiles.*;
|
||||
import noppes.npcs.client.controllers.*;
|
||||
@@ -53,7 +50,8 @@ import noppes.npcs.client.gui.script.GuiScriptItem;
|
||||
import noppes.npcs.client.model.*;
|
||||
import noppes.npcs.client.renderer.*;
|
||||
import noppes.npcs.client.renderer.blocks.*;
|
||||
import noppes.npcs.client.renderer.customitem.CustomItemRenderer;
|
||||
import noppes.npcs.client.renderer.items.CustomItemRenderer;
|
||||
import noppes.npcs.client.renderer.items.ScriptedBlockItemRenderer;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.config.StringCache;
|
||||
@@ -105,6 +103,7 @@ public class ClientProxy extends CommonProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileBlockAnvil.class, new BlockCarpentryBenchRenderer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileMailbox.class, new BlockMailboxRenderer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileScripted.class, new BlockScriptedRenderer());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.scripted), new ScriptedBlockItemRenderer());
|
||||
RenderingRegistry.registerBlockHandler(new BlockBorderRenderer());
|
||||
|
||||
if(!ConfigMain.DisableExtraBlock){
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.client;
|
||||
|
||||
import kamkeel.addon.DBCAddon;
|
||||
import kamkeel.addon.GeckoAddon;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
@@ -11,7 +12,7 @@ public class EntityUtil {
|
||||
|
||||
public static void Copy(EntityLivingBase copied, EntityLivingBase entity){
|
||||
entity.worldObj = copied.worldObj;
|
||||
|
||||
|
||||
entity.deathTime = copied.deathTime;
|
||||
entity.distanceWalkedModified = copied.distanceWalkedModified;
|
||||
entity.prevDistanceWalkedModified = copied.distanceWalkedModified;
|
||||
@@ -20,18 +21,18 @@ public class EntityUtil {
|
||||
|
||||
entity.moveForward = copied.moveForward;
|
||||
entity.moveStrafing = copied.moveStrafing;
|
||||
|
||||
|
||||
entity.setPosition(copied.posX, copied.posY, copied.posZ);
|
||||
entity.boundingBox.setBB(copied.boundingBox);
|
||||
|
||||
|
||||
entity.prevPosX = copied.prevPosX;
|
||||
entity.prevPosY = copied.prevPosY;
|
||||
entity.prevPosZ = copied.prevPosZ;
|
||||
|
||||
|
||||
entity.motionX = copied.motionX;
|
||||
entity.motionY = copied.motionY;
|
||||
entity.motionZ = copied.motionZ;
|
||||
|
||||
|
||||
entity.rotationYaw = copied.rotationYaw;
|
||||
entity.rotationPitch = copied.rotationPitch;
|
||||
entity.prevRotationYaw = copied.prevRotationYaw;
|
||||
@@ -41,9 +42,9 @@ public class EntityUtil {
|
||||
entity.prevRenderYawOffset = copied.prevRenderYawOffset;
|
||||
entity.cameraPitch = copied.cameraPitch;
|
||||
entity.prevCameraPitch = copied.prevCameraPitch;
|
||||
|
||||
|
||||
entity.renderYawOffset = copied.renderYawOffset;
|
||||
|
||||
|
||||
entity.lastTickPosX = copied.lastTickPosX;
|
||||
entity.lastTickPosY = copied.lastTickPosY;
|
||||
entity.lastTickPosZ = copied.lastTickPosZ;
|
||||
@@ -56,9 +57,9 @@ public class EntityUtil {
|
||||
entity.prevSwingProgress = copied.prevSwingProgress;
|
||||
entity.isSwingInProgress = copied.isSwingInProgress;
|
||||
entity.swingProgressInt = copied.swingProgressInt;
|
||||
|
||||
|
||||
entity.ticksExisted = copied.ticksExisted;
|
||||
|
||||
|
||||
if(entity instanceof EntityPlayer && copied instanceof EntityPlayer){
|
||||
EntityPlayer ePlayer = (EntityPlayer) entity;
|
||||
EntityPlayer cPlayer = (EntityPlayer) copied;
|
||||
@@ -73,19 +74,20 @@ public class EntityUtil {
|
||||
ePlayer.field_71095_bQ = cPlayer.field_71095_bQ;
|
||||
ePlayer.field_71085_bR = cPlayer.field_71085_bR;
|
||||
}
|
||||
|
||||
|
||||
if(entity instanceof EntityDragon){
|
||||
entity.rotationYaw += 180;
|
||||
}
|
||||
if(entity instanceof EntityChicken){
|
||||
((EntityChicken)entity).destPos = copied.onGround?0:1;
|
||||
}
|
||||
|
||||
|
||||
for(int i = 0; i < 5; i++){
|
||||
entity.setCurrentItemOrArmor(i, copied.getEquipmentInSlot(i));
|
||||
}
|
||||
|
||||
GeckoAddon.instance.geckoCopyData(copied, entity);
|
||||
DBCAddon.instance.dbcCopyData(copied, entity);
|
||||
|
||||
if(copied instanceof EntityNPCInterface && entity instanceof EntityNPCInterface){
|
||||
EntityNPCInterface npc = (EntityNPCInterface) copied;
|
||||
@@ -94,9 +96,9 @@ public class EntityUtil {
|
||||
target.textureLocation = npc.textureLocation;
|
||||
target.display = npc.display;
|
||||
target.inventory = npc.inventory;
|
||||
|
||||
|
||||
target.currentAnimation = npc.currentAnimation;
|
||||
|
||||
|
||||
target.setDataWatcher(npc.getDataWatcher());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package noppes.npcs.client.gui.mainmenu;
|
||||
|
||||
import kamkeel.addon.DBCAddon;
|
||||
import kamkeel.addon.client.DBCClient;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.EnumCreatureAttribute;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -70,6 +72,8 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
|
||||
addLabel(new GuiNpcLabel(18,"stats.attackInvisible", guiLeft + 140, y + 5));
|
||||
addLabel(new GuiNpcLabel(34,"stats.creaturetype", guiLeft + 275, y + 5));
|
||||
addButton(new GuiNpcButton(8,guiLeft + 358, y, 56, 20, new String[]{"stats.normal","stats.undead","stats.arthropod"} ,stats.creatureType.ordinal()));
|
||||
|
||||
DBCClient.Instance.showDBCStatButtons(this, npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,6 +138,10 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
|
||||
else if (button.id == 22) {
|
||||
stats.ignoreCobweb = (button.getValue() == 0);
|
||||
}
|
||||
|
||||
// Button 300
|
||||
if(guibutton instanceof GuiNpcButton)
|
||||
DBCClient.Instance.showDBCStatActionPerformed(this, (GuiNpcButton) guibutton);
|
||||
}
|
||||
@Override
|
||||
public void save() {
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package noppes.npcs.client.renderer.blocks;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.blocks.BlockScripted;
|
||||
@@ -28,26 +27,58 @@ public class BlockScriptedRenderer extends BlockRendererInterface{
|
||||
private static final RenderBlocks renderBlocks = new RenderBlocks();
|
||||
private static final Random random = new Random();
|
||||
|
||||
public BlockScriptedRenderer() {
|
||||
((BlockScripted) CustomItems.scripted).renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
Block blockModel = tile.blockModel;
|
||||
|
||||
if (!overrideModel() && blockModel != null) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(tile.rotationY, 0, 1, 0);
|
||||
GL11.glRotatef(tile.rotationX, 1, 0, 0);
|
||||
GL11.glRotatef(tile.rotationZ, 0, 0, 1);
|
||||
GL11.glScalef(tile.scaleX, tile.scaleY, tile.scaleZ);
|
||||
if (blockModel != CustomItems.scripted) {
|
||||
tile.renderFullBlock = renderer.renderBlockByRenderType(blockModel, x, y, z);
|
||||
} else {
|
||||
renderer.renderStandardBlock(blockModel, x, y, z);
|
||||
tile.renderFullBlock = true;
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
} else {
|
||||
renderer.renderStandardBlock(CustomItems.scripted, x, y, z);
|
||||
tile.renderFullBlock = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getRenderId() {
|
||||
return CustomItems.scripted.getRenderType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks) {
|
||||
TileScripted tile = (TileScripted) te;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glTranslatef((float) (x + 0.5), (float) y, (float) (z + 0.5));
|
||||
if (overrideModel()) {
|
||||
GL11.glTranslatef(0, 0.5F, 0);
|
||||
renderItem(te, new ItemStack(CustomItems.scripted));
|
||||
} else {
|
||||
if (!tile.renderFullBlock) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glTranslatef((float) (x + 0.5), (float) y, (float) (z + 0.5));
|
||||
GL11.glRotatef(tile.rotationY, 0, 1, 0);
|
||||
GL11.glRotatef(tile.rotationX, 1, 0, 0);
|
||||
GL11.glRotatef(tile.rotationZ, 0, 0, 1);
|
||||
GL11.glScalef(tile.scaleX, tile.scaleY, tile.scaleZ);
|
||||
GL11.glTranslatef(0, 0.5F, 0);
|
||||
renderItem(te, tile.itemModel);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (!tile.text1.text.isEmpty()) {
|
||||
drawText(tile.text1, x, y, z);
|
||||
@@ -152,7 +183,7 @@ public class BlockScriptedRenderer extends BlockRendererInterface{
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private boolean overrideModel() {
|
||||
public static boolean overrideModel() {
|
||||
ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
|
||||
if (held == null)
|
||||
return false;
|
||||
@@ -166,7 +197,7 @@ public class BlockScriptedRenderer extends BlockRendererInterface{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return 0;
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package noppes.npcs.client.renderer.customitem;
|
||||
package noppes.npcs.client.renderer.items;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
@@ -0,0 +1,77 @@
|
||||
package noppes.npcs.client.renderer.items;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import noppes.npcs.CustomItems;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ScriptedBlockItemRenderer implements IItemRenderer {
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return type != ItemRenderType.FIRST_PERSON_MAP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
RenderBlocks renderBlocks = (RenderBlocks) data[0];
|
||||
if (type == ItemRenderType.INVENTORY) {
|
||||
GL11.glTranslatef(0, -0.1f, 0);
|
||||
renderBlock(item, renderBlocks);
|
||||
} else if (type == ItemRenderType.EQUIPPED) {
|
||||
GL11.glTranslatef(0.5F, 0.4F, 0.5F);
|
||||
renderBlock(item, renderBlocks);
|
||||
} else if (type == ItemRenderType.ENTITY) {
|
||||
renderBlock(item, renderBlocks);
|
||||
} else if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
GL11.glTranslatef(0.5F, 0.4F, 0.5F);
|
||||
renderBlock(item, renderBlocks);
|
||||
}
|
||||
}
|
||||
|
||||
private void renderBlock(ItemStack item, RenderBlocks renderBlocks) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
Block block = CustomItems.scripted;
|
||||
int p_147800_2_ = item.getItemDamage();
|
||||
|
||||
block.setBlockBoundsForItemRender();
|
||||
renderBlocks.setRenderBoundsFromBlock(block);
|
||||
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(-0.5F, -0.4F, -0.5F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
renderBlocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderBlocks.getBlockIconFromSideAndMetadata(block, 0, p_147800_2_));
|
||||
tessellator.draw();
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderBlocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderBlocks.getBlockIconFromSideAndMetadata(block, 1, p_147800_2_));
|
||||
tessellator.draw();
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
renderBlocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderBlocks.getBlockIconFromSideAndMetadata(block, 2, p_147800_2_));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderBlocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderBlocks.getBlockIconFromSideAndMetadata(block, 3, p_147800_2_));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
renderBlocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderBlocks.getBlockIconFromSideAndMetadata(block, 4, p_147800_2_));
|
||||
tessellator.draw();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderBlocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderBlocks.getBlockIconFromSideAndMetadata(block, 5, p_147800_2_));
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
@@ -228,6 +228,8 @@ public class ScriptContainer {
|
||||
}
|
||||
|
||||
public boolean hasCode() {
|
||||
if(!scripts.isEmpty())
|
||||
return true;
|
||||
return !this.getFullCode().isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import jdk.nashorn.api.scripting.ClassFilter;
|
||||
import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
@@ -24,12 +25,11 @@ import javax.script.ScriptContext;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineFactory;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import static noppes.npcs.util.CustomNPCsThreader.customNPCThread;
|
||||
|
||||
public class ScriptController {
|
||||
|
||||
public static ScriptController Instance;
|
||||
@@ -42,9 +42,7 @@ public class ScriptController {
|
||||
public File dir;
|
||||
public NBTTagCompound compound = new NBTTagCompound();
|
||||
|
||||
private boolean loaded = false;
|
||||
public boolean shouldSave = false;
|
||||
|
||||
public PlayerDataScript playerScripts = new PlayerDataScript((EntityPlayer)null);
|
||||
public long lastPlayerUpdate = 0L;
|
||||
|
||||
@@ -55,7 +53,6 @@ public class ScriptController {
|
||||
public long lastGlobalNpcUpdate = 0L;
|
||||
|
||||
public ScriptController(){
|
||||
loaded = false;
|
||||
Instance = this;
|
||||
manager = new ScriptEngineManager();
|
||||
if(!ConfigScript.ScriptingEnabled)
|
||||
@@ -176,6 +173,26 @@ public class ScriptController {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void saveForgeScriptsSync(){
|
||||
customNPCThread.execute(this::saveForgeScripts);
|
||||
}
|
||||
|
||||
public synchronized void savePlayerScriptsSync(){
|
||||
customNPCThread.execute(() -> {
|
||||
File file = this.playerScriptsFile();
|
||||
try {
|
||||
NBTJsonUtil.SaveFile(file, this.playerScripts.writeToNBT(new NBTTagCompound()));
|
||||
this.playerScripts.lastInited = -1L;
|
||||
} catch (IOException | JsonException var4) {
|
||||
var4.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public synchronized void saveGlobalScriptsSync(){
|
||||
customNPCThread.execute(this::saveGlobalNpcScripts);
|
||||
}
|
||||
|
||||
public void loadCategories(){
|
||||
dir = new File(CustomNpcs.getWorldSaveDirectory(), "scripts");
|
||||
if(!dir.exists())
|
||||
|
||||
@@ -2,6 +2,7 @@ package noppes.npcs.entity;
|
||||
|
||||
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.addon.DBCAddon;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
@@ -232,41 +233,49 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attackEntityAsMob(Entity par1Entity){
|
||||
public boolean attackEntityAsMob(Entity receiver){
|
||||
float f = stats.getAttackStrength();
|
||||
|
||||
if (stats.attackSpeed < 10){
|
||||
par1Entity.hurtResistantTime = 0;
|
||||
receiver.hurtResistantTime = 0;
|
||||
}
|
||||
if(par1Entity instanceof EntityLivingBase && !isRemote()){
|
||||
NpcEvent.MeleeAttackEvent event = new NpcEvent.MeleeAttackEvent(wrappedNPC, f, (EntityLivingBase)par1Entity);
|
||||
if(receiver instanceof EntityLivingBase && !isRemote()){
|
||||
NpcEvent.MeleeAttackEvent event = new NpcEvent.MeleeAttackEvent(wrappedNPC, f, (EntityLivingBase)receiver);
|
||||
if(EventHooks.onNPCMeleeAttack(this, event))
|
||||
return false;
|
||||
f = event.getDamage();
|
||||
}
|
||||
|
||||
boolean var4 = par1Entity.attackEntityFrom(new NpcDamageSource("mob", this), f);
|
||||
boolean didAttack = false;
|
||||
if(DBCAddon.instance.canDBCAttack(this, f, receiver)){
|
||||
didAttack = receiver.attackEntityFrom(new NpcDamageSource("mob", this), 1.0f);
|
||||
if(didAttack)
|
||||
DBCAddon.instance.doDBCDamage(this, f, receiver);
|
||||
}
|
||||
else
|
||||
didAttack = receiver.attackEntityFrom(new NpcDamageSource("mob", this), f);
|
||||
|
||||
if (var4){
|
||||
|
||||
if (didAttack){
|
||||
if(getOwner() instanceof EntityPlayer)
|
||||
NPCEntityHelper.setRecentlyHit((EntityLivingBase)par1Entity);
|
||||
NPCEntityHelper.setRecentlyHit((EntityLivingBase)receiver);
|
||||
if (stats.knockback > 0){
|
||||
par1Entity.addVelocity((double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * (float)stats.knockback * 0.5F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * (float)stats.knockback * 0.5F));
|
||||
receiver.addVelocity((double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * (float)stats.knockback * 0.5F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * (float)stats.knockback * 0.5F));
|
||||
this.motionX *= 0.6D;
|
||||
this.motionZ *= 0.6D;
|
||||
}
|
||||
if(advanced.role == EnumRoleType.Companion){
|
||||
((RoleCompanion)roleInterface).attackedEntity(par1Entity);
|
||||
((RoleCompanion)roleInterface).attackedEntity(receiver);
|
||||
}
|
||||
}
|
||||
|
||||
if (stats.potionType != EnumPotionType.None){
|
||||
if (stats.potionType != EnumPotionType.Fire)
|
||||
((EntityLivingBase)par1Entity).addPotionEffect(new PotionEffect(this.getPotionEffect(stats.potionType), stats.potionDuration * 20, stats.potionAmp));
|
||||
((EntityLivingBase)receiver).addPotionEffect(new PotionEffect(this.getPotionEffect(stats.potionType), stats.potionDuration * 20, stats.potionAmp));
|
||||
else
|
||||
par1Entity.setFire(stats.potionDuration);
|
||||
receiver.setFire(stats.potionDuration);
|
||||
}
|
||||
return var4;
|
||||
return didAttack;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.*;
|
||||
|
||||
public class QuestItem extends QuestInterface implements IQuestItem {
|
||||
public NpcMiscInventory items = new NpcMiscInventory(3);
|
||||
public static EntityPlayer pickedUpPlayerSolo;
|
||||
public static ItemStack pickedUp;
|
||||
|
||||
public static ItemStack pickedUpParty;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package noppes.npcs.scripted.entity;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.api.IPos;
|
||||
import noppes.npcs.api.ITimers;
|
||||
@@ -617,7 +618,11 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
* @param item The item the drop list slot will be changed to
|
||||
*/
|
||||
public void setLootItem(int slot, IItemStack item) {
|
||||
npc.inventory.setInventorySlotContents(slot+7, item.getMCItemStack());
|
||||
if(item == null || item.getMCItemStack() == null){
|
||||
npc.inventory.setInventorySlotContents(slot+7, (ItemStack) null);
|
||||
} else {
|
||||
npc.inventory.setInventorySlotContents(slot+7, item.getMCItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user