When a player blacklists an object by setting its emc value to 0, also update other players that the item is now blacklisted

This commit is contained in:
Pahimar 2016-05-25 10:20:04 -04:00
parent e9f834555f
commit 747f67f16f
5 changed files with 12 additions and 3 deletions

View file

@ -6,6 +6,7 @@ import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy;
import com.pahimar.ee3.exchange.EnergyValueRegistry;
import com.pahimar.ee3.exchange.WrappedStack;
import com.pahimar.ee3.network.PacketHandler;
import com.pahimar.ee3.network.message.MessageSetBlacklistEntry;
import com.pahimar.ee3.network.message.MessageSetEnergyValue;
import com.pahimar.ee3.reference.Messages;
import com.pahimar.ee3.reference.Names;
@ -114,7 +115,8 @@ public class CommandSetEnergyValue extends CommandBase
BlacklistRegistryProxy.setAsNotLearnable(wrappedStack);
BlacklistRegistryProxy.setAsNotExchangeable(wrappedStack);
// TODO Remove energy value from EnergyValueRegistry
// TODO Sync change with client
PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE));
PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE));
func_152373_a(commandSender, this, "%s set %s as not learnable and not exchangeable", new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()});
}
}

View file

@ -6,6 +6,7 @@ import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy;
import com.pahimar.ee3.exchange.EnergyValueRegistry;
import com.pahimar.ee3.exchange.WrappedStack;
import com.pahimar.ee3.network.PacketHandler;
import com.pahimar.ee3.network.message.MessageSetBlacklistEntry;
import com.pahimar.ee3.network.message.MessageSetEnergyValue;
import com.pahimar.ee3.reference.Messages;
import com.pahimar.ee3.reference.Names;
@ -84,6 +85,8 @@ public class CommandSetEnergyValueCurrentItem extends CommandBase
BlacklistRegistryProxy.setAsNotExchangeable(wrappedStack);
// TODO Remove energy value from EnergyValueRegistry
// TODO Sync change with client
PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE));
PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE));
func_152373_a(commandSender, this, "%s set %s as not learnable and not exchangeable", new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()});
}
}

View file

@ -79,7 +79,7 @@ public class CommandSetItemNotLearnable extends CommandBase
}
BlacklistRegistryProxy.addToBlacklist(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE);
PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE, true));
PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE));
func_152373_a(commandSender, this, Messages.Commands.SET_ITEM_NOT_LEARNABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()});
}
}

View file

@ -79,7 +79,7 @@ public class CommandSetItemNotRecoverable extends CommandBase
}
BlacklistRegistryProxy.addToBlacklist(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE);
PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE, true));
PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE));
func_152373_a(commandSender, this, Messages.Commands.SET_ITEM_NOT_RECOVERABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()});
}
}

View file

@ -23,6 +23,10 @@ public class MessageSetBlacklistEntry implements IMessage, IMessageHandler<Messa
public MessageSetBlacklistEntry() {
}
public MessageSetBlacklistEntry(Object object, Blacklist blacklist) {
this(object, blacklist, true);
}
public MessageSetBlacklistEntry(Object object, Blacklist blacklist, boolean isBlacklistAction) {
if (WrappedStack.canBeWrapped(object)) {