Jump to content

Yurim64

Members
  • Posts

    103
  • Joined

  • Last visited

Everything posted by Yurim64

  1. Ok, I have updated IntelliJ, but now when I try to run the runClient configuration I get: Invalid value: -1 On: prepareRunClient
  2. I used the Introduction here: https://mcforge.readthedocs.io/en/1.18.x/gettingstarted/ My IntelliJ Version is 2019.1
  3. Hi, im setting up a mod in 1.18.2, but when i try to launch the Minecraft Client im getting this error: Exception in thread "main" java.lang.reflect.InaccessibleObjectException: Unable to make public static void cpw.mods.bootstraplauncher.BootstrapLauncher.main(java.lang.String[]) accessible: module cpw.mods.bootstraplauncher does not "exports cpw.mods.bootstraplauncher" to unnamed module @726f3b58 at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199) at java.base/java.lang.reflect.Method.setAccessible(Method.java:193) at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:130) Anyone can help me?
  4. Hi, I was following the 1.18.2 minecraft modding introduction, and when I import the build.gradle file to IntelliJ, I get this warning: Warning:<i><b>root project 'TikTokMod': Unable to build MinecraftDev MCP project configuration</b> Details: groovy.lang.MissingPropertyException: Could not get unknown property 'genSrgs' for task set of type org.gradle.api.internal.tasks.DefaultTaskContainer.</i> plus it doesn't detect any tasks for setting up my mod. How can I solve the problem?
  5. Ok so, i changed the entity in this way: public class SmokeBulletEntity extends DamagingProjectileEntity implements IRendersAsItem { private static final DataParameter<Boolean> ACTIVATED = EntityDataManager.defineId(SmokeBulletEntity.class, DataSerializers.BOOLEAN); private static final ItemStack STACK = new ItemStack(ModItems.BULLET.get()); private int duration; public SmokeBulletEntity(World world) { super(ModEntities.SMOKE_BULLET.get(), world); } @Override public ItemStack getItem() { return STACK; } @Override protected void onHitBlock(BlockRayTraceResult rayTraceResult) { if (this.isActivated()) return; if (!this.level.isClientSide) { this.activate(); } super.onHitBlock(rayTraceResult); } @Override protected void onHitEntity(EntityRayTraceResult entityRayTraceResult) { //Must be Empty } private void activate() { this.setActivated(true); this.duration = 200; this.setDeltaMovement(0, 0, 0); this.xPower = 0; this.yPower = 0; this.zPower = 0; System.out.println("Active Smoke Projectile"); } @Override public void tick() { if (this.isActivated()) { for (int i = 0; i < 100; i++) { this.level.addParticle(ParticleTypes.FLAME, this.getX(), this.getY() + i, this.getZ(), 0, 0, 0); } this.duration--; if (this.duration <= 0) { this.remove(); } } else { super.tick(); } } @Override public void addAdditionalSaveData(CompoundNBT nbt) { super.addAdditionalSaveData(nbt); nbt.putBoolean("activated", this.isActivated()); nbt.putInt("duration", this.duration); } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.set(ACTIVATED, false); } public void setActivated(boolean activated) { this.entityData.set(ACTIVATED, activated); } public boolean isActivated() { return this.entityData.get(ACTIVATED); } @Override public EntityDataManager getEntityData() { return super.getEntityData(); } @Override public void readAdditionalSaveData(CompoundNBT nbt) { super.readAdditionalSaveData(nbt); if (nbt.contains("activated")) { this.setActivated(nbt.getBoolean("activated")); } if (nbt.contains("duration")) { this.duration = nbt.getInt("duration"); } } @Override public IPacket<?> getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } } But now, when i spawn it i encounter this error: [15:39:10] [Server thread/FATAL] [minecraft/ThreadTaskExecutor]: Error executing task on Server java.lang.NullPointerException: null at net.minecraft.network.datasync.EntityDataManager.set(EntityDataManager.java:122) ~[forge:?] {re:classloading} at com.ike.gunmod.entity.SmokeBulletEntity.defineSynchedData(SmokeBulletEntity.java:93) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.entity.Entity.<init>(Entity.java:216) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.entity.projectile.ProjectileEntity.<init>(ProjectileEntity.java:25) ~[forge:?] {re:classloading} at net.minecraft.entity.projectile.DamagingProjectileEntity.<init>(DamagingProjectileEntity.java:26) ~[forge:?] {re:classloading} at com.ike.gunmod.entity.SmokeBulletEntity.<init>(SmokeBulletEntity.java:35) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at com.ike.gunmod.item.gun.SmokeGunItem.getBullet(SmokeGunItem.java:32) ~[?:?] {re:classloading} at com.ike.gunmod.item.gun.AbstractGunItem.use(AbstractGunItem.java:42) ~[?:?] {re:classloading} at net.minecraft.item.ItemStack.use(ItemStack.java:217) ~[forge:?] {re:classloading,xf:fml:forge:filled_map.4,xf:fml:forge:itemstack} at net.minecraft.server.management.PlayerInteractionManager.useItem(PlayerInteractionManager.java:287) ~[forge:?] {re:classloading} at net.minecraft.network.play.ServerPlayNetHandler.handleUseItem(ServerPlayNetHandler.java:982) ~[forge:?] {re:classloading} at net.minecraft.network.play.client.CPlayerTryUseItemPacket.handle(CPlayerTryUseItemPacket.java:28) ~[forge:?] {re:classloading} at net.minecraft.network.play.client.CPlayerTryUseItemPacket.handle(CPlayerTryUseItemPacket.java:9) ~[forge:?] {re:classloading} at net.minecraft.network.PacketThreadUtil.lambda$ensureRunningOnSameThread$0(PacketThreadUtil.java:19) ~[forge:?] {re:classloading} at net.minecraft.util.concurrent.TickDelayedTask.run(TickDelayedTask.java:17) ~[forge:?] {re:classloading} at net.minecraft.util.concurrent.ThreadTaskExecutor.doRunTask(ThreadTaskExecutor.java:136) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.RecursiveEventLoop.doRunTask(RecursiveEventLoop.java:22) ~[forge:?] {re:classloading} at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:734) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:159) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.ThreadTaskExecutor.pollTask(ThreadTaskExecutor.java:109) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:717) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:711) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.util.concurrent.ThreadTaskExecutor.managedBlock(ThreadTaskExecutor.java:119) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:697) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:646) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:232) ~[forge:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Thread.java:748) [?:1.8.0_231] {} Why this happen?
  6. How can i set the data on the client side? The methods Entity#addAdditionalSaveData and Entity#readAdditionalSaveData doesn't do that?
  7. Ok so, i changed the function Entity#tick public void tick() { if (this.activated) { for (int i = 0; i < 100; i++) { this.level.addParticle(ParticleTypes.FLAME, this.getX(), this.getY() + i, this.getZ(), 0, 0, 0); } this.duration--; if (this.duration <= 0) { this.remove(); } } else { super.tick(); } } But still the bullet does not show the particles. There are only those of the basic bullet: Why this happen?
  8. Ok, so where do i put the code for spawning particle?
  9. Hi! I was trying to create a smoke projectile, that when hits the ground spawn some particles for a certain duration. The problem is that, when the entity hits the ground, it don't spawn the particles at all. Here is my projectile: @OnlyIn(value = Dist.CLIENT, _interface = IRendersAsItem.class) public class SmokeBulletEntity extends DamagingProjectileEntity implements IRendersAsItem { private static final ItemStack STACK = new ItemStack(ModItems.BULLET.get()); private boolean activated; private int duration; public SmokeBulletEntity(World world) { super(ModEntities.SMOKE_BULLET.get(), world); this.activated = false; } @Override public ItemStack getItem() { return STACK; } @Override protected void onHitBlock(BlockRayTraceResult rayTraceResult) { if (this.activated) return; if (!this.level.isClientSide) { this.activate(); } super.onHitBlock(rayTraceResult); } @Override protected void onHitEntity(EntityRayTraceResult entityRayTraceResult) { //Must be Empty } private void activate() { this.activated = true; this.duration = 200; this.setDeltaMovement(0, 0, 0); this.xPower = 0; this.yPower = 0; this.zPower = 0; System.out.println("Active Smoke Projectile"); } @Override public void tick() { if (this.activated && !this.level.isClientSide) { //System.out.println(String.format("%f, %f, %f", this.getX(), this.getY(), this.getZ())); for (int i = 0; i < 100; i++) { this.level.addParticle(ParticleTypes.FLAME, this.getX(), this.getY() + i, this.getZ(), 0, 0, 0); } this.duration--; if (this.duration <= 0) { this.remove(); } } else { super.tick(); } } @Override public void addAdditionalSaveData(CompoundNBT nbt) { super.addAdditionalSaveData(nbt); nbt.putBoolean("activated", this.activated); nbt.putInt("duration", this.duration); } @Override public void readAdditionalSaveData(CompoundNBT nbt) { super.readAdditionalSaveData(nbt); if (nbt.contains("activated")) { this.activated = nbt.getBoolean("activated"); } if (nbt.contains("duration")) { this.duration = nbt.getInt("duration"); } } @Override public IPacket<?> getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } } Can somebody explain me why? Thanks!
  10. Oh, I need to register the Effect? Not finding the EFFECT tag in ForgeRegistries I thought I shouldn't register them. How can I register an effect?
  11. Hi! I was trying to reate a custom effect, and it works properly except for a little thing. When im on the Inventory of the Player, it doesn't render at all, how can i do? I see that there is a method called "renderHUDEffect(...)", but i don't know how to use it. Someone can help me? This is my Effect Class: public class ColorEffect extends Effect { private final String colorName; private final String descriptionId; public ColorEffect(String colorName, int color) { super(EffectType.HARMFUL, color); this.colorName = colorName; this.descriptionId = "color.effect." + colorName; } @Override public void applyEffectTick(LivingEntity entity, int amplifier) { if (entity instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) entity; if (amplifier <= 0) { player.removeEffect(this); return; } player.causeFoodExhaustion(0.5f); player.addEffect(new EffectInstance(this, 2000, amplifier)); } } @Override public boolean isDurationEffectTick(int duration, int amplifier) { return true; } public String getColorName() { return colorName; } @Override public ITextComponent getDisplayName() { return new TranslationTextComponent("colorfood.effect." + this.colorName); } public String getOrCreateDescriptionId() { return this.descriptionId; } } Thanks!
  12. Hi! I wandering if there is a way to change the behavior of the minecraft vanilla mob. My idea is to add a bed for the cat, and when the cat is damaged or he simply wants to sleep, goes into the bed. There is a way to add this behavior to the vanilla cat?
  13. Oh thanks, now it works properly
  14. Ok, sorry for the late answer, but there is no trackIntAray method in my Container class. I need to implement the method in another way or something else?
  15. Hi! I was creating a simil-furnace block with his own TileEntity, Gui and Container. While creating it, I see the vanilla code and noticed that the FurnaceScreen scall read the lit progress by the FurnaceContainer, that stores the data by an IIntArray object. I tryed to recreate this scenario, but my IIntArray is not syncronized with the TileEntity... any suggestions? Here is the classes: The Block: The TileEntity: The Container: The Gui: The problem is that the function getTimer should call the IIntArray object of the HobTileEntity, but it seems to be only the default value from the method HobContainer.defaultContainer(int id, PlayerInventory player); Someone has any idea?
  16. Ok and where do i set the Tag? There is some method when create the itemstack or something similar?
  17. Ok so, how can i add NBT data to an item now?
  18. Hi! I was adding some NBT data to some custom items, but no data is saved inside. Doing a bit of debugging I found that the readShareTag and getShareTag methods were not being invoked. This is the Item Class: public abstract class AbstractGunItem extends Item { public AbstractGunItem() { super(new Item.Properties().tab(ItemGroup.TAB_COMBAT)); } @Override public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) { if (world instanceof ServerWorld) { ItemStack stack = player.inventory.getSelected(); if (stack.getItem() instanceof AbstractGunItem) { int ammo = GunProperties.getAmmo(stack); if (ammo > 0 || player.isCreative()) { GunProperties.removeBullet(stack); player.getCooldowns().addCooldown(this, GunProperties.getFireRate(stack)); Vector3d vector3d = player.getViewVector(1.0f); BulletEntity bullet = new BulletEntity(world); bullet.setOwner(player); bullet.xPower = vector3d.x; bullet.yPower = vector3d.y; bullet.zPower = vector3d.z; bullet.setDamage(GunProperties.getDamage(stack)); bullet.setPos(player.getX() + vector3d.x, player.getY() + player.getEyeHeight(), player.getZ() + vector3d.z); bullet.setDeltaMovement(vector3d); world.addFreshEntity(bullet); if (GunProperties.getAmmo(stack) <= 0 && GunProperties.canAutoRefill(stack)) { this.refill(player, stack); } return ActionResult.consume(player.inventory.getSelected()); } } } return super.use(world, player, hand); } @Override public UseAction getUseAnimation(ItemStack stack) { return UseAction.SPEAR; } @Nullable @Override public CompoundNBT getShareTag(ItemStack stack) { CompoundNBT shareTag = super.getShareTag(stack); if (shareTag == null) { shareTag = new CompoundNBT(); } GunProperties properties = getGunProperties(stack); GunProperties.addProperties(shareTag, properties); return shareTag; } @Override public void readShareTag(ItemStack stack, @Nullable CompoundNBT nbt) { super.readShareTag(stack, nbt); if (nbt == null) { System.out.println("Invalid NBT for abstract gun item " + stack.getItem()); } } @Nonnull public abstract GunProperties defaultGunProperties(); private GunProperties getGunProperties(ItemStack stack) { System.out.println("Getting Properties from " + stack); GunProperties properties = GunProperties.getProperties(stack); GunProperties defaultProperties = defaultGunProperties(); if (properties.getMaxAmmo() == 0) properties = properties.maxAmmo(defaultProperties.getMaxAmmo()); if (properties.getFireRate() == 0) properties = properties.fireRate(defaultProperties.getFireRate()); if (properties.getDamage() == 0) properties = properties.damage(defaultProperties.getDamage()); System.out.println(properties); return properties; } @Override public boolean showDurabilityBar(ItemStack stack) { return true; } @Override public double getDurabilityForDisplay(ItemStack stack) { double d = 1.0; double r = GunProperties.getAmmo(stack) / (double) GunProperties.getMaxAmmo(stack); return d - r; } public void refill(PlayerEntity player, ItemStack stack) { boolean flag = false; PlayerInventory inventory = player.inventory; int size = inventory.getContainerSize(); for (int i = 0; i < size; i++) { ItemStack item = inventory.getItem(i); if (item.getItem() instanceof Bullet) { flag = true; int count = item.getCount(); int remain = GunProperties.refill(stack, count); item.setCount(remain); } if (GunProperties.getAmmo(stack) == GunProperties.getMaxAmmo(stack)) { System.out.println(GunProperties.getAmmo(stack) + "/" + GunProperties.getMaxAmmo(stack)); if (flag) player.getCooldowns().addCooldown(this, 20); return; } } if (flag) player.getCooldowns().addCooldown(this, 20); } @Override public int getItemStackLimit(ItemStack stack) { return 1; } } And this is the Properties Class: public class GunProperties { private int maxAmmo; private int ammo; private float damage; private int fireRate; public GunProperties() { this.maxAmmo = 0; this.ammo = 0; this.damage = 0; this.fireRate = 0; } public static boolean canAutoRefill(ItemStack stack) { return stack.getItem() instanceof SniperItem; } public GunProperties maxAmmo(int maxAmmo) { this.maxAmmo = maxAmmo; return this; } public GunProperties damage(float damage) { this.damage = damage; return this; } public GunProperties fireRate(int fireRate) { this.fireRate = fireRate; return this; } public int getMaxAmmo() { return maxAmmo; } public float getDamage() { return damage; } public int getFireRate() { return fireRate; } @Override public String toString() { return "GunProperties{" + "maxAmmo=" + maxAmmo + ", ammo=" + ammo + ", damage=" + damage + ", fireRate=" + fireRate + '}'; } public static final String MAX_AMMO = "maxAmmo"; public static final String AMMO = "ammo"; public static final String DAMAGE = "damage"; public static final String FIRE_RATE = "fireRate"; public static void addProperties(ItemStack stack, GunProperties properties) { CompoundNBT tag = stack.getOrCreateTag(); addProperties(tag, properties); } public static void addProperties(CompoundNBT tag, GunProperties properties) { tag.putInt(MAX_AMMO, properties.maxAmmo); tag.putInt(AMMO, properties.ammo); tag.putFloat(DAMAGE, properties.damage); tag.putInt(FIRE_RATE, properties.fireRate); } public static GunProperties getProperties(ItemStack stack) { CompoundNBT tag = stack.getOrCreateTag(); GunProperties properties = new GunProperties(); if (tag.contains(MAX_AMMO)) { properties.maxAmmo = tag.getInt(MAX_AMMO); } if (tag.contains(AMMO)) { properties.ammo = tag.getInt(AMMO); } if (tag.contains(DAMAGE)) { properties.damage = tag.getFloat(DAMAGE); } if (tag.contains(FIRE_RATE)) { properties.fireRate = tag.getInt(FIRE_RATE); } return properties; } public static int getMaxAmmo(ItemStack stack) { CompoundNBT tag = stack.getOrCreateTag(); if (tag.contains(MAX_AMMO)) { return tag.getInt(MAX_AMMO); } return 0; } public static int getAmmo(ItemStack stack) { CompoundNBT tag = stack.getOrCreateTag(); if (tag.contains(AMMO)) { return tag.getInt(AMMO); } return 0; } public static float getDamage(ItemStack stack) { CompoundNBT tag = stack.getOrCreateTag(); if (tag.contains(DAMAGE)) { return tag.getFloat(DAMAGE); } return 0; } public static int getFireRate(ItemStack stack) { CompoundNBT tag = stack.getOrCreateTag(); if (tag.contains(FIRE_RATE)) { return tag.getInt(FIRE_RATE); } return 0; } public static int refill(ItemStack stack, int amount) { CompoundNBT tag = stack.getOrCreateTag(); System.out.println(tag); int rest = 0; if (tag.contains(MAX_AMMO) && tag.contains(AMMO)) { System.out.println(tag.getInt(AMMO)); int maxAmmo = tag.getInt(MAX_AMMO); int ammo = tag.getInt(AMMO); ammo += amount; if (ammo > maxAmmo) { rest = ammo - maxAmmo; ammo = maxAmmo; } tag.putInt(AMMO, ammo); } return rest; } public static void removeBullet(ItemStack stack) { removeBullet(stack, 1); } public static void removeBullet(ItemStack stack, int amount) { CompoundNBT tag = stack.getOrCreateTag(); if (tag.contains(AMMO)) { int ammo = tag.getInt(AMMO); ammo -= amount; if (ammo < 0) ammo = 0; tag.putInt(AMMO, ammo); } } } Can someone help me? Thanks.
  19. Omg it works, thanks and sorry for my insistent.
  20. Ooooh ok, now i try the solution and see. Thank you so much.
  21. The Item: public class Bullet extends Item { public Bullet() { super(new Item.Properties().tab(ItemGroup.TAB_COMBAT)); } } The Entity: public class BulletEntity extends DamagingProjectileEntity implements IRendersAsItem { private static final ItemStack STACK = new ItemStack(ModItems.BULLET.get()); private int damage; public BulletEntity(World world) { super(ModEntities.BULLET.get(), world); } @Override public ItemStack getItem() { return STACK; } @Override public void setOwner(@Nullable Entity owner) { super.setOwner(owner); } @Override protected void onHitBlock(BlockRayTraceResult p_230299_1_) { super.onHitBlock(p_230299_1_); if (!this.level.isClientSide) { this.remove(); } } @Override protected void onHitEntity(EntityRayTraceResult entityRayTraceResult) { super.onHitEntity(entityRayTraceResult); if (!this.level.isClientSide) { Entity entity = entityRayTraceResult.getEntity(); DamageSource source = new DamageSource("bullet"); source = source.setProjectile(); entity.hurt(source, this.damage); this.remove(); } } @Override public void tick() { super.tick(); } @Override public void addAdditionalSaveData(CompoundNBT nbt) { super.addAdditionalSaveData(nbt); nbt.putInt("bulletDamage", this.damage); } @Override public void readAdditionalSaveData(CompoundNBT nbt) { super.readAdditionalSaveData(nbt); if (nbt.contains("bulletDamage")) { this.damage = nbt.getInt("bulletDamage"); } } public void setDamage(int damage) { this.damage = damage; } @Override public IPacket<?> getAddEntityPacket() { return super.getAddEntityPacket(); } } The Entity Renderer: public class BulletRender<T extends BulletEntity> extends EntityRenderer<T> { public BulletRender(EntityRendererManager manager) { super(manager); } @Override public void render(T entity, float f1, float f2, MatrixStack matrix, IRenderTypeBuffer buffer, int light) { super.render(entity, f1, f2, matrix, buffer, light); System.out.println("Render"); RenderUtil.renderColoredModel(SpecialModels.BULLET.getModel(), ItemCameraTransforms.TransformType.NONE, false, matrix, buffer, light, OverlayTexture.NO_OVERLAY); } @Override public boolean shouldRender(T p_225626_1_, ClippingHelper p_225626_2_, double p_225626_3_, double p_225626_5_, double p_225626_7_) { return true; } @Override public ResourceLocation getTextureLocation(T p_110775_1_) { return null; } } Tell me if you need something else.
  22. Ok so, i tried to use the perspctive, but it works only for the item bullet. Again, the BulletEntity is not rendered, And I don't know what to do or how to do it anymore.
  23. This is the Renderer Class: public class BulletRender<T extends BulletEntity> extends EntityRenderer<T> { public BulletRender(EntityRendererManager manager) { super(manager); } @Override public void render(T entity, float f1, float f2, MatrixStack matrix, IRenderTypeBuffer buffer, int light) { super.render(entity, f1, f2, matrix, buffer, light); System.out.println("Render"); RenderUtil.renderColoredModel(SpecialModels.BULLET.getModel(), ItemCameraTransforms.TransformType.NONE, false, matrix, buffer, light, OverlayTexture.NO_OVERLAY); } @Override public boolean shouldRender(T p_225626_1_, ClippingHelper p_225626_2_, double p_225626_3_, double p_225626_5_, double p_225626_7_) { return true; } @Override public ResourceLocation getTextureLocation(T p_110775_1_) { return null; } } The print is not shown on the console, as if the method is never invoked. Now i try with the perspective, thanks
×
×
  • Create New...

Important Information

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