Skip to content

Commit

Permalink
Now works on SSP, also fixed #5 (I was dumb), also fixed rendering mu…
Browse files Browse the repository at this point in the history
…ltiple items instead of one.
  • Loading branch information
dries007 committed Feb 9, 2016
1 parent e6383bf commit 12001cd
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRe
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
ItemStack unpacked = ItemBlacklisted.unpack(item);
if (type == EQUIPPED || type == EQUIPPED_FIRST_PERSON || type == INVENTORY) unpacked.stackSize = 1;
IItemRenderer renderer = MinecraftForgeClient.getItemRenderer(unpacked, type);
if (renderer != null)
{
renderItem(type, unpacked, data);
renderer.renderItem(type, unpacked, data);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.google.gson.*;
import cpw.mods.fml.common.registry.GameRegistry;
import net.doubledoordev.itemblacklist.ItemBlacklist;
import net.doubledoordev.itemblacklist.util.ItemBlacklisted;
import net.minecraft.item.Item;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import net.minecraft.util.IChatComponent;
import net.minecraftforge.oredict.OreDictionary;

import java.util.*;
import java.util.HashSet;
import java.util.List;

import static net.minecraft.util.EnumChatFormatting.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.event.entity.item.ItemTossEvent;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
Expand All @@ -27,20 +28,47 @@ private ServerEventHandlers()

}

@SubscribeEvent(priority = EventPriority.HIGHEST)
public void multiPlaceEvent(BlockEvent.MultiPlaceEvent event)
{
EntityPlayer player = event.player;
if (player == null || event.itemInHand == null) return;
if (!Helper.shouldCare(event.player)) return;
if (GlobalBanList.isBanned(player.dimension, event.itemInHand))
{
player.addChatComponentMessage(new ChatComponentText(ItemBlacklist.message));
if (ItemBlacklist.log) ItemBlacklist.logger.info("{} tried to use {} at {};{};{} (Place Block. Banned Item in hand)", player.getCommandSenderName(), player.getHeldItem().getDisplayName(), event.x, event.y, event.z);
event.setCanceled(true);
GlobalBanList.process(player.dimension, player.inventory);
}
else
{
for (BlockSnapshot blockSnapshot : event.getReplacedBlockSnapshots())
{
if (!GlobalBanList.isBanned(player.dimension, new ItemStack(blockSnapshot.getCurrentBlock(), 1, blockSnapshot.world.getBlockMetadata(event.x, event.y, event.z)))) continue;
player.addChatComponentMessage(new ChatComponentText(ItemBlacklist.message));
if (ItemBlacklist.log) ItemBlacklist.logger.info("{} tried to use {} at {};{};{} (Place Block. Banned Item placed.)", player.getCommandSenderName(), player.getHeldItem().getDisplayName(), event.x, event.y, event.z);
event.setCanceled(true);
GlobalBanList.process(player.dimension, player.inventory);
break;
}
}
}

@SubscribeEvent(priority = EventPriority.HIGHEST)
public void blockPlaceEvent(BlockEvent.PlaceEvent event)
{
EntityPlayer player = event.player;
if (player == null || event.itemInHand == null) return;
if (!Helper.shouldCare(event.player)) return;
if (GlobalBanList.isBanned(player.dimension, player.getHeldItem()))
if (GlobalBanList.isBanned(player.dimension, event.itemInHand))
{
player.addChatComponentMessage(new ChatComponentText(ItemBlacklist.message));
if (ItemBlacklist.log) ItemBlacklist.logger.info("{} tried to use {} at {};{};{} (Place Block. Banned Item in hand)", player.getCommandSenderName(), player.getHeldItem().getDisplayName(), event.x, event.y, event.z);
event.setCanceled(true);
GlobalBanList.process(player.dimension, player.inventory);
}
else if (GlobalBanList.isBanned(player.dimension, new ItemStack(event.placedBlock, event.blockSnapshot.meta)))
else if (GlobalBanList.isBanned(player.dimension, new ItemStack(event.blockSnapshot.getCurrentBlock(), 1, event.blockSnapshot.world.getBlockMetadata(event.x, event.y, event.z))))
{
player.addChatComponentMessage(new ChatComponentText(ItemBlacklist.message));
if (ItemBlacklist.log) ItemBlacklist.logger.info("{} tried to use {} at {};{};{} (Place Block. Banned Item placed.)", player.getCommandSenderName(), player.getHeldItem().getDisplayName(), event.x, event.y, event.z);
Expand Down

0 comments on commit 12001cd

Please sign in to comment.