Skip to content

Commit

Permalink
fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ckscor3 committed Jan 31, 2018
1 parent 054a52e commit 10c7f7c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.netty.buffer.ByteBuf;
import net.geforcemods.securitycraft.tileentity.TileEntityOwnable;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
Expand Down Expand Up @@ -54,10 +55,10 @@ public static class Handler implements IMessageHandler<PacketCRequestTEOwnableUp
@Override
public PacketSUpdateTEOwnable onMessage(PacketCRequestTEOwnableUpdate message, MessageContext ctx)
{
TileEntityOwnable te = (TileEntityOwnable)FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(message.dimension).getTileEntity(message.pos);
TileEntity te = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(message.dimension).getTileEntity(message.pos);

if(te != null)
return new PacketSUpdateTEOwnable(te);
if(te != null && te instanceof TileEntityOwnable)
return new PacketSUpdateTEOwnable((TileEntityOwnable)te);
else
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.geforcemods.securitycraft.tileentity.TileEntityOwnable;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
Expand Down Expand Up @@ -66,9 +67,12 @@ public static class Handler implements IMessageHandler<PacketSUpdateTEOwnable, I
public IMessage onMessage(final PacketSUpdateTEOwnable message, MessageContext ctx)
{
Minecraft.getMinecraft().addScheduledTask(() -> {
TileEntityOwnable te = ((TileEntityOwnable)Minecraft.getMinecraft().theWorld.getTileEntity(message.pos));
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(message.pos);

te.setOwner(message.uuid, message.name);
if(!(te instanceof TileEntityOwnable))
return;

((TileEntityOwnable)te).setOwner(message.uuid, message.name);

if(message.customizable)
((CustomizableSCTE)te).readFromNBT(message.tag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.netty.buffer.ByteBuf;
import net.geforcemods.securitycraft.tileentity.TileEntityOwnable;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
Expand Down Expand Up @@ -54,10 +55,10 @@ public static class Handler implements IMessageHandler<PacketCRequestTEOwnableUp
@Override
public PacketSUpdateTEOwnable onMessage(PacketCRequestTEOwnableUpdate message, MessageContext ctx)
{
TileEntityOwnable te = (TileEntityOwnable)FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(message.dimension).getTileEntity(message.pos);
TileEntity te = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(message.dimension).getTileEntity(message.pos);

if(te != null)
return new PacketSUpdateTEOwnable(te);
if(te != null && te instanceof TileEntityOwnable)
return new PacketSUpdateTEOwnable((TileEntityOwnable)te);
else
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.geforcemods.securitycraft.tileentity.TileEntityOwnable;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
Expand Down Expand Up @@ -66,9 +67,12 @@ public static class Handler implements IMessageHandler<PacketSUpdateTEOwnable, I
public IMessage onMessage(final PacketSUpdateTEOwnable message, MessageContext ctx)
{
Minecraft.getMinecraft().addScheduledTask(() -> {
TileEntityOwnable te = ((TileEntityOwnable)Minecraft.getMinecraft().world.getTileEntity(message.pos));
TileEntity te = Minecraft.getMinecraft().world.getTileEntity(message.pos);

te.setOwner(message.uuid, message.name);
if(!(te instanceof TileEntityOwnable))
return;

((TileEntityOwnable)te).setOwner(message.uuid, message.name);

if(message.customizable)
((CustomizableSCTE)te).readFromNBT(message.tag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.netty.buffer.ByteBuf;
import net.geforcemods.securitycraft.tileentity.TileEntityOwnable;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
Expand Down Expand Up @@ -54,10 +55,10 @@ public static class Handler implements IMessageHandler<PacketCRequestTEOwnableUp
@Override
public PacketSUpdateTEOwnable onMessage(PacketCRequestTEOwnableUpdate message, MessageContext ctx)
{
TileEntityOwnable te = (TileEntityOwnable)FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(message.dimension).getTileEntity(message.pos);
TileEntity te = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(message.dimension).getTileEntity(message.pos);

if(te != null)
return new PacketSUpdateTEOwnable(te);
if(te != null && te instanceof TileEntityOwnable)
return new PacketSUpdateTEOwnable((TileEntityOwnable)te);
else
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.geforcemods.securitycraft.tileentity.TileEntityOwnable;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
Expand Down Expand Up @@ -66,9 +67,12 @@ public static class Handler implements IMessageHandler<PacketSUpdateTEOwnable, I
public IMessage onMessage(final PacketSUpdateTEOwnable message, MessageContext ctx)
{
Minecraft.getMinecraft().addScheduledTask(() -> {
TileEntityOwnable te = ((TileEntityOwnable)Minecraft.getMinecraft().world.getTileEntity(message.pos));
TileEntity te = Minecraft.getMinecraft().world.getTileEntity(message.pos);

te.setOwner(message.uuid, message.name);
if(!(te instanceof TileEntityOwnable))
return;

((TileEntityOwnable)te).setOwner(message.uuid, message.name);

if(message.customizable)
((CustomizableSCTE)te).readFromNBT(message.tag);
Expand Down

0 comments on commit 10c7f7c

Please sign in to comment.