mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-24 18:44:26 +00:00
Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f67c3328a | ||
|
|
db751c462c | ||
|
|
7e06be509d | ||
|
|
3448957d04 | ||
|
|
985e03c227 | ||
|
|
2dd41fb9d5 | ||
|
|
0736ac27d4 | ||
|
|
fc9b386ea7 | ||
|
|
7f7d54403c | ||
|
|
9b3c1aaa44 | ||
|
|
3216926681 | ||
|
|
1a7d9187e5 |
No files matched your search
+1
-1
Submodule src/api updated: f91e17ab3e...04fd348d13.
@@ -13,10 +13,20 @@ import kamkeel.npcs.util.ByteBufUtils;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import noppes.npcs.CustomNpcsPermissions;
|
||||||
|
import noppes.npcs.LogWriter;
|
||||||
import noppes.npcs.NoppesUtilServer;
|
import noppes.npcs.NoppesUtilServer;
|
||||||
|
import noppes.npcs.blocks.tiles.ITilePermission;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience packet for saving extra data about Tile Entities. <br>
|
||||||
|
* <br>
|
||||||
|
* <b>Any tile entity that uses this packet should implement {@link ITilePermission}</b> <br>
|
||||||
|
* Not implementing results in the packet treated as malformed and rejected.
|
||||||
|
*/
|
||||||
public final class TileEntitySavePacket extends AbstractPacket {
|
public final class TileEntitySavePacket extends AbstractPacket {
|
||||||
public static final String packetName = "Request|TileEntitySave";
|
public static final String packetName = "Request|TileEntitySave";
|
||||||
|
|
||||||
@@ -50,9 +60,40 @@ public final class TileEntitySavePacket extends AbstractPacket {
|
|||||||
if (!(player instanceof EntityPlayerMP))
|
if (!(player instanceof EntityPlayerMP))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
NBTTagCompound incomingCompound = ByteBufUtils.readNBT(in);
|
||||||
|
|
||||||
|
if (!isCorrectPermission(incomingCompound, player))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK))
|
if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NoppesUtilServer.saveTileEntity((EntityPlayerMP) player, ByteBufUtils.readNBT(in));
|
NoppesUtilServer.saveTileEntity((EntityPlayerMP) player, incomingCompound);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isCorrectPermission(NBTTagCompound incomingCompound, EntityPlayer player) {
|
||||||
|
int x = incomingCompound.getInteger("x");
|
||||||
|
int y = incomingCompound.getInteger("y");
|
||||||
|
int z = incomingCompound.getInteger("z");
|
||||||
|
String id = incomingCompound.getString("id");
|
||||||
|
|
||||||
|
TileEntity tile = player.worldObj.getTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if (tile == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!ITilePermission.doesIDMatch(tile.getClass(), id))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
boolean validatesPacket = tile instanceof ITilePermission;
|
||||||
|
if (!validatesPacket) {
|
||||||
|
LogWriter.error(String.format("%s tried to use TileEntitySavePacket on %s -- should this class implement ITileValidityChecker??", player.getCommandSenderName(), tile));
|
||||||
|
return false; // Assume packet is not meant for this entity from the get-go as there is no checking process.
|
||||||
|
}
|
||||||
|
|
||||||
|
ITilePermission validityChecker = (ITilePermission) tile;
|
||||||
|
CustomNpcsPermissions.Permission perm = validityChecker.getPermission();
|
||||||
|
|
||||||
|
return CustomNpcsPermissions.hasPermission(player, perm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package noppes.npcs.blocks.tiles;
|
||||||
|
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import noppes.npcs.CustomNpcsPermissions;
|
||||||
|
|
||||||
|
public interface ITilePermission {
|
||||||
|
|
||||||
|
CustomNpcsPermissions.Permission getPermission();
|
||||||
|
|
||||||
|
static boolean doesIDMatch(Class<? extends TileEntity> tileClass, String givenID) {
|
||||||
|
if (givenID == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Object entry = TileEntity.classToNameMap.get(tileClass);
|
||||||
|
return givenID.equals(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,11 +12,12 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.util.ChatComponentTranslation;
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
|
import noppes.npcs.CustomNpcsPermissions;
|
||||||
import noppes.npcs.controllers.data.Availability;
|
import noppes.npcs.controllers.data.Availability;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileBorder extends TileEntity implements IEntitySelector {
|
public class TileBorder extends TileEntity implements IEntitySelector, ITilePermission {
|
||||||
public Availability availability = new Availability();
|
public Availability availability = new Availability();
|
||||||
public AxisAlignedBB boundingbox;
|
public AxisAlignedBB boundingbox;
|
||||||
public int rotation = 0;
|
public int rotation = 0;
|
||||||
@@ -109,4 +110,9 @@ public class TileBorder extends TileEntity implements IEntitySelector {
|
|||||||
public boolean isEntityApplicable(Entity var1) {
|
public boolean isEntityApplicable(Entity var1) {
|
||||||
return var1 instanceof EntityPlayerMP || var1 instanceof EntityEnderPearl;
|
return var1 instanceof EntityPlayerMP || var1 instanceof EntityEnderPearl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomNpcsPermissions.Permission getPermission() {
|
||||||
|
return CustomNpcsPermissions.EDIT_BLOCKS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,12 +6,13 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import noppes.npcs.CustomNpcs;
|
import noppes.npcs.CustomNpcs;
|
||||||
|
import noppes.npcs.CustomNpcsPermissions;
|
||||||
import noppes.npcs.blocks.BlockNpcRedstone;
|
import noppes.npcs.blocks.BlockNpcRedstone;
|
||||||
import noppes.npcs.controllers.data.Availability;
|
import noppes.npcs.controllers.data.Availability;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileRedstoneBlock extends TileEntity {
|
public class TileRedstoneBlock extends TileEntity implements ITilePermission {
|
||||||
public int onRange = 6;
|
public int onRange = 6;
|
||||||
public int offRange = 10;
|
public int offRange = 10;
|
||||||
|
|
||||||
@@ -138,4 +139,9 @@ public class TileRedstoneBlock extends TileEntity {
|
|||||||
public boolean canUpdate() {
|
public boolean canUpdate() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomNpcsPermissions.Permission getPermission() {
|
||||||
|
return CustomNpcsPermissions.EDIT_REDSTONE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.util.ChatComponentTranslation;
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
|
import noppes.npcs.CustomNpcsPermissions;
|
||||||
import noppes.npcs.constants.EnumQuestType;
|
import noppes.npcs.constants.EnumQuestType;
|
||||||
import noppes.npcs.controllers.PartyController;
|
import noppes.npcs.controllers.PartyController;
|
||||||
import noppes.npcs.controllers.data.Party;
|
import noppes.npcs.controllers.data.Party;
|
||||||
@@ -18,7 +19,7 @@ import noppes.npcs.quests.QuestLocation;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileWaypoint extends TileEntity {
|
public class TileWaypoint extends TileEntity implements ITilePermission {
|
||||||
|
|
||||||
public String name = "";
|
public String name = "";
|
||||||
|
|
||||||
@@ -102,4 +103,9 @@ public class TileWaypoint extends TileEntity {
|
|||||||
compound.setString("LocationName", name);
|
compound.setString("LocationName", name);
|
||||||
compound.setInteger("LocationRange", range);
|
compound.setInteger("LocationRange", range);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomNpcsPermissions.Permission getPermission() {
|
||||||
|
return CustomNpcsPermissions.EDIT_WAYPOINT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -26,3 +26,7 @@ public net.minecraft.client.Minecraft field_147126_aw # mcMusicTicker
|
|||||||
public net.minecraft.client.audio.MusicTicker field_147676_d # timeUntilNextMusic
|
public net.minecraft.client.audio.MusicTicker field_147676_d # timeUntilNextMusic
|
||||||
#GuiScreen
|
#GuiScreen
|
||||||
public net.minecraft.client.gui.GuiScreen field_146290_a # selectedButton
|
public net.minecraft.client.gui.GuiScreen field_146290_a # selectedButton
|
||||||
|
|
||||||
|
|
||||||
|
# TileEntity
|
||||||
|
public net.minecraft.tileentity.TileEntity field_145853_j
|
||||||
Reference in new issue
Block a user