Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

<Gl33p_0r4nge>

Members
  • Posts

    17
  • Joined

  • Last visited

Recent Profile Visitors

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

<Gl33p_0r4nge>'s Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hi I have one problem I dont know why but for some reason I cant change blockstate. Here is the LeadCoating.java: package me.gleep.oreganized.blocks; import me.gleep.oreganized.util.RegistryHandler; import net.minecraft.block.*; import net.minecraft.block.material.Material; import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; import net.minecraft.state.BooleanProperty; import net.minecraft.state.IntegerProperty; import net.minecraft.state.StateContainer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.ToolType; import org.jetbrains.annotations.Nullable; import java.util.Random; public class LeadCoating extends Block { public static final int RANGE = 4; public static final IntegerProperty LEVEL = IntegerProperty.create("water_level", 0, 3); public static final IntegerProperty HEIGHT = IntegerProperty.create("base_height", 0, 255); public static final BooleanProperty IS_BASE = BooleanProperty.create("is_base"); public LeadCoating() { super(Properties.create(Material.IRON) .hardnessAndResistance(4.0F, 5.0F) .harvestTool(ToolType.PICKAXE) .setRequiresTool() .harvestLevel(1) .sound(SoundType.METAL)); this.setDefaultState(this.stateContainer.getBaseState().with(LEVEL, Integer.valueOf(0)).with(IS_BASE, false).with(HEIGHT, Integer.valueOf(0))); } /** * Called by ItemBlocks after a block is set in the world, to allow post-place logic */ @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { BlockPos basePos = pos.down(); while (worldIn.getBlockState(basePos).getBlock().equals(RegistryHandler.LEAD_COATING.get())) basePos = basePos.down(); basePos = basePos.up(); BlockPos topPos = basePos.up(); while (worldIn.getBlockState(topPos).getBlock().equals(RegistryHandler.LEAD_COATING.get())) { worldIn.setBlockState(topPos, worldIn.getBlockState(topPos).with(IS_BASE, false).with(HEIGHT, basePos.getY()), 2); topPos = topPos.up(); } topPos = topPos.down(); BlockState baseState = worldIn.getBlockState(basePos).with(IS_BASE, true).with(HEIGHT, topPos.getY()); worldIn.setBlockState(basePos, baseState, 2); } /** * Called after a player destroys this Block - the position pos may no longer hold the state indicated. */ @Override public void onPlayerDestroy(IWorld worldIn, BlockPos pos, BlockState state) { if (worldIn.getBlockState(pos.up()).getBlock().equals(RegistryHandler.LEAD_COATING.get())) { worldIn.getBlockState(pos.up()).getBlock().onBlockPlacedBy((World)worldIn, pos.up(), worldIn.getBlockState(pos.up()), null, ItemStack.EMPTY); } if (worldIn.getBlockState(pos.down()).getBlock().equals(RegistryHandler.LEAD_COATING.get())) { worldIn.getBlockState(pos.down()).getBlock().onBlockPlacedBy((World)worldIn, pos.down(), worldIn.getBlockState(pos.down()), null, ItemStack.EMPTY); } } @Override protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) { builder.add(LEVEL).add(IS_BASE).add(HEIGHT); } @Override public boolean ticksRandomly(BlockState state) { return true; } /** * Performs a random tick on a block. */ @Override public void randomTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) { this.tick(state, worldIn, pos, random); } @Override public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random rand) { if (state.get(IS_BASE) && state.get(LEVEL) == 3) { fertilize((World) worldIn, pos, state); } } @Override public void fillWithRain(World worldIn, BlockPos pos) { float f = worldIn.getBiome(pos).getTemperature(pos); if (!(f < 0.15F)) { BlockState state = worldIn.getBlockState(pos); BlockPos basePos = new BlockPos(pos.getX(), state.get(HEIGHT), pos.getZ()); BlockState baseState = worldIn.getBlockState(basePos); if (!flow(worldIn, basePos, baseState)) { worldIn.setBlockState(pos, state.with(LEVEL, Integer.valueOf(state.get(LEVEL) + 1))); } } } public void fertilize(World world, BlockPos pos, BlockState blockState) { int minY = pos.getY(); int maxY = blockState.get(HEIGHT); for (int i = minY; i <= maxY; i++) { int rndX = world.getRandom().nextInt(RANGE * 2) - 4; int rndZ = world.getRandom().nextInt(RANGE * 2) - 4; BlockPos pos1 = new BlockPos(pos.getX() + rndX, i - 1, pos.getZ() + rndZ); BlockState state1 = world.getBlockState(pos1); BlockPos leadPos = new BlockPos(pos.getX(), i, pos.getZ()); BlockState leadState = world.getBlockState(leadPos); for (int j = leadState.get(LEVEL); j > 0; j--) { if (state1.getBlock() instanceof IGrowable) { IGrowable igrowable = (IGrowable) state1.getBlock(); if (igrowable.canGrow(world, pos1, state1, world.isRemote)) { if (world instanceof ServerWorld) { if (igrowable.canUseBonemeal(world, world.rand, pos1, state1)) { igrowable.grow((ServerWorld) world, world.rand, pos1, state1); world.setBlockState(leadPos, leadState.with(LEVEL, Integer.valueOf(leadState.get(LEVEL) - 1)), 2); } } } } } } } public boolean flow(World world, BlockPos pos, BlockState blockState) { if (blockState.get(IS_BASE)) { if (pos.getY() > blockState.get(HEIGHT)) return false; if (world.getBlockState(pos).get(LEVEL) == 3) { return flow(world, pos.up(), blockState); } else { BlockState prevState = world.getBlockState(pos); world.setBlockState(pos, prevState.with(LEVEL, Integer.valueOf(prevState.get(LEVEL) + 1)), 2); return true; } } return false; } /** * @deprecated call via {@link BlockState#hasComparatorInputOverride()} whenever possible. Implementing/overriding * is fine. */ @Override public boolean hasComparatorInputOverride(BlockState state) { return true; } /** * @deprecated call via {@link IBlockState#getComparatorInputOverride(World, BlockPos)} whenever possible. * Implementing/overriding is fine. */ @Override public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { return blockState.get(LEVEL); } } The block has three properties: height (if is_base == true then its the height of the most top block in the pillar else its the height of the base block); is_base (if this is the base block); water_level (amount of water in the block); And the problem is that it change the water level of base block and the top block but I cant change the water level of the blocks between. So my guess is that i have something wrong in the flow function but I tried almost everything and it just doesnt work. EDIT: Well I found out that it always bonemeals the grass and that means it seemed to not work. Sorry for bothering.
  2. yes thanks now it works. But I have another problem it spawns but its not animated. it always spawns the first particle in the list EDIT: nevermind I solved it i just had to do it manualy in the tick. again thanks for help
  3. Hi I have a little problem. Im trying to replace potion particles with my custom. So I looked on how to do this. I have the Particle class: package me.gleep.oreganized.particles; import net.minecraft.client.particle.*; import net.minecraft.client.world.ClientWorld; import net.minecraft.particles.BasicParticleType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Random; public class DawnShineParticle extends SpriteTexturedParticle { private static final Random RANDOM = new Random(); private final IAnimatedSprite spriteWithAge; protected DawnShineParticle(ClientWorld world, double x, double y, double z, double motionX, double motionY, double motionZ, IAnimatedSprite spriteWithAge) { super(world, x, y, z, 0.5D - RANDOM.nextDouble(), motionY, 0.5D - RANDOM.nextDouble()); this.spriteWithAge = spriteWithAge; this.motionY *= (double)0.2F; if (motionX == 0.0D && motionZ == 0.0D) { this.motionX *= (double)0.1F; this.motionZ *= (double)0.1F; } this.particleScale *= 0.75F; this.maxAge = (int)(10.0D / (Math.random() * 0.8D + 0.2D)); this.canCollide = false; this.selectSpriteWithAge(spriteWithAge); } @NotNull @Override public IParticleRenderType getRenderType() { return IParticleRenderType.PARTICLE_SHEET_LIT; } public static class Factory implements IParticleFactory<BasicParticleType> { private final IAnimatedSprite spriteSet; public Factory(IAnimatedSprite spriteSet) { this.spriteSet = spriteSet; } @Nullable @Override public Particle makeParticle(BasicParticleType typeIn, ClientWorld worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { return new DawnShineParticle(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet); } } } I have registered it: (I have other registrations in one class so I dont want to copy the whole class. If you want me to I can post it later) public static final RegistryObject<ParticleType<BasicParticleType>> DAWN_SHINE_PARTICLE = PARTICLES.register("dawn_shine", () -> new BasicParticleType(false)); and another registration which I dont clearly understand: private void doClientStuff(final FMLClientSetupEvent event) { Minecraft.getInstance().particles.registerFactory(RegistryHandler.DAWN_SHINE_PARTICLE.get(), DawnShineParticle.Factory::new); } Then I made inside assets/<modid>/particles dawn_shine.json: { "textures": [ "oreganized:dawn_shine_0", "oreganized:dawn_shine_1", "oreganized:dawn_shine_2", "oreganized:dawn_shine_3", "oreganized:dawn_shine_4", "oreganized:dawn_shine_5", "oreganized:dawn_shine_6", "oreganized:dawn_shine_7", "oreganized:dawn_shine_8", "oreganized:dawn_shine_9" ] } and place the textures in assets/<modid>/textures/particle : and got this error: [10:24:15] [Render thread/FATAL] [minecraft/Minecraft]: Reported exception thrown! net.minecraft.crash.ReportedException: Rendering overlay at net.minecraft.client.renderer.GameRenderer.updateCameraAndRender(GameRenderer.java:499) ~[forge-1.16.4-35.1.5_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1002) ~[forge-1.16.4-35.1.5_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:612) ~[forge-1.16.4-35.1.5_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.4-35.1.5_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_162] {} at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_162] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_162] {} at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_162] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.4-35.1.5_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.6.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.6.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.6.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.6.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.6.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.4-35.1.5_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {} Caused by: java.lang.IllegalStateException: Redundant texture list for particle oreganized:dawn_shine at net.minecraft.client.particle.ParticleManager.loadTextureLists(ParticleManager.java:217) ~[?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.particle.ParticleManager.lambda$null$0(ParticleManager.java:169) ~[?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at java.util.concurrent.CompletableFuture$AsyncRun.run$$$capture(CompletableFuture.java:1626) ~[?:1.8.0_162] {} at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java) ~[?:1.8.0_162] {} at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1618) ~[?:1.8.0_162] {} at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[?:1.8.0_162] {} at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) ~[?:1.8.0_162] {} at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) ~[?:1.8.0_162] {} at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[?:1.8.0_162] {} Anyone know what happend? I really dont know
  4. Yes thanks it works now: BTW in console I got this: [09:44:59] [Render thread/ERROR] [minecraft/Util]: No data fixer registered for shrapnel_tnt is it something I should worry about?
  5. So I have the following: ShrapnelTNTEntity: package me.gleep.oreganized.entities; import me.gleep.oreganized.util.RegistryHandler; import net.minecraft.entity.*; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.IPacket; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.network.play.server.SSpawnObjectPacket; import net.minecraft.particles.ParticleTypes; import net.minecraft.world.Explosion; import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; public class ShrapnelTNTEntity extends Entity { private static final DataParameter<Integer> FUSE = EntityDataManager.createKey(ShrapnelTNTEntity.class, DataSerializers.VARINT); @Nullable private LivingEntity tntPlacedBy; private int fuse = 100; public ShrapnelTNTEntity(EntityType<? extends ShrapnelTNTEntity> entityTypeIn, World worldIn) { super(entityTypeIn, worldIn); this.preventEntitySpawning = true; } public ShrapnelTNTEntity(World worldIn, double x, double y, double z, @Nullable LivingEntity igniter) { this(RegistryHandler.SHRAPNEL_TNT_ENTITY.get(), worldIn); this.setPosition(x, y, z); double d0 = worldIn.rand.nextDouble() * (double)((float)Math.PI * 2F); this.setMotion(-Math.sin(d0) * 0.02D, (double)0.2F, -Math.cos(d0) * 0.02D); this.setFuse(100); this.prevPosX = x; this.prevPosY = y; this.prevPosZ = z; this.tntPlacedBy = igniter; } public void tick() { if (!this.hasNoGravity()) { this.setMotion(this.getMotion().add(0.0D, -0.04D, 0.0D)); } this.move(MoverType.SELF, this.getMotion()); this.setMotion(this.getMotion().scale(0.98D)); if (this.onGround) { this.setMotion(this.getMotion().mul(0.7D, -0.5D, 0.7D)); } --this.fuse; if (this.fuse <= 0) { this.remove(); if (!this.world.isRemote) { this.explode(); } } else { this.func_233566_aG_(); if (this.world.isRemote) { this.world.addParticle(ParticleTypes.SMOKE, this.getPosX(), this.getPosY() + 0.5D, this.getPosZ(), 0.0D, 0.0D, 0.0D); } } } protected void explode() { this.world.createExplosion(this, this.getPosX(), this.getPosYHeight(0.0625D), this.getPosZ(), 3.0F, Explosion.Mode.BREAK); } public void setFuse(int fuseIn) { this.dataManager.set(FUSE, fuseIn); this.fuse = fuseIn; } @Override protected boolean canTriggerWalking() { return false; } @Override public boolean canBeCollidedWith() { return !this.isAlive(); } public int getFuse() { return this.fuse; } @Override protected float getEyeHeight(Pose poseIn, EntitySize sizeIn) { return 0.15F; } @Override public void notifyDataManagerChange(DataParameter<?> key) { if (FUSE.equals(key)) { this.fuse = this.getFuseDataManager(); } } public int getFuseDataManager() { return this.dataManager.get(FUSE); } @Nullable public LivingEntity getTntPlacedBy() { return this.tntPlacedBy; } @Override protected void registerData() { this.dataManager.register(FUSE, 100); } @Override protected void readAdditional(CompoundNBT compound) { this.setFuse(compound.getShort("Fuse")); } @Override protected void writeAdditional(CompoundNBT compound) { compound.putShort("Fuse", (short)this.getFuse()); } @NotNull @Override public IPacket<?> createSpawnPacket() { return new SSpawnObjectPacket(this); } } ShrapnelTNTRenderer: package me.gleep.oreganized.entities.entityrenderer; import com.mojang.blaze3d.matrix.MatrixStack; import me.gleep.oreganized.entities.ShrapnelTNTEntity; import me.gleep.oreganized.util.RegistryHandler; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.entity.TNTMinecartRenderer; import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector3f; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.client.registry.IRenderFactory; import org.jetbrains.annotations.NotNull; @OnlyIn(Dist.CLIENT) public class ShrapnelTNTRenderer extends EntityRenderer<ShrapnelTNTEntity> { public ShrapnelTNTRenderer(EntityRendererManager renderManagerIn) { super(renderManagerIn); this.shadowSize = 0.5F; } @Override public void render(ShrapnelTNTEntity entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn) { matrixStackIn.push(); matrixStackIn.translate(0.0D, 0.5D, 0.0D); if ((float)entityIn.getFuse() - partialTicks + 1.0F < 10.0F) { float f = 1.0F - ((float)entityIn.getFuse() - partialTicks + 1.0F) / 10.0F; f = MathHelper.clamp(f, 0.0F, 1.0F); f = f * f; f = f * f; float f1 = 1.0F + f * 0.3F; matrixStackIn.scale(f1, f1, f1); } matrixStackIn.rotate(Vector3f.YP.rotationDegrees(-90.0F)); matrixStackIn.translate(-0.5D, -0.5D, 0.5D); matrixStackIn.rotate(Vector3f.YP.rotationDegrees(90.0F)); TNTMinecartRenderer.renderTntFlash(RegistryHandler.SHRAPNEL_TNT.get().getDefaultState(), matrixStackIn, bufferIn, packedLightIn, entityIn.getFuse() / 5 % 2 == 0); matrixStackIn.pop(); super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn); } @NotNull @Override public ResourceLocation getEntityTexture(ShrapnelTNTEntity entity) { return AtlasTexture.LOCATION_BLOCKS_TEXTURE; } } RegistryHandler: package me.gleep.oreganized.util; import me.gleep.oreganized.Oreganized; import me.gleep.oreganized.armors.*; import me.gleep.oreganized.blocks.*; import me.gleep.oreganized.entities.LeadNuggetEntity; import me.gleep.oreganized.entities.ShrapnelTNTEntity; import me.gleep.oreganized.entities.tileentities.ExposerBlockTileEntity; import me.gleep.oreganized.effects.*; import me.gleep.oreganized.fluids.*; import me.gleep.oreganized.items.*; import me.gleep.oreganized.tools.*; import net.minecraft.block.*; import net.minecraft.block.material.Material; import net.minecraft.client.gui.DisplayEffectsScreen; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.entity.EntityClassification; import net.minecraft.entity.EntityType; import net.minecraft.fluid.Fluid; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.*; import net.minecraft.potion.Effect; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.ToolType; import net.minecraftforge.fluids.ForgeFlowingFluid; import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; public class RegistryHandler { public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, Oreganized.MOD_ID); public static void init() { ENTITIES.register(FMLJavaModLoadingContext.get().getModEventBus()); //... } public static final RegistryObject<EntityType<ShrapnelTNTEntity>> SHRAPNEL_TNT_ENTITY = ENTITIES.register("shrapnel_tnt", () -> EntityType.Builder.<ShrapnelTNTEntity>create( ShrapnelTNTEntity::new, EntityClassification.MISC ).immuneToFire().size(0.98F, 0.98F).trackingRange(10).func_233608_b_(10).build("shrapnel_tnt") ); } And the renderer registration: private void doClientStuff(final FMLClientSetupEvent event) { RenderingRegistry.registerEntityRenderingHandler(RegistryHandler.SHRAPNEL_TNT_ENTITY.get(), ShrapnelTNTRenderer::new); } and the tnt itself works but the "exploding" entity does not render. I tried almost everything can anyone help me?
  6. Okay I see that no one probably know how but can you at least tell me where should I get the rendered player view?
  7. I have no idea how to do some screen rendering nor did something like this before. But I want to make something like nausea effect but little bit more than just portal effect. I want to do something that will get the actuall player view and make it flipped and mirror it and blend it with the players view so it will look something like this: And yes I want it to shake. plus I would like to render the particles like every effect should render. Thanks for any help
  8. Okay I know that what I did is horible but I look at it and rework it so now Im using the ObfuscationReflectionHelper and it works fine. But for the static final, I need to call it only once each time enitity spawns (or the world loads) so I think its not neccessary.
  9. OMG it works but not completly. It will probably be something with my code bcs I have never used predicates or reflections but I somehow managed to make it work (and Im proud of it 😆). So now I have problem with that when it is not "angry" on me and I have the armor its okay he don't even notice me but while he is targeting me and I equip the armor he is still following me and is trying to hit me. Here is the code: @SubscribeEvent public static void onEntityJoin(EntityJoinWorldEvent event){ if (event.getEntity().isLiving()) { LivingEntity living = (LivingEntity) event.getEntity(); if (living.isEntityUndead()) { MonsterEntity monster = (MonsterEntity) event.getEntity(); Field goalsField = null; try { goalsField = monster.targetSelector.getClass().getDeclaredField("goals"); goalsField.setAccessible(true); Set<PrioritizedGoal> goals = (Set<PrioritizedGoal>) goalsField.get(monster.targetSelector); for (PrioritizedGoal g : goals) { if (g.getGoal() instanceof NearestAttackableTargetGoal<?>){ NearestAttackableTargetGoal<?> goal = (NearestAttackableTargetGoal<?>) g.getGoal(); Field targetClassField = goal.getClass().getDeclaredField("targetClass"); targetClassField.setAccessible(true); Class<?> targetClass = (Class<?>) targetClassField.get(goal); if (targetClass == PlayerEntity.class || targetClass == ServerPlayerEntity.class) { Field targetESField = goal.getClass().getDeclaredField("targetEntitySelector"); targetESField.setAccessible(true); EntityPredicate targetEntitySelector = (EntityPredicate) targetESField.get(goal); targetEntitySelector.setCustomPredicate((target) -> { for (ItemStack itemStack : target.getArmorInventoryList()) { if (ItemTags.getCollection().getTagByID( new ResourceLocation("oreganized:silver_tinted_items")) .contains(itemStack.getItem())) return false; } return true; }); } } } } catch (NoSuchFieldException | IllegalAccessException noSuchFieldException) { noSuchFieldException.printStackTrace(); } } } } thanks for help!
  10. Hi maybe Im super dumb but I just cant find where to change/cancel what entity should be the mob attacking (I mean the thing when for example zombie follows you and attacks you) can someone tell me where can I find this and how to change the value to null or cancel the tracking? I just want to make mob neutral when Im wearing my custom mod armor. Thanks for any help.
  11. Nice now it is working that when I right click it changes to my cauldron and when I get the item out again by right clicking with bare hand it pops out and changing back to the vanilla cauldron. And my question is how can I check for source of fire under the cauldron (I maybe have idea just when event is fired on block (campfire) is placed) and how to change the content of the cauldron after some ticks (I have never worked with ticks and other related stuff)?
  12. Like if I put in lead block (which is from my mod) then put campfire/some source of fire under it, it melts. Like water it will have 3 "levels" that means that it will change texture from basic block to melted stage and to completly melted then the player could get it from the cauldron with bucket recieving lead bucket which I haven't created yet and tbh maybe you right about it not overriding the cauldron because with this I override the water colors which is controlled somwhere else as I guess.
  13. But I need interaction so I think It's better for me to create new Cauldron
  14. I looked in the forum and yeah it looks like forge really dont like overriding vanilla items/blocks with custom block states so I need to create my cauldron anyway: [10:22:41] [Render thread/ERROR] [ne.mi.re.GameData/REGISTRIES]: Registry replacements for vanilla block 'minecraft:cauldron' must not change the number or order of blockstates. Old: level={0,1,2,3} New: content={0,1,2};level={0,1,2,3} but still happy that I made it like this so it could actually work. Maybe in 1.17 there will be more support to adding custom fluids to cauldron as they add lava and other to cauldron Anyways thanks for help! for those who want to do the same thing as I want just simply do this (its just replacing the cauldron with your own cauldron when placed) : public class VanillaCauldron extends CauldronBlock { public VanillaCauldron() { super(AbstractBlock.Properties.create(Material.IRON, MaterialColor.STONE).setRequiresTool().hardnessAndResistance(2.0F).notSolid()); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { if (!worldIn.isRemote) { worldIn.removeBlock(pos, false); worldIn.setBlockState(pos, RegistryHandler.CAULDRON.get().getDefaultState()); } } } You want there put your registry class and the new name of the block (mine is CAULDRON): worldIn.setBlockState(pos, RegistryHandler.CAULDRON.get().getDefaultState()); then register it in registry like normal block except your modid replace with "minecraft" and then create your block also extending the vanilla one and here you can override add custom blockstatest as you wish and want. Then simply register it as block under your modid and there you go. Also dont forget to create json files EDIT: oh no Im dumb do this with the Cauldron Item then check when right click EDIT 2: wait just still testing it Yeah I was wrong just simply dont override it and with the BlockEvent.EntityPlaceEvent check for cauldron block
  15. ohhh, allright now I understatnd thats Registry: package me.gleep.oreexpansion.util; import me.gleep.oreexpansion.OreExpansion; import me.gleep.oreexpansion.armors.STAMaterial; import me.gleep.oreexpansion.armors.ArmorBase; import me.gleep.oreexpansion.blocks.*; import me.gleep.oreexpansion.blocks.tileentities.SilverBlockTileEntity; import me.gleep.oreexpansion.items.ItemBase; import me.gleep.oreexpansion.tools.STSMaterial; import me.gleep.oreexpansion.tools.STSBase; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.*; import net.minecraft.tileentity.TileEntityType; import net.minecraft.world.gen.blockstateprovider.BlockStateProviderType; import net.minecraftforge.client.model.generators.BlockStateProvider; import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; public class RegistryHandler { //Vanilla private static final DeferredRegister<Block> VANILLA_BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, "minecraft"); //Mod private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, OreExpansion.MOD_ID); private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, OreExpansion.MOD_ID); //private static final DeferredRegister<Fluid> FLUDIS = DeferredRegister.create(ForgeRegistries.FLUIDS, OreExpansion.MOD_ID); private static final DeferredRegister<TileEntityType<?>> TILE_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, OreExpansion.MOD_ID); //private static final DeferredRegister<IRecipeSerializer<?>> RECIPES = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, OreExpansion.MOD_ID); public static void init() { ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus()); //FLUDIS.register(FMLJavaModLoadingContext.get().getModEventBus()); TILE_ENTITY_TYPES.register(FMLJavaModLoadingContext.get().getModEventBus()); VANILLA_BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus()); } //Items public static final RegistryObject<Item> SILVER_INGOT = ITEMS.register("silver_ingot", ItemBase::new); public static final RegistryObject<Item> LEAD_INGOT = ITEMS.register("lead_ingot", ItemBase::new); public static final RegistryObject<Item> SILVER_NUGGET = ITEMS.register("silver_nugget", ItemBase::new); public static final RegistryObject<Item> LEAD_NUGGET = ITEMS.register("lead_nugget", ItemBase::new); public static final RegistryObject<Item> NETHERITE_NUGGET = ITEMS.register("netherite_nugget", () -> new ItemBase(true)); //public static final RegistryObject<Item> LEAD_BUCKET = ITEMS.register("lead_bucket", LeadBucket::new); //Blocks public static final RegistryObject<Block> SILVER_BLOCK = BLOCKS.register("silver_block", SilverBlock::new); public static final RegistryObject<Block> LEAD_BLOCK = BLOCKS.register("lead_block", LeadBlock::new); public static final RegistryObject<Block> SILVER_ORE = BLOCKS.register("silver_ore", SilverOre::new); public static final RegistryObject<Block> LEAD_ORE = BLOCKS.register("lead_ore", LeadOre::new); public static final RegistryObject<Block> CAULDRON = VANILLA_BLOCKS.register("cauldron", Cauldron::new); //Block Item public static final RegistryObject<Item> SILVER_BLOCK_ITEM = ITEMS.register("silver_block", () -> new BlockItemBase(SILVER_BLOCK.get())); public static final RegistryObject<Item> LEAD_BLOCK_ITEM = ITEMS.register("lead_block", () -> new BlockItemBase(LEAD_BLOCK.get())); public static final RegistryObject<Item> SILVER_ORE_ITEM = ITEMS.register("silver_ore", () -> new BlockItemBase(SILVER_ORE.get())); public static final RegistryObject<Item> LEAD_ORE_ITEM = ITEMS.register("lead_ore", () -> new BlockItemBase(LEAD_ORE.get())); //Fluids //public static final RegistryObject<FlowingFluidBlock> LEAD_FLUID = FLUDIS.register("lead_fluid", (); //Tile Entities public static final RegistryObject<TileEntityType<SilverBlockTileEntity>> SILVER_BLOCK_TE = TILE_ENTITY_TYPES.register("silver_block", () -> TileEntityType.Builder.create( SilverBlockTileEntity::new, SILVER_BLOCK.get()).build(null)); //Tools public static final RegistryObject<SwordItem> SILVER_TINTED_GOLDEN_SWORD = ITEMS.register("silver_tinted_golden_sword", () -> new STSBase(STSMaterial.STGS, 3, -2.4F)); public static final RegistryObject<SwordItem> SILVER_TINTED_DIAMOND_SWORD = ITEMS.register("silver_tinted_diamond_sword", () -> new STSBase(STSMaterial.STDS, 3, -2.4F)); public static final RegistryObject<SwordItem> SILVER_TINTED_NETHERITE_SWORD = ITEMS.register("silver_tinted_netherite_sword", () -> new STSBase(STSMaterial.STNS, 3, -2.4F, true)); //Armors public static final RegistryObject<ArmorItem> SILVER_TITNTED_GOLDEN_HELMET = ITEMS.register("silver_tinted_golden_helmet", () -> new ArmorBase(STAMaterial.STGA, EquipmentSlotType.HEAD)); public static final RegistryObject<ArmorItem> SILVER_TITNTED_GOLDEN_CHESTPLATE = ITEMS.register("silver_tinted_golden_chestplate", () -> new ArmorBase(STAMaterial.STGA, EquipmentSlotType.CHEST)); public static final RegistryObject<ArmorItem> SILVER_TITNTED_GOLDEN_LEGGINGS = ITEMS.register("silver_tinted_golden_leggings", () -> new ArmorBase(STAMaterial.STGA, EquipmentSlotType.LEGS)); public static final RegistryObject<ArmorItem> SILVER_TITNTED_GOLDEN_BOOTS = ITEMS.register("silver_tinted_golden_boots", () -> new ArmorBase(STAMaterial.STGA, EquipmentSlotType.FEET)); public static final RegistryObject<ArmorItem> SILVER_TITNTED_DIAMOND_HELMET = ITEMS.register("silver_tinted_diamond_helmet", () -> new ArmorBase(STAMaterial.STDA, EquipmentSlotType.HEAD)); public static final RegistryObject<ArmorItem> SILVER_TITNTED_DIAMOND_CHESTPLATE = ITEMS.register("silver_tinted_diamond_chestplate", () -> new ArmorBase(STAMaterial.STDA, EquipmentSlotType.CHEST)); public static final RegistryObject<ArmorItem> SILVER_TITNTED_DIAMOND_LEGGINGS = ITEMS.register("silver_tinted_diamond_leggings", () -> new ArmorBase(STAMaterial.STDA, EquipmentSlotType.LEGS)); public static final RegistryObject<ArmorItem> SILVER_TITNTED_DIAMOND_BOOTS = ITEMS.register("silver_tinted_diamond_boots", () -> new ArmorBase(STAMaterial.STDA, EquipmentSlotType.FEET)); public static final RegistryObject<ArmorItem> SILVER_TITNTED_NETHERITE_HELMET = ITEMS.register("silver_tinted_netherite_helmet", () -> new ArmorBase(STAMaterial.STNA, EquipmentSlotType.HEAD, true)); public static final RegistryObject<ArmorItem> SILVER_TITNTED_NETHERITE_CHESTPLATE = ITEMS.register("silver_tinted_netherite_chestplate", () -> new ArmorBase(STAMaterial.STNA, EquipmentSlotType.CHEST, true)); public static final RegistryObject<ArmorItem> SILVER_TITNTED_NETHERITE_LEGGINGS = ITEMS.register("silver_tinted_netherite_leggings", () -> new ArmorBase(STAMaterial.STNA, EquipmentSlotType.LEGS, true)); public static final RegistryObject<ArmorItem> SILVER_TITNTED_NETHERITE_BOOTS = ITEMS.register("silver_tinted_netherite_boots", () -> new ArmorBase(STAMaterial.STNA, EquipmentSlotType.FEET, true)); } like I haven't made change since I'm editing the cauldron and the main: package me.gleep.oreexpansion; import me.gleep.oreexpansion.util.RegistryHandler; import me.gleep.oreexpansion.world.gen.CustomOreGen; import net.minecraft.block.Blocks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @Mod("oreexpansion") public class OreExpansion { private static final Logger LOGGER = LogManager.getLogger(); public static final String MOD_ID = "oreexpansion"; public OreExpansion() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); RegistryHandler.init(); } private void setup(final FMLCommonSetupEvent event) { CustomOreGen.registerOres(); MinecraftForge.EVENT_BUS.register(this); LOGGER.info("HELLO FROM PREINIT"); LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); } private void doClientStuff(final FMLClientSetupEvent event) { LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings); } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.