Everything posted by Darmo
-
[1.16.5] Custom minecart entity is lagging/stuttering
Oh, that was much simpler to fix than I thought ^^ Thanks!
-
[1.16.5] Custom minecart entity is lagging/stuttering
Anyone has any idea?
-
[1.16.5] Custom minecart entity is lagging/stuttering
Hi, I’m trying to make a custom minecart entity but it has some strange behavior: whenever I spawn one on rails, it stutters; it moves for a bit then jumps forward, then moves a bit again and so on. But if the class inherits MinecartEntity, it works as it should. I don’t understand why. Here’s how I declare my entity class: public class TestMinecartEntity extends AbstractMinecartEntity { public TestMinecartEntity(EntityType<?> type, World world) { super(type, world); } public TestMinecartEntity(World world, double x, double y, double z) { super(ModEntities.TEST_MINECART.get(), world, x, y, z); } @Override public ActionResultType processInitialInteract(PlayerEntity player, Hand hand) { if (player.isSecondaryUseActive() || this.isBeingRidden()) { return ActionResultType.PASS; } else if (!this.world.isRemote) { return player.startRiding(this) ? ActionResultType.CONSUME : ActionResultType.PASS; } else { return ActionResultType.SUCCESS; } } @Override public Type getMinecartType() { return Type.RIDEABLE; } @Override public IPacket<?> createSpawnPacket() { return NetworkHooks.getEntitySpawningPacket(this); } } The entity type definition: public class ModEntities { public static final RegistryObject<EntityType<TestMinecartEntity>> TEST_MINECART = REGISTER.register( "test_minecart", () -> EntityType.Builder.<TestMinecartEntity>create(TestMinecartEntity::new, EntityClassification.MISC) .size(0.98f, 0.98f) .trackingRange(10) .updateInterval(10) .immuneToFire() .build("test_minecart") ); } Am I missing something here? Is there some vanilla code that might cause this behavior?
-
[1.16.5] Custom texture for TER
Hi, I have a TER for a custom tile entity and I’m trying to apply a texture to a ModelRenderer box. I figured I should use the a texture atlas but I don’t know how to acheive that… I saw here I should register a custom ReloadListener and look into the ParticleManager class but that’s not really helped me at all. What do I have to do exactly? Nowhere in the docs explains how to proceed. My texture is in assets/<modid>/textures/entity/<te_name>/<te_name>.png in my mod’s resources directory. Thanks!
-
[1.10.2] Custom Signs
Ok, I'll try, thanks for the help anyway
-
[1.10.2] Custom Signs
I still get null, even when using displayGuiScreen instead of the gui handler
-
[1.10.2] Custom Signs
I use a gui handler because I have many custom containers that need that system. I used it to handle the signs gui as well as it was already made (and I don't know how to do otherwise). The code I posted is just the part relevant to the current question.
-
[1.10.2] Custom Signs
McfrNetworkWrapper is the custom network wrapper; OpenEditMcfrSignMessage is the custom packet to notify the client to open the sign edition gui; TileEntityMcfrSign is a custom tile entity extending TileEntitySign; CustomGuiScreen is an enum declaring all guis from the mod. Custom Item Sign: public class McfrItemSign extends McfrItem { private McfrBlockStandingSign standingSign; private McfrBlockWallSign wallSign; private McfrBlockSuspendedSign suspendedSign; private Class<? extends TileEntityMcfrSign> teClass; public McfrItemSign(String name, McfrBlockStandingSign standingSign, McfrBlockWallSign wallSign, McfrBlockSuspendedSign suspendedSign, Class<? extends TileEntityMcfrSign> teClass) { super(name, 64, CreativeTabs.DECORATIONS); this.standingSign = standingSign; this.wallSign = wallSign; this.suspendedSign = suspendedSign; this.teClass = teClass; } @Override public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { IBlockState state = worldIn.getBlockState(pos); boolean flag = state.getBlock().isReplaceable(worldIn, pos); if (facing != EnumFacing.DOWN && (state.getMaterial().isSolid() || flag) && (!flag || facing == EnumFacing.UP)) { pos = pos.offset(facing); if (playerIn.canPlayerEdit(pos, facing, stack) && this.standingSign.canPlaceBlockAt(worldIn, pos)) { if (!worldIn.isRemote) { pos = flag ? pos.down() : pos; if (facing == EnumFacing.UP) { int i = getRotation(playerIn); worldIn.setBlockState(pos, this.standingSign.getDefaultState().withProperty(McfrBlockStandingSign.ROTATION, Integer.valueOf(i)), 11); } else if (facing == EnumFacing.DOWN) { int i = getRotation(playerIn); worldIn.setBlockState(pos, this.suspendedSign.getDefaultState().withProperty(McfrBlockSuspendedSign.ROTATION, Integer.valueOf(i)), 11); } else { worldIn.setBlockState(pos, this.wallSign.getDefaultState().withProperty(McfrBlockWallSign.FACING, facing), 11); } stack.stackSize--; TileEntity te = worldIn.getTileEntity(pos); if (te != null && te.getClass() == this.teClass && !ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack)) { ((TileEntityMcfrSign) te).setPlayer(playerIn); // We send the packet to the client. McfrNetworkWrapper.getInstance().sendTo(new OpenEditMcfrSignMessage(pos), (EntityPlayerMP) playerIn); } } return EnumActionResult.SUCCESS; } } return EnumActionResult.FAIL; } private int getRotation(EntityPlayer playerIn) { return MathHelper.floor_double((playerIn.rotationYaw + 180) * 16 / 360 + 0.5) & 15; } } Message Handler: public class OpenEditMcfrSignMessageHandler implements IMessageHandler<OpenEditMcfrSignMessage, IMessage> { @Override @SideOnly(Side.CLIENT) public IMessage onMessage(final OpenEditMcfrSignMessage message, MessageContext ctx) { Minecraft.getMinecraft().addScheduledTask(new Runnable() { @Override public void run() { BlockPos pos = message.getSignPos(); EntityPlayer player = Minecraft.getMinecraft().thePlayer; World world = Minecraft.getMinecraft().theWorld; // Opens the sign edition gui (calls the Gui Handler below). player.openGui(McfrMain.instance, CustomGuiScreens.SIGN.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } }); return null; } } Gui Handler: @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { BlockPos pos = new BlockPos(x, y, z); // Here I get null instead of the sign's tile entity. TileEntity tileEntity = world.getTileEntity(pos); // If the ID is SIGN, open the custom edition gui. if (id == CustomGuiScreen.SIGN.ordinal() && tileEntity instanceof TileEntityMcfrSign) return new GuiEditSign((TileEntityMcfrSign) tileEntity); return null; } What is happening here is that when the player right-clicks, the server sends a packet (call to sendTo in onItemUse) to the player to make him open the edition gui. When the Gui Handler is called, I get null where there should be the newly placed tile entity.
-
[1.10.2] Custom Signs
I did that, but the packet seems to somehow arrive before the block update so I get a null tile entity...
-
[1.10.2] Custom Signs
Ok then, but how am I supposed to open the gui from the packet's processPacket method?
-
[1.10.2] Custom Signs
Because the method handleSignEditorOpen calls the openEditSign method from the player which opens the default gui. We're coming back to the initial concern.
-
[1.10.2] Custom Signs
Yep, it seems so, but I also need a custom client NetHandler. How do I register a custom one?
-
[1.10.2] Custom Signs
I tried that, but the server never sends the packet to the client to open the gui. I looked up the code inside the openEditSign method in EntityPlayerMP, a specific packet (SPacketSignEditorOpen) is sent to the client when it is called. It's that packet, when processed, that opens the gui clientside. I tried sending it myself but still no luck, the clientside method is still hardcoded.
-
[1.10.2] Custom Signs
Well, the thing is that it is hard-coded into the method, so it can't be replaced. Extracted from EntityPlayerSP: public void openEditSign(TileEntitySign signTile) { this.mc.displayGuiScreen(new GuiEditSign(signTile)); } My problem is that I don't know how to go around this...
-
[1.10.2] Custom Signs
Hello everyone, I'm currently making a mod for a server where I need to add 3 custom signs. The problem is that the method EntityPlayerSP.openEditSign uses the vanilla class GuiEditSign so the render is completely broken for both the model and the GUI. I made my own GuiScreen but I don't know where to use it. I tried to use a GuiHandler but I don't know what to return in the method getServerGuiElement() . Thanks in advance.
IPS spam blocked by CleanTalk.