Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/26/17 in all areas

  1. You don't have to cancel all spawns. You can check for what is trying to spawn, what dimension you're in and return false if you don't want it to spawn. You should have full control of spawning through that event.
    1 point
  2. I think the only tricky thing is I'm not sure the exact timing and order of these various events -- you need to tag the entity with the Capability at the time of creation but before the join event if possible. If the join event happens before the capability is fully applied you might need to using a living update event instead. There is possibly an entirely different approach. There is a CheckSpawn event which is used whenever a natural spawn is being considered by the server. I don't believe check spawn is called when using a spawn egg. So you may not have to tag the entities at all, just intercept the check spawn event and return false for those you don't want to spawn in that dimension and spawn eggs should continue to work normally.
    1 point
  3. I'm assuming there's a particular reason for wanting to use EntityJoinWorldEvent? Depending on what you're wanting to do, you could hook into LivingEntityUseItemEvent, and test for the spawn egg item. But it all depends on what you're trying to do
    1 point
  4. Alright, I spent hours figuring this one out. There are a myriad of methods you need to implement besides writeToNBT() and readFromNBT(NBTTagCompound). A working example of a luckyblock tileentity is: import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class TileEntityLuckyBlock extends TileEntity { public static final int MAX_TYPE = 1; private int luck; private int type; // 0: normal, 1: well private boolean isPlayerEditing; public TileEntityLuckyBlock() { this.luck = 0; this.type = 0; this.isPlayerEditing = false; } public int getLuck() { return luck; } public void setLuck(int newLuck) { luck = newLuck; markDirty(); // important } public int getType() { return type; } public void setType(int newType) { type = newType; markDirty(); // important } public boolean isPlayerEditing() { return isPlayerEditing; } public void setPlayerEditing(boolean editing) { isPlayerEditing = editing; // not marked because this field doesn't need to be persistent } public void executeDrop(World world, BlockPos pos, EntityPlayer breaker) { switch(type) { case 0: LBDrops.executeDrop(luck, world, pos, breaker); break; case 1: { EntityPlayer player = world.getClosestPlayer(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 16.0 * 16.0 * 32.0, false); if(player != null) LBDrops.executeWellDrop(luck, world, pos, player, false); break; } } } /** Everything below here is an absolute MUST have. **/ @Override public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate) { return false; } @Override public NBTTagCompound getTileData() { return serializeNBT(); } @Override public SPacketUpdateTileEntity getUpdatePacket() { NBTTagCompound nbt = new NBTTagCompound(); writeToNBT(nbt); return new SPacketUpdateTileEntity(this.pos, 1, nbt); } @Override public NBTTagCompound getUpdateTag() { NBTTagCompound nbt = new NBTTagCompound(); writeToNBT(nbt); return nbt; } @Override public void onDataPacket(NetworkManager manager, SPacketUpdateTileEntity packet) { readFromNBT(packet.getNbtCompound()); } /** Obviously these mehtods will be different. **/ @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setInteger("luck", luck); nbt.setInteger("type", type); return nbt; } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); luck = nbt.getInteger("luck"); type = nbt.getInteger("type"); isPlayerEditing = false; } } So basically try copying the implementations of shouldRefresh, getTileData, getUpdatePacket, getUpdateTag, and onDataPacket. You will also need to schedule a render update in onDataPacket if you're rendering your tile entity.
    1 point
  5. Yes, you could do something like that. Anything that somehow ties the use of the spawn egg to the creation of the entity. I suppose you could make use of the fact that entities have a field for the ticksExisted (or something like that) so when a spawn egg is finished being used you could check area for any of the same entity type that have only existed for a tick or less.
    1 point
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.