Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Narlecks

Members
  • Joined

  • Last visited

Everything posted by Narlecks

  1. in the first instance it worked, but for some reason when hitting it keeps getting different id's on server / client. Did I made a mistake while implementing IEntityAdditionalSpawnData? @Override public IPacket<?> createSpawnPacket() { return NetworkHooks.getEntitySpawningPacket(this); } @Override public void writeSpawnData(PacketBuffer buffer) { int[] id = new int[getAllParts().length]; for(int i=0;i<getAllParts().length;i++) { getAllParts()[i].setEntityId(i+this.getEntityId()); id[i] = i+this.getEntityId(); } buffer.writeVarIntArray(id); } @Override public void readSpawnData(PacketBuffer additionalData) { int[] id = additionalData.readVarIntArray(); for(int i=0;i<getAllParts().length;i++) { getAllParts()[i].setEntityId(id[i]); } }
  2. Any idea where Minecraft does that? or i put it in the same place using packets?
  3. The problem is, it only works in clientside, the id's on serverside are not the same
  4. one thing I forgot to say is that following the EnderDragon's code i came across this: public void handleSpawnMob(SSpawnMobPacket packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, (ClientPlayNetHandler) (Object)this, this.client); double d0 = packetIn.getX(); double d1 = packetIn.getY(); double d2 = packetIn.getZ(); float f = (float)(packetIn.getYaw() * 360) / 256.0F; float f1 = (float)(packetIn.getPitch() * 360) / 256.0F; LivingEntity livingentity = (LivingEntity)EntityType.create(packetIn.getEntityType(), this.client.world); if (livingentity != null) { livingentity.setPacketCoordinates(d0, d1, d2); livingentity.renderYawOffset = (float)(packetIn.getHeadPitch() * 360) / 256.0F; livingentity.rotationYawHead = (float)(packetIn.getHeadPitch() * 360) / 256.0F; if (livingentity instanceof EnderDragonEntity) { EnderDragonPartEntity[] aenderdragonpartentity = ((EnderDragonEntity)livingentity).getDragonParts(); for(int i = 0; i < aenderdragonpartentity.length; ++i) { aenderdragonpartentity[i].setEntityId(i + packetIn.getEntityID()); } } if (livingentity instanceof MultiPartEntity) { MultiPartEntityPart[] multipartentitypart = ((MultiPartEntity)livingentity).getAllParts(); for(int i = 0; i < multipartentitypart.length; ++i) { multipartentitypart[i].setEntityId(i + packetIn.getEntityID()); } } livingentity.setEntityId(packetIn.getEntityID()); livingentity.setUniqueId(packetIn.getUniqueId()); livingentity.setPositionAndRotation(d0, d1, d2, f, f1); livingentity.setMotion((double)((float)packetIn.getVelocityX() / 8000.0F), (double)((float)packetIn.getVelocityY() / 8000.0F), (double)((float)packetIn.getVelocityZ() / 8000.0F)); this.world.addEntity(packetIn.getEntityID(), livingentity); if (livingentity instanceof BeeEntity) { boolean flag = ((BeeEntity)livingentity).isAngry(); BeeSound beesound; if (flag) { beesound = new BeeAngrySound((BeeEntity)livingentity); } else { beesound = new BeeFlightSound((BeeEntity)livingentity); } this.client.getSoundHandler().play(beesound); } } else { LOGGER.warn("Skipping Entity with id {}", (int)packetIn.getEntityType()); } } I'm not sure if the error is in this part, but as you can see I added a condition to modify the entityID of each part, I tried it and it works as it should on clientSide
  5. Thanks for the suggestion!, i solved that problem but i found another.. The problem is, the entity parts have different IDs on client and server So, for example.. when i hit the head, in client-side the hit is received by the head but in server-side is received by the body bc the ids collide Do you have an idea why that can happen? Tell me if u need specific information
  6. It never reaches AttackEntityFrom because the other hitboxes even though they exist, I can't hit them.
  7. You are right, my bad. When I hit the entity, in the console I don't get any messages
  8. Version: 1.15.2 I'm trying to make a mob that has multiple hitboxes, i take a look on Ender Dragon's code but when i hit the entity, it just dont works. (in debug mode(f3) it shows me the hitboxes correctly) NewEntity.class public class NewEntity extends MultiPartEntity { protected final MultiPartEntityPart[] bodyParts; public final MultiPartEntityPart headPart; public final MultiPartEntityPart bodyPart; public NewEntity(EntityType<? extends MultiPartEntity> type, World worldIn) { super(type, worldIn); this.bodyPart = new MultiPartEntityPart(this, "body", 2.0F, 1.0F); this.headPart = new MultiPartEntityPart(this, "head", 1.0F, 1.0F); this.bodyParts = new MultiPartEntityPart[]{this.headPart,this.bodyPart}; } @Override protected void registerAttributes() { super.registerAttributes(); this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(100); } public boolean attackEntityFrom(DamageSource source, float amount) { return false; } public boolean attackEntityFrom(MultiPartEntityPart entityPart, DamageSource source, float damage) { System.out.println(entityPart.partName); return true; } public boolean canBeCollidedWith() { return false; } @Override public boolean canBePushed() { return false; } @Override public void livingTick() { super.livingTick(); Vec3d[] avec3d = new Vec3d[this.bodyParts.length]; for(int j = 0; j < this.bodyParts.length; ++j) { avec3d[j] = new Vec3d(this.bodyParts[j].getPosX(), this.bodyParts[j].getPosY(), this.bodyParts[j].getPosZ()); } bodyParts[0].setPosition(0,0 + 1f,0); bodyParts[1].setPosition(0,0 - 0.2f,0); for(int l = 0; l < this.bodyParts.length; ++l) { this.bodyParts[l].prevPosX = avec3d[l].x; this.bodyParts[l].prevPosY = avec3d[l].y; this.bodyParts[l].prevPosZ = avec3d[l].z; this.bodyParts[l].lastTickPosX = avec3d[l].x; this.bodyParts[l].lastTickPosY = avec3d[l].y; this.bodyParts[l].lastTickPosZ = avec3d[l].z; } } @Override public MultiPartEntityPart[] getAllParts() { return this.bodyParts; } } MultiPartEntity.class public abstract class MultiPartEntity extends CreatureEntity { protected MultiPartEntity(EntityType<? extends CreatureEntity> type, World worldIn) { super(type, worldIn); } public abstract boolean attackEntityFrom(MultiPartEntityPart entityPart, DamageSource source, float damage); public abstract MultiPartEntityPart[] getAllParts(); } MultiPartEntityPart.class: public class MultiPartEntityPart extends Entity { public final MultiPartEntity parentEntity; public final String partName; private final EntitySize boxSize; public MultiPartEntityPart(MultiPartEntity parentEntity, String partName, float widthIn, float HeightIn) { super(parentEntity.getType(), parentEntity.world); this.boxSize = EntitySize.flexible(widthIn, HeightIn); this.recalculateSize(); this.parentEntity = (MultiPartEntity) parentEntity; this.partName = partName; } protected void registerData() { } protected void readAdditional(CompoundNBT compound) { } protected void writeAdditional(CompoundNBT compound) { } public boolean canBeCollidedWith() { return true; } public boolean attackEntityFrom(DamageSource source, float amount) { return this.parentEntity.attackEntityFrom(this, source, amount); } public boolean isEntityEqual(Entity entityIn) { return this == entityIn || this.parentEntity == entityIn; } public IPacket<?> createSpawnPacket() { throw new UnsupportedOperationException(); } public EntitySize getSize(Pose poseIn) { return this.boxSize; } }
  9. I'm trying to use a dependency for my mod, but i need it to be deobfuscated (to use it in the dev environment) i tried adding the dependency with fg.deobf in the build.gradle but when i refresh gradle it throws me "Error getting artifact" I'm doing it wrong? build.gradle: buildscript { repositories { maven { url = 'https://files.minecraftforge.net/maven' } jcenter() mavenCentral() } dependencies { classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true } } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' repositories { jcenter() maven { name = "CurseForge" url = "https://minecraft.curseforge.com/api/maven/" } } version = '1.0' group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'modid' sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. minecraft { mappings channel: 'snapshot', version: '20200514-1.15.1' runs { client { workingDirectory project.file('run') // Recommended logging data for a userdev environment property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' // Recommended logging level for the console property 'forge.logging.console.level', 'debug' mods { examplemod { source sourceSets.main } } } server { workingDirectory project.file('run') // Recommended logging data for a userdev environment property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' // Recommended logging level for the console property 'forge.logging.console.level', 'debug' mods { examplemod { source sourceSets.main } } } data { workingDirectory project.file('run') // Recommended logging data for a userdev environment property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' // Recommended logging level for the console property 'forge.logging.console.level', 'debug' args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/') mods { examplemod { source sourceSets.main } } } } } dependencies { minecraft 'net.minecraftforge:forge:1.15.2-31.2.0' implementation fg.deobf("com.github.ErdbeerbaerLP:ErdbeerbaerGuiLib:1.0.2") } jar { manifest { attributes([ "Specification-Title": "examplemod", "Specification-Vendor": "examplemodsareus", "Specification-Version": "1", // We are version 1 of ourselves "Implementation-Title": project.name, "Implementation-Version": "${version}", "Implementation-Vendor" :"examplemodsareus", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } } jar.finalizedBy('reobfJar') publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file:///${project.projectDir}/mcmodsrepo" } } } Minecraft version: 1.15.2 Forge: 31.2.0 Error message: https://imgur.com/a/CD2ajKN
  10. Hello, it's my first time using Reflections and i want to know if i am doing it correctly. (In my mod i have to change the player eyeHeight several times, which is private) So, i stored the reflected field in a private static Field and then, when i need to use it i call it. I already try it and works but my question is, is the correct way to do it?
  11. But it doesn't and idk why..
  12. public class KeyHandler { private static final String CATEGORY = "mod-test"; public static KeyBinding test; public KeyHandler() { test = new KeyBinding("", GLFW.GLFW_KEY_H, CATEGORY); ClientRegistry.registerKeyBinding(test); } @SubscribeEvent public void keyEvent(ClientTickEvent event) { if(event.phase.equals(Phase.END) && mc.isGameFocused()) { if(test.isPressed()) { System.out.println("test"); } } } }
  13. End phase? i tried but didn't work.
  14. Hi, i have an issue with a keybind, when i use myKey.isPressed always returns true(works like isKeyDown), when should "Returns true on the initial key press" My "KeyHandler" class: public class KeyHandler { private static final String CATEGORY = "mod-test"; public static KeyBinding test; public KeyHandler() { test = new KeyBinding("", GLFW.GLFW_KEY_H, CATEGORY); ClientRegistry.registerKeyBinding(test); } @SubscribeEvent public void keyEvent(InputEvent.KeyInputEvent event) { if(mc.isGameFocused()) { if(test.isPressed()) { System.out.println("test"); } } } } Main class: @Mod("dpz") @Mod.EventBusSubscriber(modid = Main.MODID) public class Main { public static final String MODID = "dpz"; public static final String NAME = "testmod"; public static final String VERSION = "1.0"; public static Minecraft mc; public Main() { MinecraftForge.EVENT_BUS.register(this); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); } private void setup(FMLCommonSetupEvent event) { mc = Minecraft.getInstance(); } private void doClientStuff(FMLClientSetupEvent event) { MinecraftForge.EVENT_BUS.register(new KeyHandler()); } } Forge version: 31.1.0
  15. If u want a full view of my main class: @Mod("dpz") public class Main { public static final String MODID = "dpz"; public static final String NAME = "Update test"; public static final String VERSION = "1.0"; public Main() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { registerCapabilities(); Handler.register(); MinecraftForge.EVENT_BUS.register(new ServerEvents()); } private void doClientStuff(final FMLClientSetupEvent event) { MinecraftForge.EVENT_BUS.register(new Hud(null)); } @SubscribeEvent public void onServerStarting(FMLServerStartingEvent event) { CommandHandler.register(event.getCommandDispatcher()); } public void registerCapabilities() { CapabilityManager.INSTANCE.register(IPlayerData.class, new Storage<IPlayerData>(), PlayerData::new); MinecraftForge.EVENT_BUS.register(new Capabilities()); } }
  16. Ok i see, i use a commandhandler bc i want to put different subcommands in one. CommandHandler: public class CommandHandler { public static void register(CommandDispatcher<CommandSource> dispatcher) { LiteralCommandNode<CommandSource> command = dispatcher.register( Commands.literal(Main.MODID) .then(PointsCommand.register(dispatcher)) ); dispatcher.register(Commands.literal(Main.MODID).redirect(command)); } } and i call it on my main class @SubscribeEvent public void onServerStarting(FMLServerStartingEvent event) { CommandHandler.register(event.getCommandDispatcher()); }
  17. public class PointsCommand { public static ArgumentBuilder<CommandSource, ?> register(CommandDispatcher<CommandSource> dispatcher){ return Commands.literal("points") .requires(cs -> cs.hasPermissionLevel(3)) .executes(source -> { return run(null, 0);}) .then(Commands.argument("target", EntityArgument.player()) .executes(source -> { return run(EntityArgument.getPlayer(source, "target"), 0);}) .then(Commands.argument("quantity", IntegerArgumentType.integer()) .executes(source -> { return run(EntityArgument.getPlayer(source, "target"), IntegerArgumentType.getInteger(source, "quantity")); })))); } public static int run(PlayerEntity pPlayer, int pQuantity) { if(pPlayer != null) { if(Integer.class.isInstance(pQuantity)) { Handler.INSTANCE.sendToServer(new PacketPoints(pQuantity, pPlayer.getUniqueID())); return 0; } else { Minecraft.getInstance().player.sendMessage(new TranslationTextComponent("gui.error.1")); return 0; } } else { Minecraft.getInstance().player.sendMessage(new TranslationTextComponent("gui.error.2")); return 0; } } }
  18. Hi, i'm updating my mod and i have some problems with networking. When i use my packet in a command to give points to the players it only changes in the client public class Handler { private static final String PROTOCOL_VERSION = Integer.toString(1); public static SimpleChannel INSTANCE; public static void register() { INSTANCE = NetworkRegistry.ChannelBuilder .named(new ResourceLocation(Main.MODID, "main")) .clientAcceptedVersions(PROTOCOL_VERSION::equals) .serverAcceptedVersions(PROTOCOL_VERSION::equals) .networkProtocolVersion(() -> PROTOCOL_VERSION) .simpleChannel(); int id = 0; INSTANCE.messageBuilder(PacketPoints.class, id++) .decoder(PacketPoints::new) .encoder(PacketPoints::encode) .consumer(PacketPoints::handle) .add(); } } PacketPoints message: public class PacketPoints { private int quantity; private UUID playerUuid; public PacketPoints(){} public PacketPoints(PacketBuffer buf) { this.quantity = buf.readInt(); this.player = buf.readUniqueId(); } public PacketPoints(int pQuantity, UUID pPlayerUuid) { this.quantity = pQuantity; this.playerUuid = pPlayerUuid; } public void encode(PacketBuffer buf) { buf.writeInt(quantity); buf.writeUniqueId(playerUuid); } public void handle(Supplier<NetworkEvent.Context> context) { context.get().enqueueWork(() -> { PlayerEntity player = Minecraft.getInstance().player.world.getPlayerByUuid(playerUuid); if(player != null) { IPlayerData cap = PlayerData.getPlayerData(player); cap.setPoints(quantity); } }); context.get().setPacketHandled(true); } } Main class: private void setup(final FMLCommonSetupEvent event) { registerCapabilities(); Handler.register(); }
  19. Hi, i'm trying to update my mod to 1.15.2, but i have a problem replacing the renderer, I don't know one of the parameters of doRender() doRender(AbstractClientPlayerEntity, float, float, MatrixStack, IRenderTypeBuffer, int) i know the integer is getLight and one of the floats is getPartialRenderTick but i don't know which one is the other float.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.