Jump to content

Narlecks

Members
  • Posts

    21
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Narlecks's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  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. 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"); } } } }
  12. 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
×
×
  • Create New...

Important Information

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