Jump to content

grossik

Members
  • Posts

    88
  • Joined

  • Last visited

Everything posted by grossik

  1. Hi. I'm having trouble rendering my own head. If I place a head that has my skin texture and another one next to it (without texture - completely black) my skin is visible on the second one until the first head disappears from view. How to make the second head always be all black? https://imgur.com/Bd2fNgP https://imgur.com/m04kAWV Code: public class CustomSkullRenderer implements BlockEntityRenderer<CustomSkullBlockEntity> { SkullModelBase headModel; RenderType rendertype; DynamicTexture texture; private int[][] oldTextureMap; public CustomSkullRenderer(BlockEntityRendererProvider.Context context) { headModel = new SkullModel(context.bakeLayer(ClientSetup.HEAD)); rendertype = null; oldTextureMap = new int[16][32]; texture = new DynamicTexture(64, 64, true); } @Override public void render(CustomSkullBlockEntity be, float p_112308_, PoseStack pose, MultiBufferSource buffer, int light, int p_112312_) { try { updateImage(be); if(rendertype == null) { Minecraft.getInstance().getTextureManager().register(be.getLocation(), texture); rendertype = CustomRenderType.createSkullRenderType(be.getLocation()); } } catch(Exception e) { e.printStackTrace(); } BlockState blockstate = be.getBlockState(); boolean flag = blockstate.getBlock() instanceof CustomSkullWall; Direction direction = flag ? blockstate.getValue(CustomSkullWall.FACING) : null; float f1 = 22.5F * (float)(flag ? (2 + direction.get2DDataValue()) * 4 : blockstate.getValue(CustomSkull.ROTATION)); pose.pushPose(); if(direction == null) { pose.translate(0.5D, 0.0D, 0.5D); } else { pose.translate((double)(0.5F - (float)direction.getStepX() * 0.25F), 0.25D, (double)(0.5F - (float)direction.getStepZ() * 0.25F)); } pose.scale(-1.0F, -1.0F, 1.0F); VertexConsumer vertexconsumer = buffer.getBuffer(rendertype); headModel.setupAnim(0, f1, 0); headModel.renderToBuffer(pose, vertexconsumer, light, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F); pose.popPose(); } public void updateImage(CustomSkullBlockEntity be) { boolean update = false; for(int y = 0; y < be.getTextureMap().length; y++) { for(int x = 0; x < be.getTextureMap()[y].length; x++) { if(oldTextureMap[y][x] != be.getTextureMap()[y][x]) { setColorToImage(x, y, be.getTextureMap()[y][x]); update = true; } } } if(update) { texture.upload(); } } public void setColorToImage(int x, int y, int color) { texture.getPixels().setPixelRGBA(x, y, color); oldTextureMap[y][x] = color; } } public static RenderType createSkullRenderType(ResourceLocation location) { RenderType.CompositeState rendertype$compositestate = RenderType.CompositeState.builder() .setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_SHADER) .setTextureState(new RenderStateShard.TextureStateShard(location, false, false)) .setTransparencyState(TRANSLUCENT_TRANSPARENCY) .setCullState(NO_CULL) .setLightmapState(LIGHTMAP) .setOverlayState(OVERLAY) .createCompositeState(true); return RenderType.create(Main.MODID + "_head", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, rendertype$compositestate); }
  2. Hi I try to get custom entity to a specific position which is located above the diamond block, but the entity stops next to the block and doesn't continue. Where is the problem? How can I get my entity to position above the diamond block? https://imgur.com/6dzbt6J Custom goal: public class TestMoveToPositionGoal extends Goal { protected MiniGolemEntity mob; protected BlockPos blockPos; protected int index; protected int tryTicks; public TestMoveToPositionGoal(MiniGolemEntity entity, int index) { this.mob = entity; this.index = index; this.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.JUMP)); blockPos = new BlockPos(8, -60, -19); } @Override public void tick() { super.tick(); if(!blockPos.closerThan(this.mob.position(), 1D)) { this.tryTicks++; if(this.shouldRecalculatePath()) { System.out.println("recalculate"); mob.getNavigation().moveTo(blockPos.getX() + 0.5D, blockPos.getY(), blockPos.getZ() + 0.5D, 1F); } } else { this.tryTicks--; mob.getNavigation().stop(); mob.chanceStatus(index); System.out.println("finish"); } } @Override public void start() { super.start(); tryTicks = 0; } public boolean shouldRecalculatePath() { return this.tryTicks % 40 == 0; } @Override public boolean canUse() { return mob.canUseGoal(index); } } Entity only recalculate path, but doesn't move. I know. I can solve it by increasing the radius, but I don't want to.
  3. Hi. I update my mod from 1.15.2 to 1.16.1 and in 1.16.1 version I see "button" behind my text. I dont know how this solved Screen init: @Override public void func_231160_c_() { super.func_231160_c_(); this.func_230480_a_(new Slider(this.guiLeft + 84, this.guiTop + 26, 85, 10, new StringTextComponent("Red: "), new StringTextComponent(""), 0, 255, this.container.tile.red, false, true, slider -> { })); this.func_230480_a_(new Slider(this.guiLeft + 84, this.guiTop + 38, 85, 10, new StringTextComponent("Green: "), new StringTextComponent(""), 0, 255, this.container.tile.green, false, true, slider -> { })); this.func_230480_a_(new Slider(this.guiLeft + 84, this.guiTop + 50, 85, 10, new StringTextComponent("Blue: "), new StringTextComponent(""), 0, 255, this.container.tile.blue, false, true, slider -> { })); }
  4. Yeah sorry https://github.com/grossik/FarmCraft/blob/master/src/main/resources/assets/farmcraft/models/block/boiling.blend
  5. https://github.com/grossik/FarmCraft/blob/master/src/main/resources/assets/farmcraft/models/block/boiling.obj
  6. I try recalculate outside (Mesh -> Normals -> Recalculate outside) but not work. I also tried to recalculate inside and set from faces but nothing worked.
  7. Hi. I create Blender model, But I don't understand why it's hollow? And JSON is: { "parent": "forge:block/default", "loader": "forge:obj", "model": "farmcraft:models/block/boiling.obj", "flip-v": true, "transform": { "scale": [0.375, 0.375, 0.375], "translation": [0.4, -0.5, 0.4] } } This problem occurs when they start to change model in modeling tab in blender. And if I add a normal cube without changes so it works.
  8. Hi. I need to use more texture layers for my item, but only 5 layers will load. Minecraft minecraft = Minecraft.getInstance(); ItemColors colors = minecraft.getItemColors(); colors.register((p_210242_0_, p_210242_1_) -> { if(p_210242_0_.getItem() == ItemInit.LABEL.get()) { return ((LabelItem) p_210242_0_.getItem()).getColor(p_210242_0_, p_210242_1_); } return -1; }, ItemInit.LABEL.get()); Item json: { "parent": "item/generated", "textures": { "layer0": "realistic_beer_brewing:items/label/layer0", "layer1": "realistic_beer_brewing:items/label/layer1", "layer2": "realistic_beer_brewing:items/label/layer2", "layer3": "realistic_beer_brewing:items/label/layer3", "layer4": "realistic_beer_brewing:items/label/layer4", "layer5": "realistic_beer_brewing:items/label/layer5", "layer6": "realistic_beer_brewing:items/label/layer6", "layer7": "realistic_beer_brewing:items/label/layer7", "layer8": "realistic_beer_brewing:items/label/layer8" } } Is the number of layers limited or why doesn't it work for me?
  9. Hello. I have transferStackInSlot method and use hasRecipe for find if itemstack is present in recipe. @Override public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); if(slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if(index == 2) { if(!this.mergeItemStack(itemstack1, 3, 39, true)) { return ItemStack.EMPTY; } slot.onSlotChange(itemstack1, itemstack); } else if(index != 1 && index != 0) { if(this.hasRecipe(itemstack1)) { if(!this.mergeItemStack(itemstack1, 1, 2, false)) { return ItemStack.EMPTY; } } else if(this.isBucket(itemstack1)) { if(!this.mergeItemStack(itemstack1, 0, 1, false)) { return ItemStack.EMPTY; } } else if(index >= 3 && index < 30) { if(!this.mergeItemStack(itemstack1, 30, 39, false)) { return ItemStack.EMPTY; } } else if(index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) { return ItemStack.EMPTY; } } else if(!this.mergeItemStack(itemstack1, 3, 39, false)) { return ItemStack.EMPTY; } if(itemstack1.isEmpty()) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if(itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } slot.onTake(playerIn, itemstack1); } return itemstack; } protected boolean hasRecipe(ItemStack stack) { return this.world.getRecipeManager().getRecipe(MaltingRecipe.RECIPE_TYPE, new Inventory(stack), world).isPresent(); } But hasRecipe return false for all itemstack, but i have recipe who works. Recipe: { "type": "realistic_beer_brewing:malting", "ingredient": { "item": "realistic_beer_brewing:barley" }, "result": { "item": "realistic_beer_brewing:barley_seed" }, "process_time": 200 } Recipe in this tile entity works.
  10. Oh... sorry Yes. If you use VillagerInit#init then it will work for you.
  11. https://github.com/grossik/FarmCraft/blob/master/src/main/java/cz/grossik/farmcraft/test/TestStructures.java
  12. I wanted it over json, but ok... Any good way to split a model? Or will I have to do it for each file separately?
  13. I use 1.15.2-31.1.63 forge version And the problem was that this obj files is too large and render for all 8 blocks... Can I change the start position from which it will be loading obj model?
  14. Hello. I have multistructure tile entity with .obj model but If multistructure has created the model have black shadows. I tried to change RenderTypeLookup.setRenderLayer but it didn't solved.
  15. Sorry. I solved this problem. I had rotationPitch and rotationYaw from Entity class not PlayerEntity... Thank you for everything.
  16. float f8 = MathHelper.sin(location.rotationPitch * ((float)Math.PI / 180F)); float f2 = MathHelper.cos(location.rotationPitch * ((float)Math.PI / 180F)); float f3 = MathHelper.sin(location.rotationYaw * ((float)Math.PI / 180F)); float f4 = MathHelper.cos(location.rotationYaw * ((float)Math.PI / 180F)); float f5 = ((float)Math.PI * 2F); float f6 = 0.02F; itementity.setMotion((double)(-f3 * f2 * 0.3F) + Math.cos((double)f5) * (double)f6, (double)(-f8 * 0.3F + 0.1F * 0.1F), (double)(f4 * f2 * 0.3F) + Math.sin((double)f5) * (double)f6); This code drop item around player no in front of the player. Its from PlayerEntity drop
  17. Thank you. I have new problem... The position where item entity spawn is bad I need player position and if I drop item I'll take it back to inventory. (therefore onCollideWithPlayer is empty), and item entity not move like default item entity
  18. I update constructor with position. And I update github ass well. But render still not work
  19. https://github.com/grossik/FarmCraft/blob/master/src/main/java/cz/grossik/farmcraft/entity/FarmCraftItemEntity.java Item for this entity https://github.com/grossik/FarmCraft/blob/master/src/main/java/cz/grossik/farmcraft/item/ItemBarley.java
  20. Yes I know. I forgot send new registration. Sorry public static RegistryObject<EntityType<FarmCraftItemEntity>> ITEM_ENTITY = ENTITIES .register("item_farmcraft", () -> EntityType.Builder.<FarmCraftItemEntity>create(FarmCraftItemEntity::new, EntityClassification.MISC) .size(0.25F, 0.25F) .build(new ResourceLocation(Main.MOD_ID, "item_farmcraft").toString()));
  21. This item: package cz.grossik.farmcraft.item; import cz.grossik.farmcraft.entity.FarmCraftItemEntity; import cz.grossik.farmcraft.init.EntityInit; import net.minecraft.entity.Entity; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ItemBarley extends Item { public ItemBarley(Properties properties) { super(properties); } @Override public boolean hasCustomEntity(ItemStack itemstack) { return true; } @Override public Entity createEntity(World world, Entity location, ItemStack itemstack) { return new FarmCraftItemEntity(EntityInit.ITEM_ENTITY.get(), world); } }
  22. package cz.grossik.farmcraft.entity; import cz.grossik.farmcraft.init.ItemInit; import net.minecraft.entity.EntityType; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; import net.minecraft.network.IPacket; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; public class FarmCraftItemEntity extends ItemEntity { public FarmCraftItemEntity(EntityType<? extends ItemEntity> p_i50217_1_, World p_i50217_2_) { super(p_i50217_1_, p_i50217_2_); } @Override public IPacket<?> createSpawnPacket() { return NetworkHooks.getEntitySpawningPacket(this); } @Override public void tick() { System.err.println("tick"); if(this.isInWater()) { System.err.println("water"); ItemStack newItemStack = new ItemStack(ItemInit.soaked_barley.get()); ItemEntity newItem = new ItemEntity(this.world, this.getPosition().getX(), this.getPosition().getY(), this.getPosition().getZ(), newItemStack); this.world.addEntity(newItem); this.remove(); } super.tick(); } }
×
×
  • Create New...

Important Information

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