Raycoms
Members-
Posts
383 -
Joined
-
Last visited
Everything posted by Raycoms
-
Change player inventory client side causes problems.
Raycoms replied to Raycoms's topic in Modder Support
Yeah I know how the packets work but I hoped deep inside my heart that I don't have to create one more of these messages =D -
Change player inventory client side causes problems.
Raycoms replied to Raycoms's topic in Modder Support
Shouldn't "markDirty()" cause such a package sending? Isn't there a precoded message which does update the inventory? -
When the player clicks a GUI. I'm causing this GUI giving the player an item in the inventory: ItemStack item = player.inventory.getStackInSlot(player.inventory.currentItem); player.inventory.setInventorySlotContents(emptySlot, item); player.inventory.setInventorySlotContents(player.inventory.currentItem, scepter); player.inventory.markDirty(); in the currentItem slot and I switch the old item to an old slot. But when I right click with the new item, it still tries to place the old block.
-
Oh my god. Didn't even notice I was creating a new stack, thanks =D
-
I'm trying to store some data in an item before I give it to the player (Position and an integer) ItemStack scepter = new ItemStack(ModItems.scepterGuard); if (!scepter.hasTagCompound()) { scepter.setTagCompound(new NBTTagCompound()); } NBTTagCompound compound = scepter.getTagCompound(); compound.setInteger("task", task.ordinal()); BlockPosUtil.writeToNBT(compound, "pos", building.getID()); ItemStack item = player.inventory.getStackInSlot(player.inventory.currentItem); player.inventory.setInventorySlotContents(emptySlot, item); player.inventory.setInventorySlotContents(player.inventory.currentItem, scepter); and trying to retrieve it afterwards in the item onUse: ItemStack scepter = new ItemStack(ModItems.scepterGuard); if (!scepter.hasTagCompound()) { scepter.setTagCompound(new NBTTagCompound()); } NBTTagCompound compound = scepter.getTagCompound(); int task = compound.getInteger("task"); BlockPos guardTower = BlockPosUtil.readFromNBT(compound, "pos"); But that doesn't work...
-
ClientOnly message causes problem on server start.
Raycoms replied to Raycoms's topic in Modder Support
but I could call a method with it? -
ClientOnly message causes problem on server start.
Raycoms replied to Raycoms's topic in Modder Support
The server doesn't need to know it? -
ClientOnly message causes problem on server start.
Raycoms replied to Raycoms's topic in Modder Support
Still: Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/multiplayer/WorldClient for invalid side SERVER at net.minecraftforge.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:56) ~[forgeSrc-1.10.2-12.18.1.2077-PROJECT(minecolonies).jar:?] at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:249) ~[forgeSrc-1.10.2-12.18.1.2077-PROJECT(minecolonies).jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.12.jar:?] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_112] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_112] at java.lang.Class.getDeclaredConstructors0(Native Method) ~[?:1.8.0_112] at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) ~[?:1.8.0_112] at java.lang.Class.getConstructor0(Class.java:3075) ~[?:1.8.0_112] at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_112] at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.instantiate(SimpleNetworkWrapper.java:166) ~[forgeSrc-1.10.2-12.18.1.2077-PROJECT(minecolonies).jar:?] at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.registerMessage(SimpleNetworkWrapper.java:159) ~[forgeSrc-1.10.2-12.18.1.2077-PROJECT(minecolonies).jar:?] at com.minecolonies.MineColonies.initializeNetwork(MineColonies.java:149) ~[minecolonies_main/:?] at com.minecolonies.MineColonies.init(MineColonies.java:96) ~[minecolonies_main/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_112] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_112] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_112] at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:597) ~[forgeSrc-1.10.2-12.18.1.2077-PROJECT(minecolonies).jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_112] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_112] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_112] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:239) ~[LoadController.class:?] at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:217) ~[LoadController.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_112] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_112] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_112] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:142) ~[LoadController.class:?] at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:788) ~[Loader.class:?] ... 5 more -
ClientOnly message causes problem on server start.
Raycoms replied to Raycoms's topic in Modder Support
getNetwork().registerMessage(SaveScanMessageHandler.class, SaveScanMessage.class, 51, Side.CLIENT); package com.minecolonies.network.messages; import com.minecolonies.util.LanguageHandler; import com.minecolonies.util.StructureWrapper; import net.minecraft.nbt.CompressedStreamTools; import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; /** * Handles sendScanMessages. */ public class SaveScanMessageHandler implements IMessageHandler<SaveScanMessage, IMessage> { /** * Public standard constructor. */ public SaveScanMessageHandler() { /* * Intentionally left empty. */ } @Nullable @Override public IMessage onMessage(@NotNull SaveScanMessage message, MessageContext ctx) { File file = new File(FMLClientHandler.instance().getClient().mcDataDir, message.storeLocation); StructureWrapper.createScanDirectory(FMLClientHandler.instance().getClient().theWorld); try (OutputStream outputstream = new FileOutputStream(file)) { CompressedStreamTools.writeCompressed(message.nbttagcompound, outputstream); } catch (Exception e) { LanguageHandler.sendPlayerLocalizedMessage(FMLClientHandler.instance().getClient().thePlayer, LanguageHandler.format("item.scepterSteel.scanFailure")); return null; } LanguageHandler.sendPlayerLocalizedMessage(FMLClientHandler.instance().getClient().thePlayer, LanguageHandler.format("item.scepterSteel.scanSuccess", message.storeLocation)); return null; } } package com.minecolonies.network.messages; import io.netty.buffer.ByteBuf; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fml.common.network.ByteBufUtils; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import org.jetbrains.annotations.NotNull; /** * Creates a message to save scans on the clients. */ public class SaveScanMessage implements IMessage { public NBTTagCompound nbttagcompound; public String storeLocation; /** * Send a scan compound to the client. * * @param nbttagcompound the stream. * @param storeAt string describing where to store the scan. */ public SaveScanMessage(NBTTagCompound nbttagcompound, String storeAt) { this.nbttagcompound = nbttagcompound; this.storeLocation = storeAt; } @Override public void fromBytes(@NotNull ByteBuf buf) { nbttagcompound = ByteBufUtils.readTag(buf); storeLocation = ByteBufUtils.readUTF8String(buf); } @Override public void toBytes(@NotNull ByteBuf buf) { ByteBufUtils.writeTag(buf, nbttagcompound); ByteBufUtils.writeUTF8String(buf, storeLocation); } } Still, same problem. -
ClientOnly message causes problem on server start.
Raycoms replied to Raycoms's topic in Modder Support
So one class only for the handler and one for the message? -
ClientOnly message causes problem on server start.
Raycoms replied to Raycoms's topic in Modder Support
Sure. package com.minecolonies.network.messages; import com.minecolonies.util.LanguageHandler; import com.minecolonies.util.StructureWrapper; import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.common.network.ByteBufUtils; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; /** * Send a scan outputStream to the client. */ public class SaveScanMessage implements IMessage, IMessageHandler<SaveScanMessage, IMessage> { private NBTTagCompound nbttagcompound; private String storeLocation; /** * Public standard constructor. */ public SaveScanMessage() { /* * Intentionally left empty. */ } /** * Send a scan compound to the client. * * @param nbttagcompound the stream. * @param storeAt string describing where to store the scan. */ public SaveScanMessage(NBTTagCompound nbttagcompound, String storeAt) { this.nbttagcompound = nbttagcompound; this.storeLocation = storeAt; } @Override public void fromBytes(@NotNull ByteBuf buf) { nbttagcompound = ByteBufUtils.readTag(buf); storeLocation = ByteBufUtils.readUTF8String(buf); } @Override public void toBytes(@NotNull ByteBuf buf) { ByteBufUtils.writeTag(buf, nbttagcompound); ByteBufUtils.writeUTF8String(buf, storeLocation); } @Nullable @Override public IMessage onMessage(@NotNull SaveScanMessage message, MessageContext ctx) { File file = new File(FMLClientHandler.instance().getClient().mcDataDir, message.storeLocation); StructureWrapper.createScanDirectory(FMLClientHandler.instance().getClient().theWorld); try (OutputStream outputstream = new FileOutputStream(file)) { CompressedStreamTools.writeCompressed(message.nbttagcompound, outputstream); } catch (Exception e) { LanguageHandler.sendPlayerLocalizedMessage(FMLClientHandler.instance().getClient().thePlayer, LanguageHandler.format("item.scepterSteel.scanFailure")); return null; } LanguageHandler.sendPlayerLocalizedMessage(FMLClientHandler.instance().getClient().thePlayer, LanguageHandler.format("item.scepterSteel.scanSuccess", message.storeLocation)); return null; } } -
I have the message: @Nullable @Override public IMessage onMessage(@NotNull SaveScanMessage message, MessageContext ctx) { File file = new File(FMLClientHandler.instance().getClient().mcDataDir, message.storeLocation); StructureWrapper.createScanDirectory(FMLClientHandler.instance().getClient().theWorld); try (OutputStream outputstream = new FileOutputStream(file)) { CompressedStreamTools.writeCompressed(message.nbttagcompound, outputstream); } catch (Exception e) { LanguageHandler.sendPlayerLocalizedMessage(FMLClientHandler.instance().getClient().thePlayer, LanguageHandler.format("item.scepterSteel.scanFailure")); return null; } LanguageHandler.sendPlayerLocalizedMessage(FMLClientHandler.instance().getClient().thePlayer, LanguageHandler.format("item.scepterSteel.scanSuccess", message.storeLocation)); return null; } Which will be sent from the server to the client. I registered it. getNetwork().registerMessage(SaveScanMessage.class, SaveScanMessage.class, 51, Side.CLIENT); It still crashes the server on loading because he has problems with: Caused by: java.lang.ClassNotFoundException: net.minecraft.client.multiplayer.WorldClient Also tried it with Minecraft.getMinecraft() no success. Shouldn't it work because it will only be executed on the client?
-
Is it possible to convert an NBTTagCompound to a byteArray and then retrieve a NBTTagCompound from a byteArray. I have an NBTTagCompound which I'd need to send over the network.
-
I tried to change it and we lost the related data. The tileEntity stays but the data which was stored to nbt in it will be changed.
-
Using: @Override public boolean isOpaqueCube(final IBlockState state) { return false; } @Override public boolean isFullBlock(final IBlockState state) { return false; } @Override public boolean doesSideBlockRendering(final IBlockState state, final IBlockAccess world, final BlockPos pos, final EnumFacing face) { return false; } Seems to have resolved it. I unfortunately, cannot change the tileEntityProvider thing because we would lose the stored tileEntities and that means that all our users would have to start over.
-
Yeah, true, my block is not a full block. The code of my block: The abstract: package com.minecolonies.blocks; import com.minecolonies.colony.Colony; import com.minecolonies.colony.ColonyManager; import com.minecolonies.colony.buildings.AbstractBuilding; import com.minecolonies.creativetab.ModCreativeTabs; import com.minecolonies.lib.Constants; import com.minecolonies.tileentities.TileEntityColonyBuilding; import net.minecraft.block.Block; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Abstract class for all minecolonies blocks. * <p> * The method {@link AbstractBlockHut#getName()} is abstract * <p> * All AbstractBlockHut[something] should extend this class */ public abstract class AbstractBlockHut extends Block implements ITileEntityProvider { public static final PropertyDirection FACING = BlockHorizontal.FACING; private static final float HARDNESS = 10F; private static final float RESISTANCE = Float.POSITIVE_INFINITY; protected int workingRange; /** * Constructor for a block using the minecolonies mod. * <p> * Registers the block, sets the creative tab, as well as the resistance and the hardness. */ public AbstractBlockHut() { super(Material.WOOD); initBlock(); } private void initBlock() { setRegistryName(getName()); setUnlocalizedName(Constants.MOD_ID.toLowerCase() + "." + getName()); setCreativeTab(ModCreativeTabs.MINECOLONIES); //Blast resistance for creepers etc. makes them explosion proof setResistance(RESISTANCE); //Hardness of 10 takes a long time to mine to not loose progress setHardness(HARDNESS); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); GameRegistry.register(this); GameRegistry.register((new ItemBlock(this)).setRegistryName(this.getRegistryName())); } /** * Method to return the name of the block. * * @return Name of the block. */ public abstract String getName(); @NotNull @Override public TileEntity createNewTileEntity(World world, int meta) { //Creates a tile entity for our building return new TileEntityColonyBuilding(); } @Override public int getMetaFromState(@NotNull IBlockState state) { return state.getValue(FACING).getIndex(); } // ======================================================================= // ======================= Rendering & IBlockState ======================= // ======================================================================= // render as a solid block, we don't want transparency here @NotNull @Override @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.SOLID; } @Override public boolean onBlockActivated( World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { /* If the world is client, open the gui of the building */ if (worldIn.isRemote) { @Nullable final AbstractBuilding.View building = ColonyManager.getBuildingView(pos); if (building != null) { building.openGui(); } } return true; } @Override public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, @Nullable EntityLivingBase placer) { @NotNull final EnumFacing enumFacing = (placer == null) ? EnumFacing.NORTH : EnumFacing.fromAngle(placer.rotationYaw); return this.getDefaultState().withProperty(FACING, enumFacing); } //We unfortunately have to implement these two, to rotate our blocks in the structures. @Override public IBlockState withRotation(final IBlockState state, final Rotation rot) { return state.withProperty(FACING, rot.rotate(state.getValue(FACING))); } @Override public IBlockState withMirror(final IBlockState state, final Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); } /** * Event-Handler for placement of this block. * <p> * Override for custom logic. * * @param worldIn the word we are in * @param pos the position where the block was placed * @param state the state the placed block is in * @param placer the player placing the block * @param stack the itemstack from where the block was placed * @see Block#onBlockPlacedBy(World, BlockPos, IBlockState, EntityLivingBase, ItemStack) */ @Override public void onBlockPlacedBy(@NotNull World worldIn, @NotNull BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { super.onBlockPlacedBy(worldIn, pos, state, placer, stack); /* Only work on server side */ if (worldIn.isRemote) { return; } final TileEntity tileEntity = worldIn.getTileEntity(pos); if (placer instanceof EntityPlayer && tileEntity instanceof TileEntityColonyBuilding) { @NotNull final TileEntityColonyBuilding hut = (TileEntityColonyBuilding) tileEntity; @Nullable final Colony colony = ColonyManager.getColony(worldIn, hut.getPosition()); if (colony != null) { colony.addNewBuilding(hut); } } } @NotNull @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, FACING); } // ======================================================================= // ===================== END of Rendering & Meta-Data ==================== // ======================================================================= } the block itself: package com.minecolonies.blocks; import net.minecraft.block.state.IBlockState; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import org.jetbrains.annotations.NotNull; /** * Hut for the fisherman. * No different from {@link AbstractBlockHut} */ public class BlockHutFisherman extends AbstractBlockHut { protected BlockHutFisherman() { //No different from Abstract parent super(); } @NotNull @Override public String getName() { return "blockHutFisherman"; } @Override public boolean isFullBlock(final IBlockState state) { return false; } @Override public boolean doesSideBlockRendering(final IBlockState state, final IBlockAccess world, final BlockPos pos, final EnumFacing face) { return false; } } Even with "isFullBlock" -> false I have the problems with the black rendered surfaces.
-
I have a custom block and when I place it down the neighboring blocks became transparent. That's why I put @Override public boolean doesSideBlockRendering(final IBlockState state, final IBlockAccess world, final BlockPos pos, final EnumFacing face) { return false; } Into my block code, but now the surface of the neighboring blocks renders black. What did I do wrong?
-
I am not able to run my gradle project anymore: http://pastebin.com/XAWiB2cE I tried running it with ./gradlew setupDecompWorkspace --stacktrace --debug and even tried adding -DXmx4g and -DXmx8g, didn't change anything.
-
We've added new workers to defend your city. There are melee and range guards. We also fixed a huge amount of bugs and added new buildings and more variation.
-
I'm using 1.10 and I looked at the example he posted. But I wasn't able to understand what I have to do to get it working. I have a json model, a tile entity and the block/item. How can I implement this text rendering for the block. The text should depend on a variable in the tileEntity.
-
The link was for not tileEntitySpecialRenderer. String text = "Blablablah"; FontRenderer fontRenderer = this.getFontRenderer(); fontRenderer.drawString(text, 0, (int) (y * fontRenderer.FONT_HEIGHT), 0xFFFF00FF); I tried that similar to the font rendering he sent. But I can't find the text. When I am at a certain angle I got some block artifacts in the image but no words. I'd like to have it on top of my block.
-
Yeah I have that, but how do I get text rendered correctly?
-
Since I already have a tileEntitySpecialRenderer and tileEntity for my block. How would I do it in that case?
-
And when the text I want to have displayed may change depending on GUI interactions, will this still be possible?
-
I have a custom block, my tileEntity and my tileEntity special renderer. I guessed it should be somewhat similar to this.getFontRenderer().drawString(); to draw the string. but I couldn't figure out the int parameters yet. What would it be if I have a String I want on top of the block?