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

Create Block that changes textures like End Portal Frame


Mello
 Share

Recommended Posts

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

Link to comment
Share on other sites

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;
Link to comment
Share on other sites

	@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/

Link to comment
Share on other sites

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;
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Hello. When i tried making another server but for another version i cant seem to find a mods folder. and making one doesn't help.
    • public abstract class NitroglycerinFluid extends ForgeFlowingFluid { // Directly reference a log4j logger. private static final Logger LOGGER = LogManager.getLogger(); protected NitroglycerinFluid(Properties properties) { super(properties); } public static Properties createProperties() { return new Properties(() -> ModFluids.NITROGLYCERIN, () -> ModFluids.FLOWING_NITROGLYCERIN, FluidAttributes.builder(new ResourceLocation("sussybakaplus:block/nitroglycerin_still"), new ResourceLocation("sussybakaplus:block/nitroglycerin_flow")).overlay(new ResourceLocation("sussybakaplus:block/nitroglycerin_overlay")).density(3000).viscosity(1000).luminosity(15).temperature(1300)).tickRate(1).canMultiply().bucket(() -> ModItems.NITROGLYCERIN_BUCKET).block(() -> ModBlocks.NITROGLYCERIN); } @Override public boolean isSource(FluidState state) { return false; } @Override public int getAmount(FluidState state) { return state.getValue(LEVEL); } public void animateTick(Level p_76445_, BlockPos p_76446_, FluidState p_76447_, Random p_76448_) { LOGGER.info("animate"); if (!p_76447_.isSource() && !p_76447_.getValue(FALLING)) { if (p_76448_.nextInt(64) == 0) { p_76445_.playLocalSound((double)p_76446_.getX() + 0.5D, (double)p_76446_.getY() + 0.5D, (double)p_76446_.getZ() + 0.5D, SoundEvents.WATER_AMBIENT, SoundSource.BLOCKS, p_76448_.nextFloat() * 0.25F + 0.75F, p_76448_.nextFloat() + 0.5F, false); } } else if (p_76448_.nextInt(10) == 0) { p_76445_.addParticle(ParticleTypes.UNDERWATER, (double)p_76446_.getX() + p_76448_.nextDouble(), (double)p_76446_.getY() + p_76448_.nextDouble(), (double)p_76446_.getZ() + p_76448_.nextDouble(), 0.0D, 0.0D, 0.0D); } } @Nullable public ParticleOptions getDripParticle() { return ParticleTypes.DRIPPING_WATER; } @Override protected void beforeDestroyingBlock(LevelAccessor accessor, BlockPos pos, BlockState state) { BlockEntity blockentity = state.hasBlockEntity() ? accessor.getBlockEntity(pos) : null; LOGGER.info("spread to " + state.getBlock().getRegistryName().toString()); if (state.getBlock().getRegistryName().getPath().equals("fire")) { float f = 4.0F; Minecraft.getInstance().level.explode(null, pos.getX(), pos.getY(), pos.getZ(), f, Explosion.BlockInteraction.BREAK); } //Block.dropResources(state, accessor, pos, blockentity); } @Override public void tick(Level level, BlockPos pos, FluidState state) { //super.tick(level, pos, state); LOGGER.info("tick"); if (this.hasBurningNeighbors(level, pos)) { LOGGER.info("EXPLODING!!!"); float f = 4.0F; level.explode(null, pos.getX(), pos.getY(), pos.getZ(), f, Explosion.BlockInteraction.BREAK); } else { LOGGER.info(pos.toShortString() + " doesn't have any buring neighbors"); } } private boolean hasBurningNeighbors(LevelReader levelReader, BlockPos pos) { for(Direction direction : Direction.values()) { if (this.isBurning(levelReader, pos.relative(direction))) { return true; } } return false; } private boolean isBurning(LevelReader levelReader, BlockPos pos) { return (pos.getY() < levelReader.getMinBuildHeight() || pos.getY() >= levelReader.getMaxBuildHeight() || levelReader.hasChunkAt(pos)) && levelReader.getBlockState(pos).isBurning(levelReader, pos); } protected float getExplosionResistance() { return 0.0F; } public int getTickDelay(LevelReader p_76226_) { return p_76226_.dimensionType().ultraWarm() ? 1 : 1; } protected boolean isRandomlyTicking() { return true; } public Optional<SoundEvent> getPickupSound() { return Optional.of(SoundEvents.BUCKET_FILL); } } My Fluid Class
    • So how do I get the container? It doesn't need to be a event btw.
    • It says it in the log. It's 16. You need to use Java 8 instead of Java 16 for versions before 1.17.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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