Everything posted by Klarks
-
[1.16.4] How i can open a container by clicking on my mob
I get it but my container have a data parametr now protected MyModContainer(int id, PlayerInventory playerInventory,World world,PacketBuffer data) { super(RegObj.MOD_CONTAINER.get(), id); this.playerInventory = new InvWrapper(playerInventory); world.getEntityByID( data.readInt()).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(h -> { addSlot(new SlotItemHandler(h,0,79,18)); }); layoutPlayerInventory(7,54); } and my anonymous inner class asks for data parametr too. if i'll leave it null container wont work INamedContainerProvider iNamedContainerProvider = new INamedContainerProvider() { @Override public ITextComponent getDisplayName() { return new StringTextComponent("loh"); } @Nullable @Override public Container createMenu(int id, PlayerInventory playerInventory, PlayerEntity playerEntity) { return new MyModContainer(id,playerInventory, world,extraDataWriter); } };
-
[1.16.4] How i can open a container by clicking on my mob
why
-
[1.16.4] How i can open a container by clicking on my mob
Thanks it seems to be working. But i didnt understand one thing. if this line sending the EntityId to my container return new MyModContainer(id,playerInventory, world,extraDataWriter); so what do that line with EntityId NetworkHooks.openGui((ServerPlayerEntity) playerEntity,iNamedContainerProvider, buf -> buf.writeInt(getEntityId())); PacketBuffer extraDataWriter = new PacketBuffer(Unpooled.buffer()); extraDataWriter.writeInt(getEntityId()); INamedContainerProvider iNamedContainerProvider = new INamedContainerProvider() { @Override public ITextComponent getDisplayName() { return new StringTextComponent("loh"); } @Nullable @Override public Container createMenu(int id, PlayerInventory playerInventory, PlayerEntity playerEntity) { return new MyModContainer(id,playerInventory, world,extraDataWriter); } }; NetworkHooks.openGui((ServerPlayerEntity) playerEntity,iNamedContainerProvider, buf -> buf.writeInt(getEntityId()));
-
[1.16.4] My structure doesnt work
When i tranna locate my structure minecraft says "Could not find that structure nearby ". What i did wrong public class MyStructure { public static final DeferredRegister<Structure<?>> DEFERRED_REGISTRY_STRUCTURE = DeferredRegister.create(ForgeRegistries.STRUCTURE_FEATURES, Main.MODID); public static final RegistryObject<Structure<NoFeatureConfig>> RUN_DOWN_HOUSE = registerStructure("run_down_house", () -> (new MyPieces(NoFeatureConfig.field_236558_a_))); private static <T extends Structure<?>> RegistryObject<T> registerStructure(String name, Supplier<T> structure) { return DEFERRED_REGISTRY_STRUCTURE.register(name, structure); } public static void setupStructures() { setupMapSpacingAndLand( RUN_DOWN_HOUSE.get(), new StructureSeparationSettings(10 , 5 , 1234567890 ), true); } public static <F extends Structure<?>> void setupMapSpacingAndLand( F structure, StructureSeparationSettings structureSeparationSettings, boolean transformSurroundingLand) { Structure.NAME_STRUCTURE_BIMAP.put(structure.getRegistryName().toString(), structure); if(transformSurroundingLand) Structure.field_236384_t_.add(structure); DimensionStructuresSettings.field_236191_b_.put(structure, structureSeparationSettings); } public class MyPieces extends Structure<NoFeatureConfig> { public MyPieces(Codec<NoFeatureConfig> codec) { super(codec); } @Override public IStartFactory<NoFeatureConfig> getStartFactory() { return MyPieces.Start::new; } @Override public GenerationStage.Decoration getDecorationStage() { return GenerationStage.Decoration.SURFACE_STRUCTURES; } public static class Start extends StructureStart<NoFeatureConfig> { public Start(Structure<NoFeatureConfig> p_i225876_1_, int p_i225876_2_, int p_i225876_3_, MutableBoundingBox p_i225876_4_, int p_i225876_5_, long p_i225876_6_) { super(p_i225876_1_, p_i225876_2_, p_i225876_3_, p_i225876_4_, p_i225876_5_, p_i225876_6_); } @Override public void func_230364_a_(DynamicRegistries dynamicRegistries, ChunkGenerator chunkGenerator, TemplateManager templateManager, int cx, int cy, Biome biome, NoFeatureConfig config) { int x = cx << 4; int z = cy << 4; BlockPos blockpos = new BlockPos(x, 0, z); JigsawManager.func_242837_a( dynamicRegistries,new VillageConfig(() -> dynamicRegistries.getRegistry(Registry.JIGSAW_POOL_KEY).getOrDefault(new ResourceLocation(Main.MODID,"run_down_house/start_pool")),10), AbstractVillagePiece::new,chunkGenerator,templateManager,blockpos,this.components,this.rand,false,true); this.components.forEach(piece -> piece.offset(0, 1, 0)); this.components.forEach(piece -> piece.getBoundingBox().minY -= 1); this.recalculateStructureSize(); } } } public class MyConfigStructures { public static StructureFeature<?, ?> CONFIGURED_RUN_DOWN_HOUSE = MyStructure.RUN_DOWN_HOUSE.get().withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG); public static void registerConfiguredStructures() { Registry<StructureFeature<?, ?>> registry = WorldGenRegistries.CONFIGURED_STRUCTURE_FEATURE; Registry.register(registry, new ResourceLocation(Main.MODID, "configured_run_down_house"), CONFIGURED_RUN_DOWN_HOUSE); Map<Structure<?>, StructureFeature<?, ?>> STR = ObfuscationReflectionHelper.getPrivateValue(FlatGenerationSettings.class,null,"STRUCTURES"); STR.put(MyStructure.RUN_DOWN_HOUSE.get(), CONFIGURED_RUN_DOWN_HOUSE); ObfuscationReflectionHelper.setPrivateValue(FlatGenerationSettings.class,null,STR,"STRUCTURES"); //Map<Structure<?>, StructureFeature<?, ?>> STR = ObfuscationReflectionHelper.getPrivateValue(FlatGenerationSettings.class,null,"field_202247_j"); //STR.put(MyStructure.RUN_DOWN_HOUSE.get(), CONFIGURED_RUN_DOWN_HOUSE); //ObfuscationReflectionHelper.setPrivateValue(FlatGenerationSettings.class,null,STR,"field_202247_j"); } } public Main() { IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); MyStructure.DEFERRED_REGISTRY_STRUCTURE.register(bus); bus.addListener(this::setup); IEventBus forgeBus = MinecraftForge.EVENT_BUS; forgeBus.addListener(EventPriority.NORMAL, this::addDimensionalSpacing); forgeBus.addListener(EventPriority.HIGH, this::biomeModification); } private void setup (final FMLCommonSetupEvent event) { Networking.RegMes(); event.enqueueWork(() -> { MyStructure.setupStructures(); MyConfigStructures.registerConfiguredStructures(); }); } public void biomeModification(final BiomeLoadingEvent event) { event.getGeneration().getStructures().add(() -> MyConfigStructures.CONFIGURED_RUN_DOWN_HOUSE); } public void addDimensionalSpacing(final WorldEvent.Load event) { if(event.getWorld() instanceof ServerWorld){ ServerWorld serverWorld = (ServerWorld)event.getWorld(); if(serverWorld.getChunkProvider().getChunkGenerator() instanceof FlatChunkGenerator && serverWorld.getDimensionKey().equals(World.OVERWORLD)){ return; } Map<Structure<?>, StructureSeparationSettings> tempMap = new HashMap<>(serverWorld.getChunkProvider().generator.func_235957_b_().func_236195_a_()); tempMap.put(MyStructure.RUN_DOWN_HOUSE.get(), DimensionStructuresSettings.field_236191_b_.get(MyStructure.RUN_DOWN_HOUSE.get())); serverWorld.getChunkProvider().generator.func_235957_b_().func_236195_a_(); }
-
[1.16.4] How i can open a container by clicking on my mob
I don't understand. Where i should have container factory
-
[1.16.4] How i can open a container by clicking on my mob
In my IContainerFactory? Where i can get it in my container class
-
[1.16.4] How i can open a container by clicking on my mob
is it correct? //MyModEntity public ITextComponent getDisplayName() { return new StringTextComponent("Name"); } @Nullable @Override public Container createMenu(int id, PlayerInventory playerInventory, PlayerEntity playerEntity) { return new MyModContainer(id,playerInventory, world); } }; PacketBuffer buf = new PacketBuffer(Unpooled.buffer()); buf.writeVarInt(this.getEntityId()); NetworkHooks.openGui((ServerPlayerEntity) playerEntity,iNamedContainerProvider,(Consumer<PacketBuffer> buf); and how can i get it in my container class //MyModContainer world.getEntityByID().getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(h -> { addSlot(new SlotItemHandler(h,0,79,18)); });
-
[1.16.4] How i can put my strucnures in to FlatGenerationSettings.STRUCTURES
Is STRUCTURES a mapped name? forge-bot gave me this MC 1.16.3: net/minecraft/world/gen/FlatGenerationSettings.STRUCTURES Name: c => field_202247_j => STRUCTURES Comment: None Side: BOTH AT: public net.minecraft.world.gen.FlatGenerationSettings field_202247_j # STRUCTURES
-
[1.16.4] How i can open a container by clicking on my mob
Ok i messed up few things, idk where did i get a player inventory parameter in openGui. So thanks it's working now But how i can correctly get the entity inside the container class to get capabilities to add a slot. I know how to do it with the player i can just get the player from the player inventory but with a mob i am not sure. Should i get the entity from world somehow?
-
[1.16.4] How i can open a container by clicking on my mob
With out it java gave an error "Cant resolve method openGui". What i did wrong here?
-
[1.16.4] How i can open a container by clicking on my mob
is it correct INamedContainerProvider in = new INamedContainerProvider() { @Override public ITextComponent getDisplayName() { return new StringTextComponent("Name"); } @Nullable @Override public Container createMenu(int id, PlayerInventory playerInventory, PlayerEntity playerEntity) { return new MyModContainer(id,playerInventory); } }; if(en.equals(pl)) { NetworkHooks.openGui((ServerPlayerEntity) playerEntity, in,(Consumer<PacketBuffer>) playerEntity.inventory); } else playerEntity.sendMessage(new TranslationTextComponent("You are not "+en),Util.DUMMY_UUID); }
-
[1.16.4] How i can put my strucnures in to FlatGenerationSettings.STRUCTURES
I am a bigginer at Java and do not know much about reflection but I know it allows to get private var, methods, annotations and so
-
[1.16.4] How i can open a container by clicking on my mob
I ve seen an example of it but i dont understand how i can apply this to my problem. Do I need to call createmenu from new class in networkhooks.opengui method?
-
[1.16.4] How i can open a container by clicking on my mob
I dont quite understand what you mean by this. I created a new class. NetworkHooks.openGui((ServerPlayerEntity) playerEntity,new MyModContainer(0,new anonymousInnerClass() { },playerEntity.inventory)); public class anonymousInnerClass implements INamedContainerProvider { @Override public ITextComponent getDisplayName() { return new StringTextComponent("Name"); } @Nullable @Override public Container createMenu(int id, PlayerInventory playerInventory, PlayerEntity playerEntity) { return new MyModContainer(id,playerInventory); } }
-
[1.16.4] How i can put my strucnures in to FlatGenerationSettings.STRUCTURES
I don't quite understand
-
[1.16.4] How i can put my strucnures in to FlatGenerationSettings.STRUCTURES
forge-bot?
-
[1.16.4] How i can put my strucnures in to FlatGenerationSettings.STRUCTURES
But where i can get the instance Map<Structure<?>, StructureFeature<?, ?>> STR = ObfuscationReflectionHelper.getPrivateValue(FlatGenerationSettings.class,instance,"STRUCTURES");
-
[1.16.4] How i can put my strucnures in to FlatGenerationSettings.STRUCTURES
How i can put my structures in to FlatGenerationSettings.STRUCTURES. The structures var is final so i cant put mine like that FlatGenerationSettings.STRUCTURES.put(MyStructure.RUN_DOWN_HOUSE.get(), CONFIGURED_RUN_DOWN_HOUSE);
-
[1.16.4] How i can open a container by clicking on my mob
What should implement INamedContainerProvider
-
[1.16.4] How i can open a container by clicking on my mob
So what needs to be implemented? My Entity?
-
[1.16.4] How i can open a container by clicking on my mob
Is it ok that i am saving a player uuid as a string in datamanager private static final DataParameter<String> OWNER = EntityDataManager.createKey(MyEntity.class, DataSerializers.STRING); @OnlyIn(Dist.CLIENT) public UUID getOwner() { return UUID.fromString(this.dataManager.get(OWNER)); } public void setOwner(UUID name) { this.dataManager.set(OWNER ,name.toString()); }
-
[1.16.4] How i can open a container by clicking on my mob
where i can get uuid. from player entity? Should my entity implement it?
-
[1.16.4] How i can open a container by clicking on my mob
i am trying to show my gui by clicking on my entity public ActionResultType func_230254_b_(PlayerEntity playerEntity, Hand hand) { if (!this.world.isRemote) { String en = getOwner(); String pl = playerEntity.getScoreboardName(); if(en.equals(pl)) { NetworkHooks.openGui((ServerPlayerEntity) playerEntity,new MyModContainer(0,playerEntity.inventory)); } else playerEntity.sendMessage(new TranslationTextComponent("You are not "+en),Util.DUMMY_UUID); } return ActionResultType.func_233537_a_(this.world.isRemote); }
-
[1.16.4] How i can open a container by clicking on my mob
it stil doest work
-
[1.16.4] How i can open a container by clicking on my mob
like this? NetworkHooks.openGui((ServerPlayerEntity) playerEntity,new MyModContainer(0,playerEntity.inventory));
IPS spam blocked by CleanTalk.