Brush Editor

This commit is contained in:
Kam committed 2025-02-13 02:09:50 -05:00
1 parent 16f2901fbc
commit cb2c7910cf
13 files changed
+274 -19

No files matched your search

@@ -37,6 +37,7 @@ import kamkeel.npcs.network.packets.request.effects.EffectSavePacket;
import kamkeel.npcs.network.packets.request.effects.EffectsGetPacket;
import kamkeel.npcs.network.packets.request.faction.*;
import kamkeel.npcs.network.packets.request.feather.DimensionTeleportPacket;
import kamkeel.npcs.network.packets.request.item.ColorSetPacket;
import kamkeel.npcs.network.packets.request.jobs.JobGetPacket;
import kamkeel.npcs.network.packets.request.jobs.JobSavePacket;
import kamkeel.npcs.network.packets.request.jobs.JobSpawnerAddPacket;
@@ -307,6 +308,9 @@ public class PacketHandler {
REQUEST_PACKET.registerPacket(new MovingPathSavePacket());
REQUEST_PACKET.registerPacket(new MovingPathGetPacket());
// Tool Packets
REQUEST_PACKET.registerPacket(new ColorSetPacket());
// Custom Effect Packets
REQUEST_PACKET.registerPacket(new EffectGetPacket());
REQUEST_PACKET.registerPacket(new EffectsGetPacket());
@@ -87,6 +87,13 @@ public class PacketUtil {
return false;
}
break;
case BRUSH:
if (item.getItem() != CustomItems.tool || item.getItemDamage() != 1) {
LogWriter.error(String.format("%s attempted to utilize a %s Packet without a Pather, they could be a hacker",
player.getCommandSenderName(), type));
return false;
}
break;
}
return true;
}
@@ -141,6 +148,8 @@ public class PacketUtil {
return !(item.getItem() == Item.getItemFromBlock(CustomItems.waypoint)
|| item.getItem() == Item.getItemFromBlock(CustomItems.border)
|| item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock));
case BRUSH:
return item.getItem() == CustomItems.tool && item.getItemDamage() == 1;
default:
return false;
}
@@ -176,6 +185,8 @@ public class PacketUtil {
return "Pather";
case BLOCK:
return "valid Block";
case BRUSH:
return "Paintbrush";
default:
return type.toString();
}
@@ -7,5 +7,6 @@ public enum EnumItemPacketType {
TELEPORTER,
SCRIPTER,
PATHER,
BLOCK
BLOCK,
BRUSH
}
@@ -177,4 +177,6 @@ public enum EnumRequestPacket {
EffectScriptGet,
EffectRemove,
EffectSave,
ColorSet,
}
@@ -0,0 +1,74 @@
package kamkeel.npcs.network.packets.request.item;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.PacketUtil;
import kamkeel.npcs.network.enums.EnumItemPacketType;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import kamkeel.npcs.util.ByteBufUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.controllers.LinkedNpcController;
import java.io.IOException;
public final class ColorSetPacket extends AbstractPacket {
public static String packetName = "Request|ColorSet";
private int color;
public ColorSetPacket(int color) {
this.color = color;
}
public ColorSetPacket() {}
@Override
public Enum getType() {
return EnumRequestPacket.ColorSet;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.REQUEST_PACKET;
}
@Override
public CustomNpcsPermissions.Permission getPermission() {
return CustomNpcsPermissions.NPC_BUILD;
}
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {
out.writeInt(this.color);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.BRUSH, player))
return;
int color = in.readInt();
ItemStack stack = player.getHeldItem();
setBrushColor(stack, color);
}
public static void setBrushColor(ItemStack brush, int color){
NBTTagCompound brushCompound = brush.getTagCompound();
if(brushCompound == null)
brushCompound = new NBTTagCompound();
brushCompound.setInteger("Color", color);
brush.setTagCompound(brushCompound);
}
}