Client-Server Script desync
This commit is contained in:
parent
416124c9d2
commit
b42d538049
|
|
@ -15,6 +15,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.TextComponentString;
|
import net.minecraft.util.text.TextComponentString;
|
||||||
|
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
import tschipp.carryon.CarryOn;
|
import tschipp.carryon.CarryOn;
|
||||||
import tschipp.carryon.common.handler.CustomPickupOverrideHandler;
|
import tschipp.carryon.common.handler.CustomPickupOverrideHandler;
|
||||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||||
|
|
@ -76,7 +77,7 @@ public class CommandCarryOn extends CommandBase implements ICommand
|
||||||
cleared += player.inventory.clearMatchingItems(RegistrationHandler.itemTile, 0, 64, null);
|
cleared += player.inventory.clearMatchingItems(RegistrationHandler.itemTile, 0, 64, null);
|
||||||
cleared += player.inventory.clearMatchingItems(RegistrationHandler.itemEntity, 0, 64, null);
|
cleared += player.inventory.clearMatchingItems(RegistrationHandler.itemEntity, 0, 64, null);
|
||||||
|
|
||||||
CarryOn.network.sendTo(new CarrySlotPacket(9), (EntityPlayerMP) player);
|
CarryOn.network.sendToAllAround(new CarrySlotPacket(9), new TargetPoint(player.world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
||||||
|
|
||||||
if (cleared != 1)
|
if (cleared != 1)
|
||||||
player.sendMessage(new TextComponentString("Cleared " + cleared + " Items!"));
|
player.sendMessage(new TextComponentString("Cleared " + cleared + " Items!"));
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
||||||
|
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
|
|
@ -91,10 +92,10 @@ public class ItemEntityEvents
|
||||||
{
|
{
|
||||||
if (ItemEntity.storeEntityData(entity, world, stack))
|
if (ItemEntity.storeEntityData(entity, world, stack))
|
||||||
{
|
{
|
||||||
if(entity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
|
if (entity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
|
||||||
{
|
{
|
||||||
IItemHandler handler = entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
IItemHandler handler = entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
||||||
for(int i = 0; i < handler.getSlots(); i++)
|
for (int i = 0; i < handler.getSlots(); i++)
|
||||||
{
|
{
|
||||||
handler.extractItem(i, 64, false);
|
handler.extractItem(i, 64, false);
|
||||||
}
|
}
|
||||||
|
|
@ -102,10 +103,10 @@ public class ItemEntityEvents
|
||||||
|
|
||||||
CarryOnOverride override = ScriptChecker.inspectEntity(entity);
|
CarryOnOverride override = ScriptChecker.inspectEntity(entity);
|
||||||
int overrideHash = 0;
|
int overrideHash = 0;
|
||||||
if(override != null)
|
if (override != null)
|
||||||
overrideHash = override.hashCode();
|
overrideHash = override.hashCode();
|
||||||
|
|
||||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, overrideHash), (EntityPlayerMP) player);
|
CarryOn.network.sendToAllAround(new CarrySlotPacket(player.inventory.currentItem, overrideHash), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
||||||
entity.setDead();
|
entity.setDead();
|
||||||
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
||||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
import tschipp.carryon.CarryOn;
|
import tschipp.carryon.CarryOn;
|
||||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||||
import tschipp.carryon.common.handler.ListHandler;
|
|
||||||
import tschipp.carryon.common.handler.PickupHandler;
|
import tschipp.carryon.common.handler.PickupHandler;
|
||||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||||
import tschipp.carryon.common.item.ItemTile;
|
import tschipp.carryon.common.item.ItemTile;
|
||||||
|
|
@ -123,7 +123,7 @@ public class ItemEvents
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CarryOn.network.sendTo(new CarrySlotPacket(player.inventory.currentItem, overrideHash), (EntityPlayerMP) player);
|
CarryOn.network.sendToAllAround(new CarrySlotPacket(player.inventory.currentItem, overrideHash), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
||||||
world.removeTileEntity(pos);
|
world.removeTileEntity(pos);
|
||||||
world.setBlockToAir(pos);
|
world.setBlockToAir(pos);
|
||||||
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
player.setHeldItem(EnumHand.MAIN_HAND, stack);
|
||||||
|
|
@ -132,7 +132,7 @@ public class ItemEvents
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
CarryOn.network.sendTo(new CarrySlotPacket(9), (EntityPlayerMP) player);
|
CarryOn.network.sendToAllAround(new CarrySlotPacket(9), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));
|
||||||
world.setBlockState(pos, statee);
|
world.setBlockState(pos, statee);
|
||||||
if (!tag.hasNoTags())
|
if (!tag.hasNoTags())
|
||||||
TileEntity.create(world, tag);
|
TileEntity.create(world, tag);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user