mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 16:59:43 +00:00
Make sure ID matches up
This commit is contained in:
1 parent
db751c462c
commit
3f67c3328a
3 files changed
+18
No files matched your search
@@ -75,11 +75,16 @@ public final class TileEntitySavePacket extends AbstractPacket {
|
||||
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));
|
||||
|
||||
@@ -1,8 +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);
|
||||
}
|
||||
}
|
||||
@@ -26,3 +26,7 @@ public net.minecraft.client.Minecraft field_147126_aw # mcMusicTicker
|
||||
public net.minecraft.client.audio.MusicTicker field_147676_d # timeUntilNextMusic
|
||||
#GuiScreen
|
||||
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