Jump to content

Create Block that changes textures like End Portal Frame


Recommended Posts

Posted

Yesterday I started with creating mods and atm I got an ore-block, a brick-Block and an item, that gets dropped by the ore-block when breaking. Now I wanted to go further and create a block that looks like an end portal frame, and when I click on that block with my item in hand, the Item gets "inserted" like the eye of ender in the portal frame. I don't need a 3D texture, I just wanted to change the texture when the block gets activated with an item. I haven't found good Tutorials yet, so I'm asking here

Posted

You will still need to mess around with the block's model, when an item gets inserted into it, if you want to make it similar looking to the portal frame. Otherwise you won't. But most importantly, it should hold any item, or only one specific like the portal frame? Because the easiest way of doing this is to override the onBlockActivated() method, so it detects if it's clicked with your item and replace your block with an activated one. If thats what you want, I will be able to make an example for it.

procedure WakeMeUp(Integer plusTime);
var
  I: Integer;
begin
  for I := 0 to plusTime do begin
    println('One more minute!');
    Sleep(1000);
  end;
  println('Okay, nothing to worry, I''m alive!');
  println('So... somebody can give me a coffee?');
  println('I know it''s Pascal, and not Java, but I love it :D.');
end;
Posted
	@Override
	public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
		if (!world.isRemote) {
			TileEntityPedestal tile = getTileEntity(world, pos);
			IItemHandler itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
			if (!player.isSneaking()) {
				if (heldItem.isEmpty()) {
					player.setHeldItem(hand, itemHandler.extractItem(0, 64, false));
				} else {
					player.setHeldItem(hand, itemHandler.insertItem(0, heldItem, false));
				}
				tile.markDirty();
			} else {
				ItemStack stack = itemHandler.getStackInSlot(0);
				if (!stack.isEmpty()) {
					String localized = TutorialMod.proxy.localize(stack.getUnlocalizedName() + ".name");
					player.addChatMessage(new TextComponentString(stack.getCount() + "x " + localized));
				} else {
					player.addChatMessage(new TextComponentString("Empty"));
				}
			}
		}
		return true;
	}



From https://shadowfacts.net/tutorials/forge-modding-112/tile-entities-inventory/

Posted

It only works if he wants a tileEntity, and he has everything needed in that tutorial. That's not what he asked for. Let's wait until he respond instead of copy pasting random code.

procedure WakeMeUp(Integer plusTime);
var
  I: Integer;
begin
  for I := 0 to plusTime do begin
    println('One more minute!');
    Sleep(1000);
  end;
  println('Okay, nothing to worry, I''m alive!');
  println('So... somebody can give me a coffee?');
  println('I know it''s Pascal, and not Java, but I love it :D.');
end;
Posted

You don't need a tile entity for this. All that happens when you insert an eye of ender into an end portal frame is that the block changes state. As a result, it changes models.

 

This can all be done with the JSON blockstate system.

 

{
    "variants": {
        "eye=false,facing=south": { "model": "end_portal_frame_empty" },
        "eye=false,facing=west": { "model": "end_portal_frame_empty", "y": 90 },
        "eye=false,facing=north": { "model": "end_portal_frame_empty", "y": 180 },
        "eye=false,facing=east": { "model": "end_portal_frame_empty", "y": 270 },
        "eye=true,facing=south": { "model": "end_portal_frame_filled" },
        "eye=true,facing=west": { "model": "end_portal_frame_filled", "y": 90 },
        "eye=true,facing=north": { "model": "end_portal_frame_filled", "y": 180 },
        "eye=true,facing=east": { "model": "end_portal_frame_filled", "y": 270 }
    }
}

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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