mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 07:35:11 +00:00
Dev into Experimental
This commit is contained in:
commit
bfb6e968ee
28 files changed
+2181
-99
No files matched your search
@@ -189,6 +189,7 @@ public class CustomItems {
|
||||
public static Block lamp_unlit;
|
||||
public static Block campfire_unlit;
|
||||
public static Block candle_unlit;
|
||||
public static Block scripted;
|
||||
|
||||
public static Item crossbowBolt;
|
||||
|
||||
@@ -204,6 +205,7 @@ public class CustomItems {
|
||||
GameRegistry.registerTileEntity(TileMailbox.class, "TileMailbox");
|
||||
GameRegistry.registerTileEntity(TileWaypoint.class, "TileWaypoint");
|
||||
GameRegistry.registerTileEntity(TileBanner.class, "TileNPCBanner");
|
||||
GameRegistry.registerTileEntity(TileScripted.class, "TileNPCScripted");
|
||||
|
||||
if(!ConfigMain.DisableExtraBlock){
|
||||
GameRegistry.registerTileEntity(TileWallBanner.class, "TileNPCWallBanner");
|
||||
@@ -241,6 +243,7 @@ public class CustomItems {
|
||||
mailbox = new BlockMailbox().setBlockName("npcMailbox").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(tabBlocks);
|
||||
waypoint = new BlockWaypoint().setBlockName("npcLocationBlock").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setBlockTextureName("customnpcs:npcWaypoint").setCreativeTab(tab);
|
||||
border = new BlockBorder().setBlockName("npcBorder").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tab).setBlockTextureName("customnpcs:npcBorder");
|
||||
scripted = new BlockScripted().setBlockName("npcScripted").setHardness(5.0F).setResistance(10.0F).setCreativeTab(tab).setBlockTextureName("customnpcs:npcScripted");
|
||||
|
||||
soulstoneEmpty = new ItemSoulstoneEmpty().setUnlocalizedName("npcSoulstoneEmpty").setTextureName("customnpcs:npcSoulstoneEmpty").setCreativeTab(tab);
|
||||
soulstoneFull = new ItemSoulstoneFilled().setUnlocalizedName("npcSoulstoneFilled").setTextureName("customnpcs:npcSoulstoneFilled");
|
||||
@@ -262,6 +265,7 @@ public class CustomItems {
|
||||
GameRegistry.registerBlock(mailbox, ItemBlock.class, "npcMailbox");
|
||||
GameRegistry.registerBlock(waypoint, "npcWaypoint");
|
||||
GameRegistry.registerBlock(border, "npcBorder");
|
||||
GameRegistry.registerBlock(scripted, "npcScripted");
|
||||
|
||||
Item.getItemFromBlock(mailbox).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(carpentyBench).setHasSubtypes(true);
|
||||
|
||||
@@ -35,7 +35,7 @@ import noppes.npcs.scripted.NpcAPI;
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.9-beta3")
|
||||
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.9-beta4")
|
||||
public class CustomNpcs {
|
||||
|
||||
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
@@ -641,4 +642,108 @@ public class EventHooks {
|
||||
handler.callScript(EnumScriptType.DIALOG_CLOSE, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onScriptBlockInteract(IScriptBlockHandler handler, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
if(handler.isClient())
|
||||
return false;
|
||||
BlockEvent.InteractEvent event = new BlockEvent.InteractEvent(handler.getBlock(), player, side, hitX, hitY, hitZ);
|
||||
handler.callScript(EnumScriptType.INTERACT, event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onScriptBlockCollide(IScriptBlockHandler handler, Entity entityIn) {
|
||||
if(handler.isClient())
|
||||
return;
|
||||
BlockEvent.CollidedEvent event = new BlockEvent.CollidedEvent(handler.getBlock(), entityIn);
|
||||
handler.callScript(EnumScriptType.COLLIDE, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onScriptBlockRainFill(IScriptBlockHandler handler) {
|
||||
if(handler.isClient())
|
||||
return;
|
||||
BlockEvent.RainFillEvent event = new BlockEvent.RainFillEvent(handler.getBlock());
|
||||
handler.callScript(EnumScriptType.RAIN_FILLED, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static float onScriptBlockFallenUpon(IScriptBlockHandler handler, Entity entity, float distance) {
|
||||
if(handler.isClient())
|
||||
return distance;
|
||||
BlockEvent.EntityFallenUponEvent event = new BlockEvent.EntityFallenUponEvent(handler.getBlock(), entity, distance);
|
||||
handler.callScript(EnumScriptType.FALLEN_UPON, event);
|
||||
if(NpcAPI.EVENT_BUS.post(event))
|
||||
return 0;
|
||||
return event.distanceFallen;
|
||||
}
|
||||
|
||||
public static void onScriptBlockClicked(IScriptBlockHandler handler, EntityPlayer player) {
|
||||
if(handler.isClient())
|
||||
return;
|
||||
BlockEvent.ClickedEvent event = new BlockEvent.ClickedEvent(handler.getBlock(), player);
|
||||
handler.callScript(EnumScriptType.CLICKED, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onScriptBlockBreak(IScriptBlockHandler handler) {
|
||||
if(handler.isClient())
|
||||
return;
|
||||
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(handler.getBlock());
|
||||
handler.callScript(EnumScriptType.BROKEN, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onScriptBlockHarvest(IScriptBlockHandler handler, EntityPlayer player) {
|
||||
if(handler.isClient())
|
||||
return false;
|
||||
BlockEvent.HarvestedEvent event = new BlockEvent.HarvestedEvent(handler.getBlock(), player);
|
||||
handler.callScript(EnumScriptType.HARVESTED, event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onScriptBlockExploded(IScriptBlockHandler handler) {
|
||||
if(handler.isClient())
|
||||
return false;
|
||||
BlockEvent.ExplodedEvent event = new BlockEvent.ExplodedEvent(handler.getBlock());
|
||||
handler.callScript(EnumScriptType.EXPLODED, event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onScriptBlockNeighborChanged(IScriptBlockHandler handler, int x, int y, int z) {
|
||||
if(handler.isClient())
|
||||
return;
|
||||
BlockEvent.NeighborChangedEvent event = new BlockEvent.NeighborChangedEvent(handler.getBlock(), NpcAPI.Instance().getIPos(x,y,z));
|
||||
handler.callScript(EnumScriptType.NEIGHBOR_CHANGED, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onScriptBlockRedstonePower(IScriptBlockHandler handler, int prevPower, int power) {
|
||||
if(handler.isClient())
|
||||
return;
|
||||
BlockEvent.RedstoneEvent event = new BlockEvent.RedstoneEvent(handler.getBlock(), prevPower, power);
|
||||
handler.callScript(EnumScriptType.REDSTONE, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onScriptBlockInit(IScriptBlockHandler handler) {
|
||||
if(handler.isClient())
|
||||
return;
|
||||
BlockEvent.InitEvent event = new BlockEvent.InitEvent(handler.getBlock());
|
||||
handler.callScript(EnumScriptType.INIT, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onScriptBlockUpdate(IScriptBlockHandler handler) {
|
||||
if(handler.isClient())
|
||||
return;
|
||||
BlockEvent.UpdateEvent event = new BlockEvent.UpdateEvent(handler.getBlock());
|
||||
handler.callScript(EnumScriptType.TICK, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onScriptBlockTimer(IScriptBlockHandler handler, int id) {
|
||||
BlockEvent.TimerEvent event = new BlockEvent.TimerEvent(handler.getBlock(), id);
|
||||
handler.callScript(EnumScriptType.TIMER, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
}
|
||||
@@ -851,6 +851,10 @@ public class NoppesUtilServer {
|
||||
return null;
|
||||
}
|
||||
|
||||
static public EntityPlayer getPlayerByName(String playername){
|
||||
return MinecraftServer.getServer().getConfigurationManager().func_152612_a(playername);
|
||||
}
|
||||
|
||||
public static Entity GetDamageSourcee(DamageSource damagesource) {
|
||||
Object entity = damagesource.getEntity();
|
||||
if(entity == null) {
|
||||
|
||||
@@ -275,7 +275,7 @@ public class PacketHandlerPlayer{
|
||||
int x = buffer.readInt(), y = buffer.readInt(), z = buffer.readInt();
|
||||
if (player.worldObj.blockExists(x, y, z)) {
|
||||
TileEntity tile = player.worldObj.getTileEntity(x, y, z);
|
||||
if (!(tile instanceof TileBigSign))
|
||||
if(!(tile instanceof TileBigSign))
|
||||
return;
|
||||
TileBigSign sign = (TileBigSign) tile;
|
||||
if (sign.canEdit) {
|
||||
|
||||
@@ -22,11 +22,13 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.blocks.tiles.TileScripted;
|
||||
import noppes.npcs.config.ConfigDebug;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.config.ConfigScript;
|
||||
@@ -112,25 +114,12 @@ public class PacketHandlerServer{
|
||||
PlayerDataController.Instance.getPlayerData(player).animationData.cacheAnimation(buffer.readInt());
|
||||
return;
|
||||
} else if (type == EnumPacketServer.GetPartyData || type == EnumPacketServer.CreateParty) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
if (type == EnumPacketServer.CreateParty) {
|
||||
Party party = PartyController.Instance().createParty();
|
||||
party.addPlayer(player);
|
||||
party.setLeader(player);
|
||||
}
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if (playerData.partyUUID != null) {
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
compound = party.writeToNBT();
|
||||
|
||||
Quest quest = (Quest) QuestController.Instance.get(party.getCurrentQuestID());
|
||||
if (quest != null) {
|
||||
compound.setString("QuestName", quest.getName());
|
||||
compound.setString("QuestCategory", quest.getCategory().getName());
|
||||
}
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
sendPartyData(player);
|
||||
} else if (type == EnumPacketServer.DisbandParty) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
if (playerData.partyUUID != null) {
|
||||
@@ -140,6 +129,58 @@ public class PacketHandlerServer{
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("Disband", true);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
} else if (type == EnumPacketServer.KickPlayer) {
|
||||
EntityPlayer kickPlayer = NoppesUtilServer.getPlayerByName(Server.readString(buffer));
|
||||
if (kickPlayer != null) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
if (playerData.partyUUID != null) {
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
party.removePlayer(kickPlayer);
|
||||
if (kickPlayer != player) {
|
||||
sendPartyData(player);
|
||||
} else {
|
||||
sendInviteData((EntityPlayerMP) kickPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (type == EnumPacketServer.SavePartyData) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
if (playerData.partyUUID != null) {
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
party.readClientNBT(Server.readNBT(buffer));
|
||||
}
|
||||
} else if (type == EnumPacketServer.SetPartyLeader) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
if (playerData.partyUUID != null) {
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
party.setLeader(NoppesUtilServer.getPlayerByName(Server.readString(buffer)));
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, party.writeToNBT());
|
||||
}
|
||||
} else if (type == EnumPacketServer.PartyInvite) {
|
||||
EntityPlayer invitedPlayer = NoppesUtilServer.getPlayerByName(Server.readString(buffer));
|
||||
if (invitedPlayer != null) {
|
||||
PlayerData senderData = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerData invitedData = PlayerDataController.Instance.getPlayerData(invitedPlayer);
|
||||
if (senderData.partyUUID != null && invitedData.partyUUID == null) {//only send invite if player is not in a party
|
||||
invitedData.inviteToParty(PartyController.Instance().getParty(senderData.partyUUID));
|
||||
}
|
||||
}
|
||||
} else if (type == EnumPacketServer.GetPartyInviteList) {
|
||||
sendInviteData(player);
|
||||
} else if (type == EnumPacketServer.AcceptInvite) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
String uuidString = Server.readString(buffer);
|
||||
if (uuidString != null) {
|
||||
UUID uuid = UUID.fromString(uuidString);
|
||||
playerData.acceptInvite(uuid);
|
||||
}
|
||||
} else if (type == EnumPacketServer.IgnoreInvite) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
String uuidString = Server.readString(buffer);
|
||||
if (uuidString != null) {
|
||||
UUID uuid = UUID.fromString(uuidString);
|
||||
playerData.ignoreInvite(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
if(type.needsNpc && npc == null){
|
||||
@@ -175,6 +216,8 @@ public class PacketHandlerServer{
|
||||
forgeScriptPackets(type, buffer, player);
|
||||
else if (type == EnumPacketServer.ScriptItemDataGet || type == EnumPacketServer.ScriptItemDataSave)
|
||||
itemScriptPackets(type, buffer, player);
|
||||
else if (type == EnumPacketServer.ScriptBlockDataGet || type == EnumPacketServer.ScriptBlockDataSave)
|
||||
blockScriptPackets(type, buffer, player);
|
||||
else if (type == EnumPacketServer.ScriptGlobalGuiDataGet || type == EnumPacketServer.ScriptGlobalGuiDataSave)
|
||||
getScriptsEnabled(type, buffer, player);
|
||||
else if (item.getItem() == CustomItems.scripter)
|
||||
@@ -187,6 +230,35 @@ public class PacketHandlerServer{
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendPartyData(EntityPlayerMP player) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
|
||||
if (playerData.partyUUID != null) {
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, party.writeToNBT());
|
||||
} else {
|
||||
sendInviteData(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendInviteData(EntityPlayerMP player) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
if (playerData.partyUUID == null) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
NBTTagList list = new NBTTagList();
|
||||
HashSet<UUID> partyInvites = playerData.getPartyInvites();
|
||||
for (UUID uuid : partyInvites) {
|
||||
Party party = PartyController.Instance().getParty(uuid);
|
||||
NBTTagCompound partyCompound = new NBTTagCompound();
|
||||
partyCompound.setString("PartyLeader", party.getPartyLeaderName());
|
||||
partyCompound.setString("PartyUUID", party.getPartyUUID().toString());
|
||||
list.appendTag(partyCompound);
|
||||
}
|
||||
compound.setTag("PartyInvites", list);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
}
|
||||
|
||||
private void isGuiOpenPacket(ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
NoppesUtilServer.isGUIOpen(buffer, player);
|
||||
}
|
||||
@@ -339,6 +411,27 @@ public class PacketHandlerServer{
|
||||
}
|
||||
}
|
||||
|
||||
private void blockScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
|
||||
if (type == EnumPacketServer.ScriptBlockDataGet) {
|
||||
TileEntity tile = player.worldObj.getTileEntity(buffer.readInt(), buffer.readInt(), buffer.readInt());
|
||||
if(!(tile instanceof TileScripted))
|
||||
return;
|
||||
NBTTagCompound compound = ((TileScripted) tile).getNBT(new NBTTagCompound());
|
||||
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
} else if (type == EnumPacketServer.ScriptBlockDataSave) {
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
return;
|
||||
}
|
||||
TileEntity tile = player.worldObj.getTileEntity(buffer.readInt(), buffer.readInt(), buffer.readInt());
|
||||
if(!(tile instanceof TileScripted))
|
||||
return;
|
||||
TileScripted script = (TileScripted) tile;
|
||||
script.setNBT(Server.readNBT(buffer));
|
||||
script.lastInited = -1;
|
||||
}
|
||||
}
|
||||
|
||||
private void featherPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
if(type == EnumPacketServer.DimensionTeleport){
|
||||
int dimension = buffer.readInt();
|
||||
|
||||
@@ -21,6 +21,7 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityInteractEvent;
|
||||
@@ -135,7 +136,20 @@ public class ServerEventsHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(LivingAttackEvent event) {
|
||||
if(!(event.source != null && event.source.getEntity() instanceof EntityPlayer) || !(event.entityLiving instanceof EntityPlayer) || FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
return;
|
||||
|
||||
EntityPlayer sourcePlayer = (EntityPlayer) event.source.getEntity();
|
||||
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(sourcePlayer);
|
||||
PlayerData targetData = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entityLiving);
|
||||
if (playerData.partyUUID != null && playerData.partyUUID.equals(targetData.partyUUID)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -7,6 +7,8 @@ import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.client.AnalyticsTracking;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
@@ -40,5 +42,18 @@ public class ServerTickHandler {
|
||||
serverName = e;
|
||||
}
|
||||
AnalyticsTracking.sendData(event.player, "join", serverName);
|
||||
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player);
|
||||
if (playerData != null) {
|
||||
playerData.onLogin();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerLogout(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player);
|
||||
if (playerData != null) {
|
||||
playerData.onLogout();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package noppes.npcs.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.EventHooks;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.blocks.tiles.TileScripted;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockScripted extends BlockContainer {
|
||||
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);
|
||||
|
||||
public BlockScripted() {
|
||||
super(Material.rock);
|
||||
setStepSound(soundTypeStone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||
return new TileScripted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
if (tile != null && tile.isPassible)
|
||||
return AABB_EMPTY;
|
||||
return AABB.getOffsetBoundingBox(x,y,z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
if (tile != null && tile.isPassible)
|
||||
return AABB_EMPTY;
|
||||
return AABB.getOffsetBoundingBox(x,y,z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote)
|
||||
return true;
|
||||
ItemStack currentItem = player.inventory.getCurrentItem();
|
||||
if (currentItem != null && (currentItem.getItem() == CustomItems.wand || currentItem.getItem() == CustomItems.scripter)) {
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.ScriptBlock, null, x, y, z);
|
||||
return true;
|
||||
}
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
return !EventHooks.onScriptBlockInteract(tile, player, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) {
|
||||
if (entity instanceof EntityPlayer && !world.isRemote) {
|
||||
NoppesUtilServer.sendOpenGui((EntityPlayer) entity, EnumGuiType.ScriptBlock, null, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entityIn) {
|
||||
if (world.isRemote)
|
||||
return;
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
EventHooks.onScriptBlockCollide(tile, entityIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillWithRain(World world, int x, int y, int z) {
|
||||
if (world.isRemote)
|
||||
return;
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
EventHooks.onScriptBlockRainFill(tile);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onFallenUpon(World world, int x, int y, int z, Entity entity, float fallDistance) {
|
||||
if (world.isRemote)
|
||||
return;
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
fallDistance = EventHooks.onScriptBlockFallenUpon(tile, entity, fallDistance);
|
||||
super.onFallenUpon(world, x, y, z, entity, fallDistance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInPass(int pass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
|
||||
if (world.isRemote)
|
||||
return;
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
EventHooks.onScriptBlockClicked(tile, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int metadata) {
|
||||
if (!world.isRemote) {
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
EventHooks.onScriptBlockBreak(tile);
|
||||
}
|
||||
super.breakBlock(world, x, y, z, block, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
|
||||
if (!world.isRemote) {
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
if (EventHooks.onScriptBlockHarvest(tile, player))
|
||||
return false;
|
||||
}
|
||||
return super.removedByPlayer(world, player, x, y, z, willHarvest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int i, Random rand, int fortune) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) {
|
||||
if (!world.isRemote) {
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
if (EventHooks.onScriptBlockExploded(tile))
|
||||
return;
|
||||
}
|
||||
super.onBlockExploded(world, x, y, z, explosion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower(IBlockAccess worldIn, int x, int y, int z, int side) {
|
||||
return this.isProvidingStrongPower(worldIn, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return ((TileScripted) world.getTileEntity(x, y, z)).activePowering;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity) {
|
||||
return ((TileScripted) world.getTileEntity(x, y, z)).isLadder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness(World world, int x, int y, int z) {
|
||||
return ((TileScripted) world.getTileEntity(x, y, z)).blockHardness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
if (tile == null)
|
||||
return 0;
|
||||
return tile.lightValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) {
|
||||
return ((TileScripted) world.getTileEntity(x, y, z)).blockResistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) {
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
EventHooks.onScriptBlockNeighborChanged(tile, tileX, tileY, tileZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
|
||||
int power = 0;
|
||||
for (EnumFacing enumfacing : EnumFacing.values()) {
|
||||
int p = world.getIndirectPowerLevelTo(x + enumfacing.getFrontOffsetX(),
|
||||
y + enumfacing.getFrontOffsetZ(), z + enumfacing.getFrontOffsetZ(), enumfacing.ordinal());
|
||||
if (p > power)
|
||||
power = p;
|
||||
}
|
||||
if (tile.prevPower != power && tile.powering <= 0) {
|
||||
tile.newPower = power;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,542 @@
|
||||
package noppes.npcs.blocks.tiles;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.ITickable;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.*;
|
||||
import noppes.npcs.api.IBlock;
|
||||
import noppes.npcs.api.block.ITextPlane;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.data.IScriptBlockHandler;
|
||||
import noppes.npcs.entity.data.DataTimers;
|
||||
import noppes.npcs.scripted.BlockScriptedWrapper;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class TileScripted extends TileEntity implements IScriptBlockHandler {
|
||||
public List<ScriptContainer> scripts = new ArrayList<>();
|
||||
|
||||
public Map<String,Object> tempData = new HashMap<>();
|
||||
|
||||
private NBTTagCompound customTileData;
|
||||
|
||||
public String scriptLanguage = "ECMAScript";
|
||||
public boolean enabled = false;
|
||||
|
||||
private IBlock blockDummy = null;
|
||||
public DataTimers timers = new DataTimers(this);
|
||||
|
||||
public long lastInited = -1;
|
||||
|
||||
private short ticksExisted = 0;
|
||||
|
||||
public ItemStack itemModel = new ItemStack(CustomItems.scripted);
|
||||
public Block blockModel = null;
|
||||
|
||||
public boolean needsClientUpdate = false;
|
||||
|
||||
public int powering = 0;
|
||||
public int activePowering = 0;
|
||||
public int newPower = 0; //used for block redstone event
|
||||
public int prevPower = 0; //used for block redstone event
|
||||
|
||||
public boolean isPassible = false;
|
||||
public boolean isLadder = false;
|
||||
public int lightValue = 0;
|
||||
|
||||
public float blockHardness = 5;
|
||||
public float blockResistance = 10;
|
||||
|
||||
public int rotationX = 0, rotationY = 0, rotationZ = 0;
|
||||
public float scaleX = 1, scaleY = 1, scaleZ = 1;
|
||||
|
||||
public TileEntity renderTile;
|
||||
public boolean renderTileErrored = true;
|
||||
public ITickable renderTileUpdate = null;
|
||||
|
||||
public TextPlane text1 = new TextPlane();
|
||||
public TextPlane text2 = new TextPlane();
|
||||
public TextPlane text3 = new TextPlane();
|
||||
public TextPlane text4 = new TextPlane();
|
||||
public TextPlane text5 = new TextPlane();
|
||||
public TextPlane text6 = new TextPlane();
|
||||
|
||||
public IBlock getBlock(){
|
||||
if(blockDummy == null)
|
||||
blockDummy = new BlockScriptedWrapper(worldObj, this.getBlockType(), xCoord,yCoord,zCoord);
|
||||
return blockDummy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound){
|
||||
super.readFromNBT(compound);
|
||||
setNBT(compound);
|
||||
setDisplayNBT(compound);
|
||||
timers.readFromNBT(compound);
|
||||
NBTTagCompound extraData = compound.getCompoundTag("ExtraData");
|
||||
if(!extraData.hasNoTags()){
|
||||
getTileData().setTag("CustomNPCsData", extraData);
|
||||
}
|
||||
}
|
||||
|
||||
public void setNBT(NBTTagCompound compound){
|
||||
scripts = NBTTags.GetScriptOld(compound.getTagList("Scripts", 10), this);
|
||||
scriptLanguage = compound.getString("ScriptLanguage");
|
||||
enabled = compound.getBoolean("ScriptEnabled");
|
||||
activePowering = powering = compound.getInteger("BlockPowering");
|
||||
prevPower = compound.getInteger("BlockPrevPower");
|
||||
|
||||
if(compound.hasKey("BlockHardness")){
|
||||
blockHardness = compound.getFloat("BlockHardness");
|
||||
blockResistance = compound.getFloat("BlockResistance");
|
||||
}
|
||||
|
||||
}
|
||||
public void setDisplayNBT(NBTTagCompound compound){
|
||||
itemModel = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("ScriptBlockModel"));
|
||||
if(itemModel==null || itemModel.stackSize == 0)
|
||||
itemModel = new ItemStack(Item.getItemFromBlock(CustomItems.scripted));
|
||||
if(compound.hasKey("ScriptBlockModelBlock"))
|
||||
blockModel = Block.getBlockFromName(compound.getString("ScriptBlockModelBlock"));
|
||||
renderTileUpdate = null;
|
||||
renderTile = null;
|
||||
renderTileErrored = false;
|
||||
|
||||
lightValue = compound.getInteger("LightValue");
|
||||
isLadder = compound.getBoolean("IsLadder");
|
||||
isPassible = compound.getBoolean("IsPassible");
|
||||
|
||||
rotationX = compound.getInteger("RotationX");
|
||||
rotationY = compound.getInteger("RotationY");
|
||||
rotationZ = compound.getInteger("RotationZ");
|
||||
|
||||
scaleX = compound.getFloat("ScaleX");
|
||||
scaleY = compound.getFloat("ScaleY");
|
||||
scaleZ = compound.getFloat("ScaleZ");
|
||||
|
||||
if(scaleX <= 0)
|
||||
scaleX = 1;
|
||||
if(scaleY <= 0)
|
||||
scaleY = 1;
|
||||
if(scaleZ <= 0)
|
||||
scaleZ = 1;
|
||||
|
||||
if(compound.hasKey("Text3")) {
|
||||
text1.setNBT(compound.getCompoundTag("Text1"));
|
||||
text2.setNBT(compound.getCompoundTag("Text2"));
|
||||
text3.setNBT(compound.getCompoundTag("Text3"));
|
||||
text4.setNBT(compound.getCompoundTag("Text4"));
|
||||
text5.setNBT(compound.getCompoundTag("Text5"));
|
||||
text6.setNBT(compound.getCompoundTag("Text6"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound){
|
||||
super.writeToNBT(compound);
|
||||
getNBT(compound);
|
||||
getDisplayNBT(compound);
|
||||
timers.writeToNBT(compound);
|
||||
compound.setTag("ExtraData",getTileData().getTag("CustomNPCsData"));
|
||||
}
|
||||
|
||||
public NBTTagCompound getNBT(NBTTagCompound compound){
|
||||
compound.setTag("Scripts", NBTTags.NBTScript(scripts));
|
||||
compound.setString("ScriptLanguage", scriptLanguage);
|
||||
compound.setBoolean("ScriptEnabled", enabled);
|
||||
compound.setInteger("BlockPowering", powering);
|
||||
compound.setInteger("BlockPrevPower", prevPower);
|
||||
compound.setFloat("BlockHardness", blockHardness);
|
||||
compound.setFloat("BlockResistance", blockResistance);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public void getDisplayNBT(NBTTagCompound compound){
|
||||
NBTTagCompound itemcompound = new NBTTagCompound();
|
||||
itemModel.writeToNBT(itemcompound);
|
||||
if(blockModel != null){
|
||||
compound.setString("ScriptBlockModelBlock", Block.blockRegistry.getNameForObject(blockModel));
|
||||
}
|
||||
compound.setTag("ScriptBlockModel", itemcompound);
|
||||
compound.setInteger("LightValue", lightValue);
|
||||
compound.setBoolean("IsLadder", isLadder);
|
||||
compound.setBoolean("IsPassible", isPassible);
|
||||
|
||||
compound.setInteger("RotationX", rotationX);
|
||||
compound.setInteger("RotationY", rotationY);
|
||||
compound.setInteger("RotationZ", rotationZ);
|
||||
|
||||
compound.setFloat("ScaleX", scaleX);
|
||||
compound.setFloat("ScaleY", scaleY);
|
||||
compound.setFloat("ScaleZ", scaleZ);
|
||||
|
||||
compound.setTag("Text1", text1.getNBT());
|
||||
compound.setTag("Text2", text2.getNBT());
|
||||
compound.setTag("Text3", text3.getNBT());
|
||||
compound.setTag("Text4", text4.getNBT());
|
||||
compound.setTag("Text5", text5.getNBT());
|
||||
compound.setTag("Text6", text6.getNBT());
|
||||
|
||||
}
|
||||
|
||||
private boolean isEnabled() {
|
||||
return enabled && ScriptController.HasStart && !worldObj.isRemote;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if(renderTileUpdate != null){
|
||||
try{
|
||||
renderTileUpdate.tick();
|
||||
}
|
||||
catch(Exception e){
|
||||
renderTileUpdate = null;
|
||||
}
|
||||
}
|
||||
ticksExisted++;
|
||||
if (prevPower != newPower && powering <= 0){
|
||||
EventHooks.onScriptBlockRedstonePower(this, prevPower, newPower);
|
||||
prevPower = newPower;
|
||||
}
|
||||
|
||||
timers.update();
|
||||
if(ticksExisted >= 10){
|
||||
EventHooks.onScriptBlockUpdate(this);
|
||||
ticksExisted = 0;
|
||||
if(needsClientUpdate){
|
||||
markDirty();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord,yCoord,zCoord,getBlockType(),3);
|
||||
needsClientUpdate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
handleUpdateTag(pkt.func_148857_g());
|
||||
}
|
||||
|
||||
public void handleUpdateTag(NBTTagCompound tag){
|
||||
int light = lightValue;
|
||||
setDisplayNBT(tag);
|
||||
if(light != lightValue)
|
||||
checkLight(worldObj,xCoord,yCoord,zCoord);
|
||||
}
|
||||
|
||||
public boolean checkLight(World world, int x, int y, int z)
|
||||
{
|
||||
boolean flag = false;
|
||||
|
||||
if (!world.provider.hasNoSky)
|
||||
{
|
||||
flag |= world.updateLightByType(EnumSkyBlock.Sky, x,y,z);
|
||||
}
|
||||
|
||||
flag = flag | world.updateLightByType(EnumSkyBlock.Block, x,y,z);
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
return new S35PacketUpdateTileEntity(xCoord,yCoord,zCoord, 0, getUpdateTag());
|
||||
}
|
||||
|
||||
public NBTTagCompound getUpdateTag(){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("x", xCoord);
|
||||
compound.setInteger("y", yCoord);
|
||||
compound.setInteger("z", zCoord);
|
||||
getDisplayNBT(compound);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public void setItemModel(ItemStack item, Block b) {
|
||||
if(item == null || item.stackSize==0){
|
||||
item = new ItemStack(CustomItems.scripted);
|
||||
}
|
||||
if(NoppesUtilPlayer.compareItems(item, itemModel, false, false) && b != blockModel)
|
||||
return;
|
||||
|
||||
itemModel = item;
|
||||
blockModel = b;
|
||||
needsClientUpdate = true;
|
||||
}
|
||||
|
||||
public void setLightValue(int value){
|
||||
if(value == lightValue)
|
||||
return;
|
||||
lightValue = ValueUtil.clamp(value, 0, 15);
|
||||
needsClientUpdate = true;
|
||||
}
|
||||
|
||||
public void setRedstonePower(int strength){
|
||||
if(powering == strength)
|
||||
return;
|
||||
//using activePowering to prevent the RedstonePower script event from going crazy
|
||||
prevPower = activePowering = ValueUtil.clamp(strength, 0, 15);
|
||||
worldObj.notifyBlockChange(xCoord,yCoord,zCoord, getBlockType());
|
||||
powering = activePowering;
|
||||
}
|
||||
|
||||
public void setScale(float x, float y, float z){
|
||||
if(scaleX == x && scaleY == y && scaleZ == z)
|
||||
return;
|
||||
scaleX = ValueUtil.clamp(x, 0, 10);
|
||||
scaleY = ValueUtil.clamp(y, 0, 10);
|
||||
scaleZ = ValueUtil.clamp(z, 0, 10);
|
||||
needsClientUpdate = true;
|
||||
}
|
||||
|
||||
public void setRotation(int x, int y, int z){
|
||||
if(rotationX == x && rotationY == y && rotationZ == z)
|
||||
return;
|
||||
rotationX = ValueUtil.clamp(x, 0, 359);
|
||||
rotationY = ValueUtil.clamp(y, 0, 359);
|
||||
rotationZ = ValueUtil.clamp(z, 0, 359);
|
||||
needsClientUpdate = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callScript(EnumScriptType type, Event event) {
|
||||
if(!isEnabled())
|
||||
return;
|
||||
if(ScriptController.Instance.lastLoaded > lastInited){
|
||||
lastInited = ScriptController.Instance.lastLoaded;
|
||||
if(type != EnumScriptType.INIT)
|
||||
EventHooks.onScriptBlockInit(this);
|
||||
}
|
||||
|
||||
for(ScriptContainer script : scripts){
|
||||
script.run(type, event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callScript(String hookName, Event event) {
|
||||
callScript(EnumScriptType.valueOf(hookName),event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClient() {
|
||||
return worldObj.isRemote;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean bo) {
|
||||
enabled = bo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String noticeString() {
|
||||
return "x: "+xCoord+", y: "+yCoord+", z: "+zCoord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguage() {
|
||||
return scriptLanguage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLanguage(String lang) {
|
||||
scriptLanguage = lang;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScripts(List<ScriptContainer> list) {
|
||||
scripts = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ScriptContainer> getScripts() {
|
||||
return scripts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, String> getConsoleText(){
|
||||
Map<Long, String> map = new TreeMap<>();
|
||||
int tab = 0;
|
||||
for(ScriptContainer script : getScripts()){
|
||||
tab++;
|
||||
for(Entry<Long, String> entry : script.console.entrySet()){
|
||||
map.put(entry.getKey(), " tab " + tab + ":\n" + entry.getValue());
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearConsole() {
|
||||
for(ScriptContainer script : getScripts()){
|
||||
script.console.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox(){
|
||||
return AxisAlignedBB.getBoundingBox(0.0, 0.0, 0.0, 1.0, 1.0, 1.0)
|
||||
.offset(xCoord,yCoord,zCoord);
|
||||
}
|
||||
|
||||
public NBTTagCompound getTileData()
|
||||
{
|
||||
if (this.customTileData == null)
|
||||
{
|
||||
this.customTileData = new NBTTagCompound();
|
||||
}
|
||||
return this.customTileData;
|
||||
}
|
||||
|
||||
public class TextPlane implements ITextPlane {
|
||||
public boolean textHasChanged = true;
|
||||
public TextBlock textBlock;
|
||||
|
||||
public String text = "";
|
||||
public int rotationX = 0, rotationY = 0, rotationZ = 0;
|
||||
public float offsetX = 0, offsetY = 0f, offsetZ = 0.5f;
|
||||
public float scale = 1;
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
@Override
|
||||
public void setText(String text) {
|
||||
if(this.text.equals(text))
|
||||
return;
|
||||
this.text = text;
|
||||
textHasChanged = true;
|
||||
needsClientUpdate = true;
|
||||
}
|
||||
@Override
|
||||
public int getRotationX() {
|
||||
return rotationX;
|
||||
}
|
||||
@Override
|
||||
public int getRotationY() {
|
||||
return rotationY;
|
||||
}
|
||||
@Override
|
||||
public int getRotationZ() {
|
||||
return rotationZ;
|
||||
}
|
||||
@Override
|
||||
public void setRotationX(int x) {
|
||||
x = ValueUtil.clamp(x % 360, 0, 359);
|
||||
if(rotationX == x)
|
||||
return;
|
||||
rotationX = x;
|
||||
needsClientUpdate = true;
|
||||
}
|
||||
@Override
|
||||
public void setRotationY(int y) {
|
||||
y = ValueUtil.clamp(y % 360, 0, 359);
|
||||
if(rotationY == y)
|
||||
return;
|
||||
rotationY = y;
|
||||
needsClientUpdate = true;
|
||||
}
|
||||
@Override
|
||||
public void setRotationZ(int z) {
|
||||
z = ValueUtil.clamp(z % 360, 0, 359);
|
||||
if(rotationZ == z)
|
||||
return;
|
||||
rotationZ = z;
|
||||
needsClientUpdate = true;
|
||||
}
|
||||
@Override
|
||||
public float getOffsetX() {
|
||||
return offsetX;
|
||||
}
|
||||
@Override
|
||||
public float getOffsetY() {
|
||||
return offsetY;
|
||||
}
|
||||
@Override
|
||||
public float getOffsetZ() {
|
||||
return offsetZ;
|
||||
}
|
||||
@Override
|
||||
public void setOffsetX(float x) {
|
||||
x = ValueUtil.clamp(x, -1, 1);
|
||||
if(offsetX == x)
|
||||
return;
|
||||
offsetX = x;
|
||||
needsClientUpdate = true;
|
||||
}
|
||||
@Override
|
||||
public void setOffsetY(float y) {
|
||||
y = ValueUtil.clamp(y, -1, 1);
|
||||
if(offsetY == y)
|
||||
return;
|
||||
offsetY = y;
|
||||
needsClientUpdate = true;
|
||||
}
|
||||
@Override
|
||||
public void setOffsetZ(float z) {
|
||||
z = ValueUtil.clamp(z, -1, 1);
|
||||
if(offsetZ == z)
|
||||
return;
|
||||
System.out.println(rotationZ);
|
||||
offsetZ = z;
|
||||
needsClientUpdate = true;
|
||||
}
|
||||
@Override
|
||||
public float getScale() {
|
||||
return scale;
|
||||
}
|
||||
@Override
|
||||
public void setScale(float scale) {
|
||||
if(this.scale == scale)
|
||||
return;
|
||||
this.scale = scale;
|
||||
needsClientUpdate = true;
|
||||
}
|
||||
|
||||
public NBTTagCompound getNBT() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setString("Text", text);
|
||||
compound.setInteger("RotationX", rotationX);
|
||||
compound.setInteger("RotationY", rotationY);
|
||||
compound.setInteger("RotationZ", rotationZ);
|
||||
compound.setFloat("OffsetX", offsetX);
|
||||
compound.setFloat("OffsetY", offsetY);
|
||||
compound.setFloat("OffsetZ", offsetZ);
|
||||
compound.setFloat("Scale", scale);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public void setNBT(NBTTagCompound compound) {
|
||||
setText(compound.getString("Text"));
|
||||
rotationX = compound.getInteger("RotationX");
|
||||
rotationY = compound.getInteger("RotationY");
|
||||
rotationZ = compound.getInteger("RotationZ");
|
||||
offsetX = compound.getFloat("OffsetX");
|
||||
offsetY = compound.getFloat("OffsetY");
|
||||
offsetZ = compound.getFloat("OffsetZ");
|
||||
scale = compound.getFloat("Scale");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ import noppes.npcs.client.gui.player.companion.GuiNpcCompanionTalents;
|
||||
import noppes.npcs.client.gui.questtypes.GuiNpcQuestTypeItem;
|
||||
import noppes.npcs.client.gui.GuiNpcRemoteEditor;
|
||||
import noppes.npcs.client.gui.roles.*;
|
||||
import noppes.npcs.client.gui.script.GuiScriptBlock;
|
||||
import noppes.npcs.client.gui.script.GuiScriptGlobal;
|
||||
import noppes.npcs.client.gui.script.GuiScriptItem;
|
||||
import noppes.npcs.client.model.*;
|
||||
@@ -124,6 +125,7 @@ public class ClientProxy extends CommonProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileBeam.class, new BlockBeamRenderer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileBook.class, new BlockBookRenderer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TilePedestal.class, new BlockPedestalRenderer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileScripted.class, new BlockScriptedRenderer());
|
||||
RenderingRegistry.registerBlockHandler(new BlockBloodRenderer());
|
||||
}
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
@@ -376,6 +378,9 @@ public class ClientProxy extends CommonProxy {
|
||||
else if (gui == EnumGuiType.CustomGui)
|
||||
return new GuiCustom((ContainerCustomGui)container);
|
||||
|
||||
else if (gui == EnumGuiType.ScriptBlock)
|
||||
return new GuiScriptBlock(x,y,z);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+10
-3
@@ -1,20 +1,27 @@
|
||||
package noppes.npcs.client;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import noppes.npcs.CustomItems;
|
||||
|
||||
public class QuestAchievement extends Achievement{
|
||||
public class MessageAchievement extends Achievement{
|
||||
|
||||
private String description;
|
||||
private String message;
|
||||
public QuestAchievement(String message, String description) {
|
||||
super("",message, 0, 0, CustomItems.letter==null?Items.paper:CustomItems.letter, null);
|
||||
|
||||
public MessageAchievement(Item item, String message, String description) {
|
||||
super("",message, 0, 0, item, null);
|
||||
this.description = description;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public MessageAchievement(String message, String description) {
|
||||
this(CustomItems.letter==null ? Items.paper : CustomItems.letter, message, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent func_150951_e()
|
||||
{
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.achievement.GuiAchievement;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -76,10 +77,10 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
|
||||
player.addChatMessage(new ChatComponentTranslation(message));
|
||||
}
|
||||
else if(type == EnumPacketClient.MESSAGE){
|
||||
else if(type == EnumPacketClient.MESSAGE || type == EnumPacketClient.PARTY_MESSAGE){
|
||||
String description = StatCollector.translateToLocal(Server.readString(buffer));
|
||||
String message = Server.readString(buffer);
|
||||
Achievement ach = new QuestAchievement(message, description);
|
||||
Achievement ach = type == EnumPacketClient.MESSAGE ? new MessageAchievement(message, description) : new MessageAchievement(CustomItems.bag == null ? Items.paper : CustomItems.bag, message, description);
|
||||
Minecraft.getMinecraft().guiAchievement.func_146256_a(ach);
|
||||
ObfuscationReflectionHelper.setPrivateValue(GuiAchievement.class, Minecraft.getMinecraft().guiAchievement, ach.getDescription(), 4);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,11 @@ package noppes.npcs.client.gui.player.inventory;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.Client;
|
||||
@@ -17,9 +20,11 @@ import tconstruct.client.tabs.InventoryTabCustomNpc;
|
||||
import tconstruct.client.tabs.TabRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, ITopButtonListener,ICustomScrollListener, IGuiData {
|
||||
public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, ITopButtonListener,ICustomScrollListener, IGuiData, GuiYesNoCallback {
|
||||
private final ResourceLocation resource = new ResourceLocation("customnpcs","textures/gui/standardbg.png");
|
||||
private final EntityPlayer player;
|
||||
private Minecraft mc = Minecraft.getMinecraft();
|
||||
@@ -27,6 +32,14 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
private boolean receivedData;
|
||||
private long renderTicks;
|
||||
|
||||
private String selectedPlayer;
|
||||
private String selectedInvite;
|
||||
|
||||
private boolean partyChanged = false;
|
||||
private boolean isLeader;
|
||||
|
||||
private final HashMap<String, String> invites = new HashMap<>();
|
||||
|
||||
public GuiParty(EntityPlayer player) {
|
||||
super();
|
||||
this.player = player;
|
||||
@@ -39,6 +52,7 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
this.selectedInvite = this.selectedPlayer = null;
|
||||
Party party = ClientCacheHandler.party;
|
||||
TabRegistry.addTabsToList(buttonList);
|
||||
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabCustomNpc.class);
|
||||
@@ -48,13 +62,13 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
//
|
||||
//create party button
|
||||
//
|
||||
GuiNpcButton createPartyButton = new GuiNpcButton(200, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 20, "Create Party");
|
||||
GuiNpcButton createPartyButton = new GuiNpcButton(200, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 20, "party.createParty");
|
||||
createPartyButton.width = 100;
|
||||
this.addButton(createPartyButton);
|
||||
|
||||
this.addLabel(new GuiNpcLabel(201, "You're not in a party!", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 30));
|
||||
this.addLabel(new GuiNpcLabel(202, "Either wait for an invite", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 20));
|
||||
this.addLabel(new GuiNpcLabel(203, "or create one.", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 10));
|
||||
this.addLabel(new GuiNpcLabel(201, "party.partyInfo1", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 30));
|
||||
this.addLabel(new GuiNpcLabel(202, "party.partyInfo2", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 20));
|
||||
this.addLabel(new GuiNpcLabel(203, "party.partyInfo3", guiLeft + xSize/2 + 30, guiTop + ySize/2 - 10));
|
||||
|
||||
//party invites list
|
||||
//
|
||||
@@ -62,13 +76,14 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
inviteScroll.setSize(150, 160);
|
||||
inviteScroll.guiLeft = guiLeft + 5;
|
||||
inviteScroll.guiTop = guiTop + 5;
|
||||
inviteScroll.setList(new ArrayList<>(this.invites.keySet()));
|
||||
this.addScroll(inviteScroll);
|
||||
|
||||
GuiNpcButton acceptButton = new GuiNpcButton(215, guiLeft + 15, guiTop + ySize - 12, "Accept");
|
||||
GuiNpcButton acceptButton = new GuiNpcButton(215, guiLeft + 15, guiTop + ySize - 12, "party.accept");
|
||||
acceptButton.width = 60;
|
||||
this.addButton(acceptButton);
|
||||
|
||||
GuiNpcButton ignoreButton = new GuiNpcButton(220, guiLeft + 80, guiTop + ySize - 12, "Ignore");
|
||||
GuiNpcButton ignoreButton = new GuiNpcButton(220, guiLeft + 80, guiTop + ySize - 12, "party.ignore");
|
||||
ignoreButton.width = 60;
|
||||
this.addButton(ignoreButton);
|
||||
} else {
|
||||
@@ -79,58 +94,146 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
playerScroll.setSize(150, 160);
|
||||
playerScroll.guiLeft = guiLeft + 5;
|
||||
playerScroll.guiTop = guiTop + 5;
|
||||
playerScroll.setList(new ArrayList<>(party.getPlayerNames()));
|
||||
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
Collection<String> playerNames = party.getPlayerNames();
|
||||
for (String s : playerNames) {
|
||||
if (party.getPartyLeaderName().equals(s)) {
|
||||
arrayList.add(s + " §e[" + StatCollector.translateToLocal("party.leader").toUpperCase() + "]");
|
||||
} else {
|
||||
arrayList.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
playerScroll.setList(arrayList);
|
||||
this.addScroll(playerScroll);
|
||||
|
||||
//set leader button
|
||||
//
|
||||
GuiNpcButton leaderButton = new GuiNpcButton(305, guiLeft + 5, guiTop + ySize - 12, "Make Leader");
|
||||
leaderButton.width = 70;
|
||||
this.addButton(leaderButton);
|
||||
if (this.isLeader) {
|
||||
//set leader button
|
||||
//
|
||||
GuiNpcButton leaderButton = new GuiNpcButton(305, guiLeft + 5, guiTop + ySize - 12, "party.makeLeader");
|
||||
leaderButton.width = 70;
|
||||
this.addButton(leaderButton);
|
||||
|
||||
//kick player button
|
||||
//
|
||||
GuiNpcButton kickButton = new GuiNpcButton(315, guiLeft + 85, guiTop + ySize - 12, "Kick");
|
||||
kickButton.width = 70;
|
||||
this.addButton(kickButton);
|
||||
//kick player button
|
||||
//
|
||||
GuiNpcButton kickButton = new GuiNpcButton(310, guiLeft + 85, guiTop + ySize - 12, "party.kick");
|
||||
kickButton.width = 70;
|
||||
this.addButton(kickButton);
|
||||
|
||||
//toggle friendly fire
|
||||
//
|
||||
GuiNpcButton friendlyFireButton = new GuiNpcButton(320, guiLeft + xSize/2 + 95, guiTop + ySize/2, new String[] {"On", "Off"}, 0); //party.friendlyFire() ? 0 : 1
|
||||
friendlyFireButton.width = 40;
|
||||
this.addButton(friendlyFireButton);
|
||||
//toggle friendly fire
|
||||
//
|
||||
GuiNpcButton friendlyFireButton = new GuiNpcButton(320, guiLeft + xSize / 2 + 95, guiTop + ySize / 2, new String[]{"gui.on", "gui.off"}, party.friendlyFire() ? 0 : 1);
|
||||
friendlyFireButton.width = 40;
|
||||
this.addButton(friendlyFireButton);
|
||||
|
||||
GuiNpcLabel friendlyFireLabel = new GuiNpcLabel(321, "Friendly Fire:", guiLeft + xSize/2 + 20, guiTop + ySize/2 + 5);
|
||||
this.addLabel(friendlyFireLabel);
|
||||
GuiNpcLabel friendlyFireLabel = new GuiNpcLabel(321, StatCollector.translateToLocal("party.friendlyFire") + ":", guiLeft + xSize / 2 + 20, guiTop + ySize / 2 + 5);
|
||||
this.addLabel(friendlyFireLabel);
|
||||
|
||||
//send invite button (opens subgui)
|
||||
//
|
||||
GuiNpcTextField playerTextField = new GuiNpcTextField(325, this, guiLeft + xSize/2 + 20, guiTop + ySize/2 + 40,100, 20, "");
|
||||
this.addTextField(playerTextField);
|
||||
//send invite button (opens subgui)
|
||||
//
|
||||
GuiNpcTextField playerTextField = new GuiNpcTextField(325, this, guiLeft + xSize / 2 + 20, guiTop + ySize / 2 + 40, 100, 20, "");
|
||||
this.addTextField(playerTextField);
|
||||
|
||||
GuiNpcButton inviteButton = new GuiNpcButton(330, guiLeft + xSize/2 + 125, guiTop + ySize/2 + 40, "Invite");
|
||||
inviteButton.width = 50;
|
||||
this.addButton(inviteButton);
|
||||
GuiNpcButton inviteButton = new GuiNpcButton(330, guiLeft + xSize / 2 + 125, guiTop + ySize / 2 + 40, "party.invite");
|
||||
inviteButton.width = 50;
|
||||
this.addButton(inviteButton);
|
||||
|
||||
//disband party
|
||||
//
|
||||
GuiNpcButton disbandButton = new GuiNpcButton(335, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 70, "Disband Party");
|
||||
disbandButton.width = 100;
|
||||
this.addButton(disbandButton);
|
||||
//disband party
|
||||
//
|
||||
GuiNpcButton disbandButton = new GuiNpcButton(335, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 70, "party.disbandParty");
|
||||
disbandButton.width = 100;
|
||||
this.addButton(disbandButton);
|
||||
} else {
|
||||
//leave party
|
||||
//
|
||||
GuiNpcButton leaveButton = new GuiNpcButton(335, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 70, "party.leaveParty");
|
||||
leaveButton.width = 100;
|
||||
this.addButton(leaveButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirmClicked(boolean flag, int i) {
|
||||
if (flag) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
Client.sendData(EnumPacketServer.SetPartyLeader, this.selectedPlayer);
|
||||
break;
|
||||
case 1:
|
||||
Client.sendData(EnumPacketServer.KickPlayer, this.selectedPlayer);
|
||||
break;
|
||||
case 2:
|
||||
Client.sendData(EnumPacketServer.DisbandParty);
|
||||
break;
|
||||
case 3:
|
||||
Client.sendData(EnumPacketServer.KickPlayer, this.player.getCommandSenderName());
|
||||
break;
|
||||
}
|
||||
receivedData = false;
|
||||
initGui();
|
||||
}
|
||||
displayGuiScreen(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton){
|
||||
Party party = ClientCacheHandler.party;
|
||||
|
||||
switch (guibutton.id) {
|
||||
case 200:
|
||||
Client.sendData(EnumPacketServer.CreateParty);
|
||||
receivedData = false;
|
||||
break;
|
||||
case 215:
|
||||
if (this.selectedInvite != null && !this.selectedInvite.isEmpty()) {
|
||||
Client.sendData(EnumPacketServer.AcceptInvite, this.selectedInvite);
|
||||
receivedData = false;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 220:
|
||||
if (this.selectedInvite != null && !this.selectedInvite.isEmpty()) {
|
||||
Client.sendData(EnumPacketServer.IgnoreInvite, this.selectedInvite);
|
||||
receivedData = false;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 305:
|
||||
if (this.selectedPlayer != null && !this.selectedPlayer.isEmpty() && !party.getPartyLeaderName().equals(this.selectedPlayer)) {
|
||||
GuiYesNo yesnoLeader = new GuiYesNo(this, StatCollector.translateToLocal("party.leaderConfirm"), this.selectedPlayer, 0);
|
||||
displayGuiScreen(yesnoLeader);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 310:
|
||||
if (this.selectedPlayer != null && !this.selectedPlayer.isEmpty() && !party.getPartyLeaderName().equals(this.selectedPlayer)) {
|
||||
GuiYesNo yesnoKick = new GuiYesNo(this, StatCollector.translateToLocal("party.kickConfirm"), this.selectedPlayer, 1);
|
||||
displayGuiScreen(yesnoKick);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 320:
|
||||
party.toggleFriendlyFire();
|
||||
this.partyChanged = true;
|
||||
break;
|
||||
case 330:
|
||||
String inviteName = this.getTextField(325).getText();
|
||||
if (!inviteName.isEmpty() && !party.getPlayerNames(true).contains(inviteName.toLowerCase())) {
|
||||
Client.sendData(EnumPacketServer.PartyInvite, inviteName);
|
||||
this.getTextField(325).setText("");
|
||||
}
|
||||
break;
|
||||
case 335:
|
||||
Client.sendData(EnumPacketServer.DisbandParty);
|
||||
receivedData = false;
|
||||
if (this.isLeader) {
|
||||
GuiYesNo yesnoDisband = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("party.disbandConfirm"), 2);
|
||||
displayGuiScreen(yesnoDisband);
|
||||
} else {
|
||||
GuiYesNo yesnoLeave = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("party.leaveConfirm"), 3);
|
||||
displayGuiScreen(yesnoLeave);
|
||||
}
|
||||
break;
|
||||
}
|
||||
initGui();
|
||||
@@ -190,17 +293,25 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
@Override
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
this.receivedData = true;
|
||||
ClientCacheHandler.party = null;
|
||||
|
||||
if (compound.hasKey("PartyUUID")) {
|
||||
Party party = ClientCacheHandler.party;
|
||||
UUID uuid = UUID.fromString(compound.getString("PartyUUID"));
|
||||
if (party == null || !party.getPartyUUID().equals(uuid)) {
|
||||
ClientCacheHandler.party = new Party(uuid);
|
||||
party = ClientCacheHandler.party;
|
||||
}
|
||||
ClientCacheHandler.party = new Party(uuid);
|
||||
Party party = ClientCacheHandler.party;
|
||||
party.readFromNBT(compound);
|
||||
this.isLeader = ClientCacheHandler.party.getPartyLeaderName().equals(this.player.getCommandSenderName());
|
||||
} else if (compound.hasKey("Disband")) {
|
||||
ClientCacheHandler.party = null;
|
||||
this.isLeader = false;
|
||||
} else if (compound.hasKey("PartyInvites")) {
|
||||
this.invites.clear();
|
||||
NBTTagList list = compound.getTagList("PartyInvites", 10);
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
NBTTagCompound listCompound = list.getCompoundTagAt(i);
|
||||
String inviteName = listCompound.getString("PartyLeader");
|
||||
String partyUUID = listCompound.getString("PartyUUID");
|
||||
this.invites.put(inviteName, partyUUID);
|
||||
}
|
||||
}
|
||||
|
||||
initGui();
|
||||
@@ -214,12 +325,21 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
|
||||
if (this.partyChanged) {
|
||||
Client.sendData(EnumPacketServer.SavePartyData, ClientCacheHandler.party.writeClientNBT());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
|
||||
switch (guiCustomScroll.id) {
|
||||
case 210:
|
||||
this.selectedInvite = this.invites.get(guiCustomScroll.getSelected());
|
||||
break;
|
||||
case 300:
|
||||
this.selectedPlayer = guiCustomScroll.getSelected().replace(" §e[" + StatCollector.translateToLocal("party.leader").toUpperCase() + "]", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package noppes.npcs.client.gui.script;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.blocks.tiles.TileScripted;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
public class GuiScriptBlock extends GuiScriptInterface {
|
||||
private TileScripted tileScripted;
|
||||
|
||||
public GuiScriptBlock(int x, int y, int z) {
|
||||
hookList.add("init");
|
||||
hookList.add("tick");
|
||||
hookList.add("interact");
|
||||
hookList.add("fallenUpon");
|
||||
hookList.add("redstone");
|
||||
hookList.add("broken");
|
||||
hookList.add("exploded");
|
||||
hookList.add("rainFilled");
|
||||
hookList.add("neighborChanged");
|
||||
hookList.add("clicked");
|
||||
hookList.add("harvested");
|
||||
hookList.add("collide");
|
||||
hookList.add("timer");
|
||||
|
||||
this.handler = this.tileScripted = (TileScripted) player.worldObj.getTileEntity(x, y, z);
|
||||
Client.sendData(EnumPacketServer.ScriptBlockDataGet, tileScripted.xCoord, tileScripted.yCoord, tileScripted.zCoord);
|
||||
}
|
||||
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
this.tileScripted.setNBT(compound);
|
||||
super.setGuiData(compound);
|
||||
}
|
||||
|
||||
public void save() {
|
||||
super.save();
|
||||
Client.sendData(EnumPacketServer.ScriptBlockDataSave, tileScripted.xCoord, tileScripted.yCoord, tileScripted.zCoord, this.tileScripted.getNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package noppes.npcs.client.renderer.blocks;
|
||||
|
||||
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.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.minecraftforge.client.ForgeHooksClient;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.blocks.BlockScripted;
|
||||
import noppes.npcs.blocks.tiles.TileScripted;
|
||||
import noppes.npcs.blocks.tiles.TileScripted.TextPlane;
|
||||
import noppes.npcs.client.TextBlockClient;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockScriptedRenderer extends BlockRendererInterface{
|
||||
private static final RenderBlocks renderBlocks = new RenderBlocks();
|
||||
private static final Random random = new Random();
|
||||
|
||||
@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 {
|
||||
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();
|
||||
|
||||
if (!tile.text1.text.isEmpty()) {
|
||||
drawText(tile.text1, x, y, z);
|
||||
}
|
||||
if (!tile.text2.text.isEmpty()) {
|
||||
drawText(tile.text2, x, y, z);
|
||||
}
|
||||
if (!tile.text3.text.isEmpty()) {
|
||||
drawText(tile.text3, x, y, z);
|
||||
}
|
||||
if (!tile.text4.text.isEmpty()) {
|
||||
drawText(tile.text4, x, y, z);
|
||||
}
|
||||
if (!tile.text5.text.isEmpty()) {
|
||||
drawText(tile.text5, x, y, z);
|
||||
}
|
||||
if (!tile.text6.text.isEmpty()) {
|
||||
drawText(tile.text6, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawText(TextPlane text1, double x, double y, double z) {
|
||||
if (text1.textBlock == null || text1.textHasChanged) {
|
||||
text1.textBlock = new TextBlockClient(text1.text, 336, true, Minecraft.getMinecraft().thePlayer);
|
||||
text1.textHasChanged = false;
|
||||
}
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) (x + 0.5), (float) (y + 0.5), (float) (z + 0.5));
|
||||
GL11.glRotatef(text1.rotationY, 0, 1, 0);
|
||||
GL11.glRotatef(text1.rotationX, 1, 0, 0);
|
||||
GL11.glRotatef(text1.rotationZ, 0, 0, 1);
|
||||
GL11.glScalef(text1.scale, text1.scale, 1);
|
||||
GL11.glTranslatef(text1.offsetX, text1.offsetY, text1.offsetZ);
|
||||
float f1 = 0.6666667F;
|
||||
float f3 = 0.0133F * f1;
|
||||
GL11.glTranslatef(0.0F, 0.5F, 0.01F);
|
||||
GL11.glScalef(f3, -f3, f3);
|
||||
GL11.glNormal3f(0.0F, 0.0F, -1.0F * f3);
|
||||
GL11.glDepthMask(false);
|
||||
FontRenderer fontrenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
|
||||
float lineOffset = 0;
|
||||
if (text1.textBlock.lines.size() < 14)
|
||||
lineOffset = (14f - text1.textBlock.lines.size()) / 2;
|
||||
for (int i = 0; i < text1.textBlock.lines.size(); i++) {
|
||||
String text = text1.textBlock.lines.get(i).getFormattedText();
|
||||
fontrenderer.drawString(text, -fontrenderer.getStringWidth(text) / 2, (int) ((lineOffset + i) * (fontrenderer.FONT_HEIGHT - 0.3)), 0);
|
||||
}
|
||||
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void renderItem(TileEntity tile, ItemStack stack) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (stack != null) {
|
||||
mc.renderEngine.bindTexture(stack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture);
|
||||
|
||||
GL11.glScalef(2F, 2F, 2F);
|
||||
if (!ForgeHooksClient.renderEntityItem(new EntityItem(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, stack), stack, 0F, 0F, tile.getWorldObj().rand, mc.renderEngine, renderBlocks, 1)) {
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
if (stack.getItem() instanceof ItemBlock && (RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())
|
||||
|| Block.getBlockFromItem(stack.getItem()) instanceof BlockScripted)) {
|
||||
renderBlocks.renderBlockAsItem(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F);
|
||||
} else {
|
||||
int renderPass = 0;
|
||||
do {
|
||||
IIcon icon = stack.getItem().getIcon(stack, renderPass);
|
||||
if (icon != null) {
|
||||
Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass));
|
||||
GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
|
||||
float f = icon.getMinU();
|
||||
float f1 = icon.getMaxU();
|
||||
float f2 = icon.getMinV();
|
||||
float f3 = icon.getMaxV();
|
||||
GL11.glTranslatef(-0.5F, -0.5F, 0F);
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
|
||||
GL11.glColor3f(1F, 1F, 1F);
|
||||
}
|
||||
renderPass++;
|
||||
} while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderBlock(TileScripted tile, Block b) {
|
||||
GL11.glPushMatrix();
|
||||
this.bindTexture(TextureMap.locationBlocksTexture);
|
||||
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glTranslatef(-0.5F, -0, 0.5F);
|
||||
renderBlocks.renderStandardBlock(b, tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
if (b.getTickRandomly() && random.nextInt(12) == 1)
|
||||
b.randomDisplayTick(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, random);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private boolean overrideModel() {
|
||||
ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
|
||||
if (held == null)
|
||||
return false;
|
||||
|
||||
return held.getItem() == CustomItems.wand || held.getItem() == CustomItems.scripter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -54,5 +54,6 @@ public enum EnumGuiType {
|
||||
CompanionTrader,
|
||||
ManageLinked,
|
||||
CustomGui,
|
||||
ScriptItem;
|
||||
ScriptItem,
|
||||
ScriptBlock;
|
||||
}
|
||||
@@ -4,6 +4,7 @@ noppes.npcs.constants;
|
||||
public enum EnumPacketClient {
|
||||
CHAT,
|
||||
MESSAGE,
|
||||
PARTY_MESSAGE,
|
||||
SYNCRECIPES_ADD,
|
||||
SYNCRECIPES_WORKBENCH,
|
||||
DIALOG,
|
||||
|
||||
@@ -49,6 +49,8 @@ public enum EnumPacketServer {
|
||||
|
||||
ScriptItemDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||
ScriptItemDataGet(false),
|
||||
ScriptBlockDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, false),
|
||||
ScriptBlockDataGet(false),
|
||||
|
||||
LinkedGetAll, LinkedRemove(CustomNpcsPermissions.GLOBAL_LINKED), LinkedAdd(CustomNpcsPermissions.GLOBAL_LINKED),
|
||||
ScriptDataSave(CustomNpcsPermissions.TOOL_SCRIPTER, true), ScriptDataGet(true),
|
||||
@@ -95,7 +97,7 @@ public enum EnumPacketServer {
|
||||
|
||||
CustomGuiButton,CustomGuiScrollClick,CustomGuiClose,CustomGuiUnfocused,
|
||||
|
||||
CreateParty, GetPartyData, DisbandParty,
|
||||
SavePartyData, CreateParty, GetPartyData, DisbandParty, KickPlayer, PartyInvite, GetPartyInviteList, AcceptInvite, IgnoreInvite, SetPartyLeader,
|
||||
|
||||
ServerUpdateSkinOverlays;
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import noppes.npcs.api.IBlock;
|
||||
|
||||
public interface IScriptBlockHandler extends INpcScriptHandler{
|
||||
|
||||
public IBlock getBlock();
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package noppes.npcs.controllers.data;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -27,7 +28,6 @@ public class Party {
|
||||
private final ArrayList<UUID> partyOrder = new ArrayList<>();
|
||||
|
||||
private int currentQuestID = -1;
|
||||
|
||||
private boolean friendlyFire;
|
||||
|
||||
//Client-sided
|
||||
@@ -66,29 +66,9 @@ public class Party {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removePlayer(String playerName) {
|
||||
UUID uuid = getUUID(playerName);
|
||||
if (uuid == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(partyMembers.containsKey(uuid)){
|
||||
partyMembers.remove(uuid);
|
||||
partyOrder.remove(uuid);
|
||||
|
||||
if(uuid.equals(partyLeader)){
|
||||
if(partyMembers.size() > 0){
|
||||
partyLeader = partyOrder.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removePlayer(EntityPlayer player) {
|
||||
if (player == null) return false;
|
||||
|
||||
UUID uuid = player.getUniqueID();
|
||||
if(partyMembers.containsKey(uuid)){
|
||||
partyMembers.remove(uuid);
|
||||
@@ -100,12 +80,19 @@ public class Party {
|
||||
}
|
||||
}
|
||||
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
playerData.partyUUID = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removePlayer(String playerName) {
|
||||
return playerName != null && this.removePlayer(NoppesUtilServer.getPlayerByName(playerName));
|
||||
}
|
||||
|
||||
public boolean hasPlayer(EntityPlayer player) {
|
||||
return partyMembers.containsKey(player.getUniqueID());
|
||||
}
|
||||
@@ -122,9 +109,12 @@ public class Party {
|
||||
return NoppesUtilServer.getPlayer(this.partyLeader);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getPartyLeaderName() {
|
||||
return this.partyLeaderName;
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
|
||||
return this.partyLeaderName;
|
||||
} else {
|
||||
return this.getPartyLeader().getCommandSenderName();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setLeader(EntityPlayer player){
|
||||
@@ -149,7 +139,20 @@ public class Party {
|
||||
}
|
||||
|
||||
public Collection<String> getPlayerNames() {
|
||||
return this.partyMembers.values();
|
||||
return this.getPlayerNames(false);
|
||||
}
|
||||
|
||||
public Collection<String> getPlayerNames(boolean lowercase) {
|
||||
Collection<String> names = this.partyMembers.values();
|
||||
if (!lowercase) {
|
||||
return names;
|
||||
}
|
||||
|
||||
ArrayList<String> lowerNames = new ArrayList<>();
|
||||
for (String s : names) {
|
||||
lowerNames.add(s.toLowerCase());
|
||||
}
|
||||
return lowerNames;
|
||||
}
|
||||
|
||||
public Collection<UUID> getPlayerUUIDs() {
|
||||
@@ -215,6 +218,7 @@ public class Party {
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
this.partyLeaderName = compound.getString("PartyLeader");
|
||||
this.currentQuestID = compound.getInteger("PartyQuestID");
|
||||
this.friendlyFire = compound.getBoolean("FriendlyFire");
|
||||
|
||||
NBTTagList list = compound.getTagList("PartyMembers", 10);
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
@@ -231,7 +235,8 @@ public class Party {
|
||||
|
||||
compound.setString("PartyUUID", this.partyUUID.toString());
|
||||
compound.setInteger("PartyQuestID", this.currentQuestID);
|
||||
compound.setString("PartyLeader", getPartyLeader().getCommandSenderName());
|
||||
compound.setBoolean("FriendlyFire", this.friendlyFire);
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (UUID uuid : this.partyOrder) {
|
||||
NBTTagCompound uuidCompound = new NBTTagCompound();
|
||||
@@ -241,6 +246,25 @@ public class Party {
|
||||
}
|
||||
compound.setTag("PartyMembers", list);
|
||||
|
||||
compound.setString("PartyLeader", getPartyLeader().getCommandSenderName());
|
||||
Quest quest = (Quest) QuestController.Instance.get(this.getCurrentQuestID());
|
||||
if (quest != null) {
|
||||
compound.setString("QuestName", quest.getName());
|
||||
compound.setString("QuestCategory", quest.getCategory().getName());
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
public void readClientNBT(NBTTagCompound compound) {
|
||||
this.currentQuestID = compound.getInteger("PartyQuestID");
|
||||
this.friendlyFire = compound.getBoolean("FriendlyFire");
|
||||
}
|
||||
|
||||
public NBTTagCompound writeClientNBT() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("PartyQuestID", this.currentQuestID);
|
||||
compound.setBoolean("FriendlyFire", this.friendlyFire);
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,20 @@ package noppes.npcs.controllers.data;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IExtendedEntityProperties;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.PacketHandlerServer;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.api.entity.ICustomNpc;
|
||||
import noppes.npcs.api.handler.*;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.controllers.PartyController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
@@ -24,6 +29,7 @@ import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
@@ -41,7 +47,9 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
|
||||
public EntityNPCInterface editingNpc;
|
||||
public NBTTagCompound cloned;
|
||||
|
||||
public UUID partyUUID = null;
|
||||
private final HashSet<UUID> partyInvites = new HashSet<>();
|
||||
|
||||
public EntityPlayer player;
|
||||
|
||||
@@ -55,6 +63,15 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
|
||||
public ScreenSize screenSize = new ScreenSize(-1,-1);
|
||||
|
||||
public void onLogin() {
|
||||
|
||||
}
|
||||
|
||||
public void onLogout() {
|
||||
this.partyUUID = null;
|
||||
this.partyInvites.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveNBTData(NBTTagCompound nbtTagCompound) {
|
||||
}
|
||||
@@ -128,7 +145,7 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
|
||||
@Override
|
||||
public void init(Entity entity, World world) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setGUIOpen(boolean bool) {
|
||||
@@ -180,6 +197,34 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
world.spawnEntityInWorld(npc);
|
||||
}
|
||||
|
||||
public void inviteToParty(Party party) {
|
||||
if (party != null && this.partyUUID == null && !this.partyInvites.contains(party.getPartyUUID())) {
|
||||
this.partyInvites.add(party.getPartyUUID());
|
||||
Server.sendData((EntityPlayerMP)this.player, EnumPacketClient.PARTY_MESSAGE, "party.inviteAlert", party.getPartyLeader().getCommandSenderName());
|
||||
Server.sendData((EntityPlayerMP)this.player, EnumPacketClient.CHAT, "party.inviteChat", " ", party.getPartyLeader().getCommandSenderName(), "!");
|
||||
}
|
||||
}
|
||||
|
||||
public void ignoreInvite(UUID uuid) {
|
||||
if (uuid != null) {
|
||||
this.partyInvites.remove(uuid);
|
||||
PacketHandlerServer.sendInviteData((EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
public void acceptInvite(UUID uuid) {
|
||||
if (uuid != null) {
|
||||
this.partyInvites.remove(uuid);
|
||||
Party party = PartyController.Instance().getParty(uuid);
|
||||
party.addPlayer(player);
|
||||
PacketHandlerServer.sendPartyData((EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
public HashSet<UUID> getPartyInvites() {
|
||||
return (HashSet<UUID>) this.partyInvites.clone();
|
||||
}
|
||||
|
||||
public void setCompanion(ICustomNpc npc) {
|
||||
this.setCompanion((EntityNPCInterface) npc.getMCEntity());
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.EventHooks;
|
||||
import noppes.npcs.api.ITimers;
|
||||
import noppes.npcs.blocks.tiles.TileScripted;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
@@ -186,6 +187,9 @@ public class DataTimers implements ITimers {
|
||||
else if(ob instanceof PlayerData) {
|
||||
EventHooks.onPlayerTimer((PlayerData)ob, this.id);
|
||||
}
|
||||
else if(ob instanceof TileScripted) {
|
||||
EventHooks.onScriptBlockTimer((TileScripted)ob, this.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,315 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.api.ITileEntity;
|
||||
import noppes.npcs.api.ITimers;
|
||||
import noppes.npcs.api.block.IBlockScripted;
|
||||
import noppes.npcs.api.block.ITextPlane;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.blocks.tiles.TileScripted;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted{
|
||||
private TileScripted tile;
|
||||
|
||||
public BlockScriptedWrapper(World world, Block block, int x, int y, int z) {
|
||||
super(world, block, new BlockPos(x,y,z));
|
||||
tile = (TileScripted) super.tile.getMCTileEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setModel(IItemStack item){
|
||||
if(item == null)
|
||||
tile.setItemModel(null, null);
|
||||
else
|
||||
tile.setItemModel(item.getMCItemStack(), Block.getBlockFromItem(item.getMCItemStack().getItem()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setModel(String name){
|
||||
if(name == null)
|
||||
tile.setItemModel(null, null);
|
||||
else{
|
||||
Block block = Block.getBlockFromName(name);
|
||||
if(block!=null) {
|
||||
tile.setItemModel(new ItemStack(Item.getItemFromBlock(block)), block);
|
||||
}else{
|
||||
if(Item.itemRegistry.containsKey(name)) {
|
||||
tile.setItemModel(new ItemStack((Item) Item.itemRegistry.getObject(name)), null);
|
||||
}else{
|
||||
tile.setItemModel(null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack getModel(){
|
||||
return NpcAPI.Instance().getIItemStack(tile.itemModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRedstonePower(int strength){
|
||||
tile.setRedstonePower(strength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstonePower(){
|
||||
return tile.powering;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsLadder(boolean bo){
|
||||
tile.isLadder = bo;
|
||||
tile.needsClientUpdate = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsLadder(){
|
||||
return tile.isLadder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsPassible(boolean bo){
|
||||
tile.isPassible = bo;
|
||||
tile.needsClientUpdate = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsPassible(){
|
||||
return tile.isPassible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLight(int value){
|
||||
tile.setLightValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLight(){
|
||||
return tile.lightValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScale(float x, float y, float z){
|
||||
tile.setScale(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getScaleX(){
|
||||
return tile.scaleX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getScaleY(){
|
||||
return tile.scaleY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getScaleZ(){
|
||||
return tile.scaleZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotation(int x, int y, int z){
|
||||
tile.setRotation(x % 360, y % 360, z % 360);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRotationX(){
|
||||
return tile.rotationX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRotationY(){
|
||||
return tile.rotationY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRotationZ(){
|
||||
return tile.rotationZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHardness() {
|
||||
return tile.blockHardness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHardness(float hardness) {
|
||||
tile.blockHardness = hardness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getResistance() {
|
||||
return tile.blockResistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResistance(float resistance) {
|
||||
tile.blockResistance = resistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String command){
|
||||
if(!MinecraftServer.getServer().isCommandBlockEnabled())
|
||||
throw new CustomNPCsException("Command blocks need to be enabled to executeCommands");
|
||||
NoppesUtilServer.runCommand(world.getMCWorld(), "ScriptedBlock", command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextPlane getTextPlane() {
|
||||
return tile.text1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextPlane getTextPlane2() {
|
||||
return tile.text2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextPlane getTextPlane3() {
|
||||
return tile.text3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextPlane getTextPlane4() {
|
||||
return tile.text4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextPlane getTextPlane5() {
|
||||
return tile.text5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextPlane getTextPlane6() {
|
||||
return tile.text6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITimers getTimers() {
|
||||
return tile.timers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTileEntity(ITileEntity tile){
|
||||
this.tile = (TileScripted) tile;
|
||||
super.setTileEntity(tile);
|
||||
}
|
||||
|
||||
private NBTTagCompound getNBT(){
|
||||
if(tile == null)
|
||||
return null;
|
||||
NBTTagCompound compound = tile.getTileData().getCompoundTag("CustomNPCsData");
|
||||
if(compound.hasNoTags() && !tile.getTileData().hasKey("CustomNPCsData")){
|
||||
tile.getTileData().setTag("CustomNPCsData", compound);
|
||||
}
|
||||
return compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoredData(String key, Object value) {
|
||||
NBTTagCompound compound = getNBT();
|
||||
if(compound == null)
|
||||
return;
|
||||
if(value instanceof Number)
|
||||
compound.setDouble(key, ((Number) value).doubleValue());
|
||||
else if(value instanceof String)
|
||||
compound.setString(key, (String)value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getStoredData(String key) {
|
||||
NBTTagCompound compound = getNBT();
|
||||
if(compound == null)
|
||||
return null;
|
||||
if(!compound.hasKey(key))
|
||||
return null;
|
||||
NBTBase base = compound.getTag(key);
|
||||
if(base instanceof NBTBase.NBTPrimitive)
|
||||
return ((NBTBase.NBTPrimitive)base).func_150286_g();
|
||||
return ((NBTTagString)base).func_150285_a_();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeStoredData(String key) {
|
||||
NBTTagCompound compound = getNBT();
|
||||
if(compound == null)
|
||||
return;
|
||||
compound.removeTag(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasStoredData(String key) {
|
||||
NBTTagCompound compound = getNBT();
|
||||
if(compound == null)
|
||||
return false;
|
||||
return compound.hasKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearStoredData() {
|
||||
if(tile == null)
|
||||
return;
|
||||
tile.getTileData().setTag("CustomNPCsData", new NBTTagCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getStoredDataKeys() {
|
||||
NBTTagCompound compound = getNBT();
|
||||
if(compound == null)
|
||||
return new String[0];
|
||||
return ((Set<String>)compound.func_150296_c()).toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTempData(String key) {
|
||||
if(tile == null)
|
||||
return;
|
||||
tile.tempData.remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTempData(String key, Object value) {
|
||||
if(tile == null)
|
||||
return;
|
||||
tile.tempData.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTempData(String key) {
|
||||
if(tile == null)
|
||||
return false;
|
||||
return tile.tempData.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTempData(String key) {
|
||||
if(tile == null)
|
||||
return null;
|
||||
return tile.tempData.get(key);
|
||||
}
|
||||
@Override
|
||||
public void clearTempData() {
|
||||
if(tile == null)
|
||||
return;
|
||||
tile.tempData.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTempDataKeys() {
|
||||
return tile.tempData.keySet().toArray(new String[tile.tempData.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,312 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.api.IBlock;
|
||||
import noppes.npcs.api.IPos;
|
||||
import noppes.npcs.api.entity.IEntity;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.event.IBlockEvent;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
|
||||
public class BlockEvent extends CustomNPCsEvent implements IBlockEvent {
|
||||
public IBlock block;
|
||||
public BlockEvent(IBlock block){
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlock getBlock() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* fallenUpon
|
||||
*/
|
||||
@Cancelable
|
||||
public static class EntityFallenUponEvent extends BlockEvent implements IBlockEvent.EntityFallenUponEvent{
|
||||
public final IEntity entity;
|
||||
public float distanceFallen;
|
||||
public EntityFallenUponEvent(IBlock block, Entity entity, float distance){
|
||||
super(block);
|
||||
this.distanceFallen = distance;
|
||||
this.entity = NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEntity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDistanceFallen() {
|
||||
return distanceFallen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.FALLEN_UPON.function;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* interact
|
||||
*/
|
||||
@Cancelable
|
||||
public static class InteractEvent extends BlockEvent implements IBlockEvent.InteractEvent{
|
||||
public final IPlayer player;
|
||||
|
||||
public final float hitX, hitY, hitZ;
|
||||
|
||||
public final int side;
|
||||
|
||||
public InteractEvent(IBlock block, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
super(block);
|
||||
this.player = (IPlayer) NpcAPI.Instance().getIEntity(player);
|
||||
|
||||
this.hitX = hitX;
|
||||
this.hitY = hitY;
|
||||
this.hitZ = hitZ;
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHitX() {
|
||||
return hitX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHitY() {
|
||||
return hitY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHitZ() {
|
||||
return hitZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSide() {
|
||||
return side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.INTERACT.function;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* redstone
|
||||
*/
|
||||
public static class RedstoneEvent extends BlockEvent implements IBlockEvent.RedstoneEvent{
|
||||
public final int prevPower, power;
|
||||
public RedstoneEvent(IBlock block, int prevPower, int power) {
|
||||
super(block);
|
||||
this.power = power;
|
||||
this.prevPower = prevPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrevPower() {
|
||||
return prevPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPower() {
|
||||
return power;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.REDSTONE.function;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* broken
|
||||
*/
|
||||
public static class BreakEvent extends BlockEvent implements IBlockEvent.BreakEvent{
|
||||
public BreakEvent(IBlock block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.BROKEN.function;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* exploded
|
||||
*/
|
||||
@Cancelable
|
||||
public static class ExplodedEvent extends BlockEvent implements IBlockEvent.ExplodedEvent{
|
||||
public ExplodedEvent(IBlock block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.EXPLODED.function;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* rainFilled
|
||||
*/
|
||||
public static class RainFillEvent extends BlockEvent implements IBlockEvent.RainFillEvent{
|
||||
public RainFillEvent(IBlock block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.RAIN_FILLED.function;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* neighborChanged
|
||||
*/
|
||||
public static class NeighborChangedEvent extends BlockEvent implements IBlockEvent.NeighborChangedEvent{
|
||||
public final IPos changedPos;
|
||||
public NeighborChangedEvent(IBlock block, IPos changedPos) {
|
||||
super(block);
|
||||
this.changedPos = changedPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPos getChangedPos() {
|
||||
return changedPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.NEIGHBOR_CHANGED.function;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* init
|
||||
*/
|
||||
public static class InitEvent extends BlockEvent implements IBlockEvent.InitEvent{
|
||||
public InitEvent(IBlock block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.INIT.function;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* tick
|
||||
*/
|
||||
public static class UpdateEvent extends BlockEvent implements IBlockEvent.UpdateEvent{
|
||||
public UpdateEvent(IBlock block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.TICK.function;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* clicked
|
||||
*/
|
||||
public static class ClickedEvent extends BlockEvent implements IBlockEvent.ClickedEvent{
|
||||
public final IPlayer player;
|
||||
public ClickedEvent(IBlock block, EntityPlayer player) {
|
||||
super(block);
|
||||
this.player = (IPlayer) NpcAPI.Instance().getIEntity(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.CLICKED.function;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* harvested
|
||||
*/
|
||||
@Cancelable
|
||||
public static class HarvestedEvent extends BlockEvent implements IBlockEvent.HarvestedEvent{
|
||||
public final IPlayer player;
|
||||
public HarvestedEvent(IBlock block, EntityPlayer player) {
|
||||
super(block);
|
||||
this.player = (IPlayer) NpcAPI.Instance().getIEntity(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.HARVESTED.function;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* collide
|
||||
*/
|
||||
public static class CollidedEvent extends BlockEvent implements IBlockEvent.CollidedEvent{
|
||||
public final IEntity entity;
|
||||
public CollidedEvent(IBlock block, Entity entity) {
|
||||
super(block);
|
||||
this.entity = NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEntity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.COLLIDE.function;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* timer
|
||||
*/
|
||||
public static class TimerEvent extends BlockEvent implements IBlockEvent.TimerEvent{
|
||||
public final int id;
|
||||
|
||||
public TimerEvent(IBlock block, int id) {
|
||||
super(block);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return EnumScriptType.TIMER.function;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user