Skip to content

Commit

Permalink
update to 1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
dries007 committed Dec 31, 2016
1 parent bcd568d commit 143e461
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 36 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Expand Up @@ -51,9 +51,9 @@ targetCompatibility = 1.7
sourceCompatibility = 1.7

minecraft {
version = "1.10.2-12.18.2.2099"
version = "1.11-13.19.1.2189"
runDir = "run"
mappings = "snapshot_20161013"
mappings = "snapshot_20161230"
}

repositories {
Expand Down
Expand Up @@ -80,7 +80,7 @@ public void onRenderGameOverlayText(RenderGameOverlayEvent.Text event)
if (mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == BLOCK && mc.objectMouseOver.getBlockPos() != null)
{
BlockPos blockpos = mc.objectMouseOver.getBlockPos();
TileEntity te = mc.theWorld.getTileEntity(blockpos);
TileEntity te = mc.world.getTileEntity(blockpos);

if (!(te instanceof ILockableContainer)) return;

Expand All @@ -102,7 +102,7 @@ public void onRenderGameOverlayText(RenderGameOverlayEvent.Text event)
return;
}
right.add(GOLD + "Locked");
right.add(reply.pub ? GOLD + "Public" : (reply.value.contains(mc.thePlayer.getName()) ? GREEN + "You have access!" : RED + "You do not have access."));
right.add(reply.pub ? GOLD + "Public" : (reply.value.contains(mc.player.getName()) ? GREEN + "You have access!" : RED + "You do not have access."));
right.add("List of people with access:");
right.addAll(reply.value);
}
Expand All @@ -113,13 +113,13 @@ public void onRenderGameOverlayText(RenderGameOverlayEvent.Text event)
public void onTickClientTick(TickEvent.ClientTickEvent event)
{
Minecraft mc = Minecraft.getMinecraft();
if (mc.theWorld == null) return;
if (mc.world == null) return;
if (event.phase != TickEvent.Phase.START) return;
if (!mc.gameSettings.showDebugInfo) return;
if (mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == BLOCK && mc.objectMouseOver.getBlockPos() != null)
{
BlockPos blockpos = mc.objectMouseOver.getBlockPos();
TileEntity te = mc.theWorld.getTileEntity(blockpos);
TileEntity te = mc.world.getTileEntity(blockpos);
if (!(te instanceof ILockableContainer)) return;
if (LOCK_CACHE.getIfPresent(blockpos) == null) InventoryLock.getSnw().sendToServer(new Request(blockpos));
}
Expand Down
Expand Up @@ -59,13 +59,13 @@
public class InventoryLockCommand extends CommandBase
{
@Override
public String getCommandName()
public String getName()
{
return MOD_ID;
}

@Override
public List<String> getCommandAliases()
public List<String> getAliases()
{
return ImmutableList.of("invlock");
}
Expand All @@ -77,7 +77,7 @@ public boolean checkPermission(MinecraftServer server, ICommandSender sender)
}

@Override
public String getCommandUsage(ICommandSender sender)
public String getUsage(ICommandSender sender)
{
return "Use '/invlock help' for more info.";
}
Expand Down Expand Up @@ -117,7 +117,7 @@ else if (args[0].equalsIgnoreCase("public"))
else if (args[0].equalsIgnoreCase("remove")) doRemove(server, player, args);
else if (args[0].equalsIgnoreCase("bypass"))
{
if (!sender.canCommandSenderUseCommand(1, getCommandName())) throw new CommandException("Permission denied.");
if (!sender.canUseCommand(1, getName())) throw new CommandException("Permission denied.");
NBTTagCompound persist = player.getEntityData().getCompoundTag(PERSISTED_NBT_TAG);
persist.setBoolean(Constants.BYPASS_KEY, !persist.getBoolean(BYPASS_KEY));
player.getEntityData().setTag(PERSISTED_NBT_TAG, persist);
Expand All @@ -127,17 +127,17 @@ else if (args[0].equalsIgnoreCase("bypass"))
}

@Override
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
if (args.length == 1) return getListOfStringsMatchingLastWord(args, "help", "list", "lock", "unlock", "clone", "inspect", "public", "add", "remove", "bypass");
if (args.length > 1 && (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove"))) return getListOfStringsMatchingLastWord(args, server.getAllUsernames());
return super.getTabCompletionOptions(server, sender, args, pos);
if (args.length > 1 && (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove"))) return getListOfStringsMatchingLastWord(args, server.getOnlinePlayerNames());
return super.getTabCompletions(server, sender, args, pos);
}

private void displayHelp(EntityPlayerMP sender) throws CommandException
{
for (String s : new String[]{
AQUA + getCommandName() + " sub command help:",
AQUA + getName() + " sub command help:",
GREEN + "ProTip: Use TAB to auto complete a command or username!",
"- help: Display this text.",
"- list: List what items can become wands.",
Expand All @@ -152,7 +152,7 @@ private void displayHelp(EntityPlayerMP sender) throws CommandException
AQUA + "If you are NOT holding an existing Add or Remove wand:",
"- add [name or UUID] ... : Create a 'Add wand'.",
"- remove [name or UUID] ... : Create a 'Remove wand'.",
}) sender.addChatMessage(new TextComponentString(s));
}) sender.sendMessage(new TextComponentString(s));
}

private void listKeys(EntityPlayerMP player)
Expand All @@ -164,7 +164,7 @@ private void listKeys(EntityPlayerMP player)
return;
}
Helper.chat(player, "List of wand-able items:", AQUA);
for (String item : list) player.addChatMessage(new TextComponentString(item));
for (String item : list) player.sendMessage(new TextComponentString(item));
}

