Jump to content

Meldexun

Members
  • Posts

    184
  • Joined

  • Last visited

Posts posted by Meldexun

  1. So i want to render a water texture when there is no block near my block. Currently i have a TileEntitySpecialRenderer which renders a block of water at the position of my block.

    But when the it renders the model of my block is hidden. I mean when standing inside the block i can see the model and the water but from the outside i can only see the water.

    That's the TileEntitySpecialRenderer :

    Spoiler
    
    public class RenderCreepvine extends TileEntitySpecialRenderer<TileEntityCreepvine> {
    
    	@Override
    	public void render(TileEntityCreepvine te, double x, double y, double z, float partialTicks, int destroyStage,
    			float alpha) {
    		BlockPos blockpos = te.getPos();
    
    		this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    		GlStateManager.pushMatrix();
    		GlStateManager.disableLighting();
    		GlStateManager.enableBlendProfile(GlStateManager.Profile.PLAYER_SKIN);
    
    		Tessellator tessellator = Tessellator.getInstance();
    		BufferBuilder bufferbuilder = tessellator.getBuffer();
    		bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    		GlStateManager.translate(x - (double) blockpos.getX(), y - (double) blockpos.getY(), z - (double) blockpos.getZ());
    		BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
    		blockrendererdispatcher.renderBlock(Blocks.WATER.getDefaultState(), blockpos, te.getWorld(), bufferbuilder);
    		tessellator.draw();
    
    		GlStateManager.disableBlendProfile(GlStateManager.Profile.PLAYER_SKIN);
    		GlStateManager.enableLighting();
    		GlStateManager.popMatrix();
    	}
    
    }

     

     

    And a pictures how it currently looks like:

    Spoiler

    2019-11-13_20_29_00.png.0d95624233deb3661fc7dce7e2d7707a.png2019-11-13_20_29_25.png.33063d8a7c2125938394881ece7c1315.png

     

  2. Hello,

    I have a moving sound but i'm wondering how to correctly start it and restart/resume it when it's stopped.

    Currently i have this:

    	@SubscribeEvent
    	public static void updateUnderwaterAmbience(ClientTickEvent event) {
    		if (event.phase == Phase.START) {
    			Minecraft mc = Minecraft.getMinecraft();
    			
    			if (mc.world != null) {
    				SoundHandler soundHandler = mc.getSoundHandler();
    				
    				if (!soundHandler.isSoundPlaying(SoundEventHandler.underwaterSound)) {
    					SoundEventHandler.underwaterSound = new UnderwaterAmbientSound(mc.player);
    					soundHandler.playSound(SoundEventHandler.underwaterSound);
    				}
    			}
    		}
    	}

     

  3. On 10/12/2019 at 3:05 AM, Draco18s said:

    https://mcforge.readthedocs.io/en/latest/concepts/registries/#injecting-registry-values-into-fields

    
        public static final Item ENDER_PEARL = null;    // Note that the actual name is "minecraft:ender_pearl", not "minecraft:ENDER_PEARL".
                                                        // However, since constructing a ResourceLocation lowerc

     

    Well that's 1.12.2 not 1.10.2. Also when lowercasing the names of the fields it works as well as annotating the fields but leaving them uppercase doesn't work.

  4. 1 minute ago, Animefan8888 said:

    You should post your code.

    Sure. Here it is:

    @ObjectHolder(BetterDiving.MOD_ID)
    public class ModItems {
    
    	public static final Item TITANIUM = null;
    	public static final Item COPPER_ORE = null;
    	public static final Item SILVER_ORE = null;
    	public static final Item LEAD = null;
    	public static final Item GOLD = null;
    
    	@EventBusSubscriber
    	public static class ItemRegistrationHandler {
    
    		public static final List<Item> ITEMS = new ArrayList<Item>();
    
    		@SubscribeEvent
    		public static void registerItems(RegistryEvent.Register<Item> event) {
    			final Item[] items = {
    					setItemName(new Item(), "titanium"),
    					setItemName(new Item(), "copper_ore"),
    					setItemName(new Item(), "silver_ore"),
    					setItemName(new Item(), "lead"),
    					setItemName(new Item(), "gold")
    			};
    
    			IForgeRegistry<Item> registry = event.getRegistry();
    
    			for (Item item : items) {
    				registry.register(item);
    				ITEMS.add(item);
    			}
    		}
    
    		private static Item setItemName(Item item, String name) {
    			return setItemNameAndTab(item, name, BetterDiving.TAB_BETTER_DIVING);
    		}
    
    		private static Item setItemNameAndTab(Item item, String name, @Nullable CreativeTabs tab) {
    			return item.setUnlocalizedName(name).setRegistryName(BetterDiving.MOD_ID, name).setCreativeTab(tab);
    		}
    	}
    
    }

     

  5. Hello,

    I have an item and i attach a ItemStackHandler capability to it.

    But i have some weird behaviour going on when using it in creative mode (it's a creative mode only item...).

     

    Duplication:

    1. Right click to open the inventory, place items inside and close it.

    2. Right click again to open the inventory, take the items and close it.

    3. Press E to open the normal inventory and drop the item to the world. (only when dropping from creative inventory)

    4. Pick up the item and open the inventory.

    5. You will find the items in it again...

     

    Deletion:

    1. Right click to open the inventory, place items inside and close it.

    2. Press E to open the normal inventory and drop the item to the world. (only when dropping from creative inventory)

    3. Pick up the item and open the inventory.

    4. You will find no items in it...

     

    Github: https://github.com/Meldexun/ChocolateQuestRepoured/tree/master/src/main/java/com/teamcqr/chocolatequestrepoured

     

    Direct links to classes on github:

    Item class: ItemBadge.java

    Capability provider class: CapabilityItemStackHandlerProvider.java

    Gui handler class: GuiHandler.java

    Container class: ContainerBadge.java

    Gui class: GuiBadge.java

     

    Thank you in advance for your help.

  6. 10 minutes ago, diesieben07 said:

    Also note however that in 1.14.4 it is encouraged you flatten your items, so maybe you want to do that already to aid in updating (i.e. make 20 items instead of 1 with 20 metadata values). 

    Iirc in 1.12.2 there is an item limit and you still recommend creating 20 items. Can't this cause issues? I thought only in MC 1.13 and newer i should create 20 items.

  7. 10 minutes ago, diesieben07 said:

    When only using an item model (not a blockstate) it must be "inventory". Otherwise you can set it to a variant and it will pick that variant from the blockstate json.

    Yeah i knew how it works with blockstates but i thought it may also work with items.

     

    11 minutes ago, diesieben07 said:

    ItemStack metadata is a full short (16 bits)

    So i just registered a item model with the metadata of 16 and it seems to work ingame.

    This is what i have done:

    	@SubscribeEvent
    	public static void registerItemModels(ModelRegistryEvent event) {
    		registerCustomItemModel(ModItems.DUNGEON_PLACER, 16, ModItems.DUNGEON_PLACER.getRegistryName().toString() + "_d" + 16, "inventory");
    	}
    
    	private static void registerCustomItemModel(Item item, int meta, String modelLocation, String variant) {
    		ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(modelLocation, variant));
    	}

    Is there any reason not to do this?

  8. Hello,

    So i basically want to create a item with 20 different models.

    1. First of all when creating a ModelResourceLocation what is the use of the variant parameter (when registering a item model)?

    2. I have a capability added to my item. Can i somehow change the model of the item depending on the capability? The meta won't really work because i need more than 16 models.

  9. I want every 5 seconds to randomly rotate my entity. So i added this to my entity class:

    	@Override
    	public void onUpdate() {
    		if (!world.isRemote && world.getTotalWorldTime() % 100 == 0) {
    			this.rotationYaw = world.rand.nextFloat() * 360F;
    		}
    		System.out.println(this.rotationYaw);
    	}

     

    But the problem is that the rotation is not synced correctly with the client. It gives me 2 different rotations. Any idea why it doesn't sync correcly?

  10. Hi there,

    I want to add a recipe for a custom item. To craft it you need a titanium ingot and a silver ingot. But i also want that you can use a ore instead of a ingot. So how can i achieve that? Do i have to make 4 recipes (1: t-ingot and s-ingot, 2: t-ore and s-ingot, 3: t-ingot and s-ore, 4: t-ore and s-ore)?

  11. 4 hours ago, Panossa said:

    MinecraftForge.EVENT_BUS.register(new MainEvents());

     

    4 hours ago, Panossa said:

    @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)

    With this you are trying to register your event handler twice. You probably want to take a look at the docs: https://mcforge.readthedocs.io/en/latest/events/intro/

     

     

    4 hours ago, Panossa said:

    player.closeScreenAndDropStack();

    This deletes the item stack you are holding with your cursor. Just use EntityPlayer.closeScreen().

     

    Also when you set your inventory hotkey to TAB then with your code the inventory will get closed immediately after opening. Because the key input event gets called once on the key press and once on the key release (and also multiple times as long as you hold the key). This can be checked in the event with the KeyInputEvent.getAction() method (returns 1 for the key press action, 0 for the key release action and 2 for the key repeat action).

    But note that when you open the inventory with the InventoryHotKey the KeyInputEvent is fired for the key press action ( and depending on how long you hold the key also the key repeat action) and after that for the key release action. But when you are in the inventory and press the InventoryHotKey then the KeyInputEvent is only fired for (depending on how long you hold the key also the key repeat action and ) the key release action.

  12. I noticed when there are multiple break speed events it can get buggy.

    What i mean is the first break speed event sets the new speed to the original speed * 0.5F.

    Then the second event tries to do something similar. For example it sets the new speed to the original speed * 1.3F.

    The problem is that both events take the original speed as basis. So when the original speed is 1 then the new speed would be 1.3 but the correct value would be 0.65.

    So i should always take the new speed as my base value and do my calculation. And then set the new speed to my calculated speed.

    But if another mod has a break speed event which is fired after my event and it  uses the original speed as a base value then my calculations are completely ignored.

    What can i do to prevent this? Setting the event prioriy to low or lowest is the only thing that i can think of.

  13. So i have a json recipe and it is loading but i want to add a condition to it. So i tried to do like in 1.12. But it gives me this error com.google.gson.JsonSyntaxException: Unknown condition type: recipes_and_more:golden_apple

    This is my recipe file:

    Spoiler
    
    {
    	"type": "minecraft:crafting_shaped",
    	"pattern":
    	[
    		"GGG",
    		"GAG",
    		"GGG"
    	],
    	"key":
    	{
    		"G":
    		{
    			"item": "minecraft:gold_block"
    		},
    		"A":
    		{
    			"item": "minecraft:apple"
    		}
    	},
    	"result":
    	{
    		"item": "minecraft:golden_apple",
    		"data": 1
    	},
    	"conditions" : [
    		{
    			"type" : "recipes_and_more:golden_apple"
    		}
    	]
    }

     

     

    And my _factories file:

    Spoiler
    
    {
    	"conditions": {
    		"golden_apple": "meldexun.recipesAndMore.recipes.GoldenAppleCondition"
    	}
    }

     

     

    And my condition class:

    Spoiler
    
    public class GoldenAppleCondition implements IConditionSerializer {
    	
    	@Override
    	public BooleanSupplier parse(JsonObject json) {
    		return () -> true;
    	}
    	
    }

     

     

×
×
  • Create New...

Important Information

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