private void doAdd(MinecraftServer server, EntityPlayerMP player, String[] args) throws CommandException
Expand Down
Expand Up @@ -70,7 +70,7 @@ public void onBlockBreak(BlockEvent.BreakEvent event)
if (protection == 0) return;
final EntityPlayer player = event.getPlayer();
//noinspection ConstantConditions
if (player.worldObj.isRemote || protection == 1 && (player == null || player instanceof FakePlayer || player.getGameProfile() == null || player.getUniqueID() == null)) return;
if (player.world.isRemote || protection == 1 && (player == null || player instanceof FakePlayer || player.getGameProfile() == null || player.getUniqueID() == null)) return;
TileEntity te = event.getWorld().getTileEntity(event.getPos());
if (!(te instanceof ILockableContainer)) return;
LockCode lc = ((ILockableContainer) te).getLockCode();
Expand All @@ -85,11 +85,10 @@ public void onBlockBreak(BlockEvent.BreakEvent event)
public void onPlayerInteractRightClickBlock(PlayerInteractEvent.RightClickBlock event)
{
EntityPlayer player = event.getEntityPlayer();
if (player == null || player instanceof FakePlayer || player.worldObj.isRemote) return;
if (player == null || player instanceof FakePlayer || player.world.isRemote) return;
ItemStack stack = event.getItemStack();
if (stack == null) return;
NBTTagCompound nbt = stack.getSubCompound(MOD_ID, false);
//noinspection ConstantConditions
if (stack.isEmpty()) return;
NBTTagCompound nbt = stack.getSubCompound(MOD_ID);
if (nbt == null) return;

event.setCanceled(true);
Expand Down
Expand Up @@ -70,7 +70,7 @@ public boolean contains(EntityPlayer player)

public boolean canEdit(EntityPlayer player)
{
if (player.getEntityData().getCompoundTag(PERSISTED_NBT_TAG).getBoolean(BYPASS_KEY) && player.canCommandSenderUseCommand(1, MOD_ID))
if (player.getEntityData().getCompoundTag(PERSISTED_NBT_TAG).getBoolean(BYPASS_KEY) && player.canUseCommand(1, MOD_ID))
{
if (!list.contains(player.getUniqueID())) Helper.chat(player, "OP Bypass", GRAY);
return true;
Expand Down
Expand Up @@ -39,11 +39,11 @@ private Helper() {}

public static void chat(ICommandSender target, String message, TextFormatting color)
{
target.addChatMessage(new TextComponentString(message).setStyle(new Style().setColor(color)));
target.sendMessage(new TextComponentString(message).setStyle(new Style().setColor(color)));
}

public static void chat(ICommandSender target, String message, HoverEvent.Action hoverAction, String hoverExtra)
{
target.addChatMessage(new TextComponentString(message).setStyle(new Style().setHoverEvent(new HoverEvent(hoverAction, new TextComponentString(hoverExtra)))));
target.sendMessage(new TextComponentString(message).setStyle(new Style().setHoverEvent(new HoverEvent(hoverAction, new TextComponentString(hoverExtra)))));
}
}
23 changes: 11 additions & 12 deletions src/main/java/net/doubledoordev/inventorylock/util/Wand.java
Expand Up @@ -28,6 +28,7 @@
import com.mojang.authlib.GameProfile;
import net.doubledoordev.inventorylock.InventoryLock;
import net.minecraft.command.CommandException;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
Expand Down Expand Up @@ -61,7 +62,7 @@ public Wand(ItemStack stack)
public static Wand from(EntityPlayerMP player, EnumHand hand) throws CommandException
{
ItemStack stack = player.getHeldItem(hand);
if (stack == null) throw new CommandException("You need to be holding an item in your " + hand.name().replace('_', ' ').toLowerCase());
if (stack.isEmpty()) throw new CommandException("You need to be holding an item in your " + hand.name().replace('_', ' ').toLowerCase());
List<String> list = InventoryLock.getKeyItems();
if (!list.isEmpty() && !list.contains(stack.getItem().getRegistryName().toString())) throw new CommandException("This item can't be a key.");
return new Wand(stack);
Expand All @@ -76,21 +77,19 @@ public Wand setDisplayName(String name)

public Action getAction()
{
NBTTagCompound tag = stack.getSubCompound(MOD_ID, false);
//noinspection ConstantConditions
NBTTagCompound tag = stack.getSubCompound(MOD_ID);
if (tag == null) return Action.NONE;
return Action.values()[(int) tag.getByte(ACTION)];
}

public Wand setAction(Action action)
{
NBTTagCompound tag = stack.getSubCompound(MOD_ID, true);
NBTTagCompound tag = stack.getOrCreateSubCompound(MOD_ID);
tag.setByte(ACTION, (byte) action.ordinal());
if (!action.hasUUIDs)
{
tag.removeTag(UUIDS);
NBTTagCompound displayTag = stack.getSubCompound(DISPLAY, false);
//noinspection ConstantConditions
NBTTagCompound displayTag = stack.getSubCompound(DISPLAY);
if (displayTag != null) displayTag.removeTag(LORE);
}
return this;
Expand All @@ -99,16 +98,16 @@ public Wand setAction(Action action)
public void clone(EntityPlayerMP player, EnumHand hand) throws CommandException
{
ItemStack stack = player.getHeldItem(hand);
if (stack == null) throw new CommandException("You need to be holding an item in your " + hand.name().replace('_', ' ').toLowerCase());
if (stack.isEmpty()) throw new CommandException("You need to be holding an item in your " + hand.name().replace('_', ' ').toLowerCase());
if (this.getAction() == Action.NONE) throw new CommandException("The item you are holding is not a wand.");
stack.setTagInfo(MOD_ID, this.stack.getSubCompound(MOD_ID, true));
stack.setTagInfo(DISPLAY, this.stack.getSubCompound(DISPLAY, true));
stack.setTagInfo(MOD_ID, this.stack.getOrCreateSubCompound(MOD_ID));
stack.setTagInfo(DISPLAY, this.stack.getOrCreateSubCompound(DISPLAY));
}

public Map<UUID, String> getUUIDs()
{
Map<UUID, String> map = new LinkedHashMap<UUID, String>();
NBTTagCompound tag = stack.getSubCompound(MOD_ID, true);
NBTTagCompound tag = stack.getOrCreateSubCompound(MOD_ID);
NBTTagList list = tag.getTagList(UUIDS, TAG_STRING);
PlayerProfileCache ppc = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache();
for (int i = 0; i < list.tagCount(); i++)
Expand All @@ -130,8 +129,8 @@ public void setUUIDs(Map<UUID, String> map)
uuidList.appendTag(new NBTTagString(uuid.toString()));
nameList.appendTag(new NBTTagString(TextFormatting.RESET + map.get(uuid) + ' ' + uuid));
}
NBTTagCompound tag = stack.getSubCompound(MOD_ID, true);
NBTTagCompound tag = stack.getOrCreateSubCompound(MOD_ID);
tag.setTag(UUIDS, uuidList);
stack.getSubCompound(DISPLAY, true).setTag(LORE, nameList);
stack.getOrCreateSubCompound(DISPLAY).setTag(LORE, nameList);
}
}

0 comments on commit 143e461

Please sign in to comment.