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

BlockPlaceEvent Needs To Fire on Client Side and Fire First on Client Side


jredfox
 Share

Recommended Posts

The block place event currently only first on server it needs to fire where it happens first on client place then on server. Example of why it causes issues: on block place event I make tile entity read data to update a spawner based on the nbt of the block It renders pig for a couple ticks now on client side because the server needs to send an update packet. I need the client to already have the update to begin with so it doesn't render pig when it's suppose to be a creeper spawner. So I need the data manipulation to happen on both sides client and server.

 

How you would do this: change the way you fire the event to ItemBlock.class on line 59-60 and fire your event there and then. It would fix my issues no I can't just use BlockEntityTag for the NBT because, TileEntityMobSpawner denies non ops to mess with that tag, so the only logical thing to do is for you to change the line and class of where you fire the event.

Edited by jredfox
making the forum alot cleaner and more advanced reasons
Link to comment
Share on other sites

14 hours ago, LexManos said:

No, World logic is done server side. 

well what about ClientBlockPlaceEvent ? I have already simulated it replacing a itemblock for the mob spawner and it works perfectly. The tile entity needs to read from nbt on client in the same time it's happening on the server. Compare the difference if you comment out my line on silk spawners to replace the itemblock. This below is what it use to do compared to now where it's instant no pigs. This is the simulation of what forge would do for all block placements difference is on line 50 compared to the other itemblock.class. Now the reason Why I am asking for a global event is silkspawners 2.0 is suppose to work with modded spawners and I don't want to see no pig for modded spawners, and I also don't want to replace all itemblocks for the modded blocks

 

Working Fix Code for video: https://gist.github.com/jredfox/a36805e025581efca9ccd8295e362d46

 

Before Fix

 

After Fix:

 

Edited by jredfox
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

    • I am trying to create a custom anvil for my mod and the approach i am trying is to create a normal vanilla anvil with custom recipe container - i tried creating the block and passing a custom container to it but i do feel a bit stuck and confused on how to do this. Some explanation and guidence would be great! Thanks in advance. package com.vassdeniss.makoru.blocks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.inventory.container.SimpleNamedContainerProvider; import net.minecraft.stats.Stats; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.IWorldPosCallable; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; public class AngelAnvilBlock extends Block { private static final ITextComponent AngelAnvilContainer = new TranslationTextComponent("container.crafting"); public AngelAnvilBlock() { super(Block.Properties.create()); } @Override public ActionResultType onBlockActivated(BlockState p_225533_1_, World worldIn, BlockPos p_225533_3_, PlayerEntity player, Hand p_225533_5_, BlockRayTraceResult p_225533_6_) { if (worldIn.isRemote) { return ActionResultType.SUCCESS; } else { NetworkHooks.openGui(player, ); player.addStat(Stats.INTERACT_WITH_ANVIL); return ActionResultType.CONSUME; } } @Override public INamedContainerProvider getContainer(BlockState state, World world, BlockPos pos) { return new SimpleNamedContainerProvider((id, inventory, player) -> new AngelAnvilContainer(id, inventory, IWorldPosCallable.of(world, pos)), AngelAnvilContainer); } } package com.vassdeniss.makoru.blocks; import com.vassdeniss.makoru.util.RegistryHandler; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.RepairContainer; import net.minecraft.util.IWorldPosCallable; public class AngelAnvilContainer extends RepairContainer { private final IWorldPosCallable field_217070_e; public AngelAnvilContainer(int id, PlayerInventory playerInventory, IWorldPosCallable p_i50102_3_) { super(id, playerInventory, p_i50102_3_); this.field_217070_e = p_i50102_3_; } @Override public boolean canInteractWith(PlayerEntity player) { return isWithinUsableDistance(this.field_217070_e, player, RegistryHandler.ANGEL_ANVIL.get()); } }  
    • I'm making some tools and I'm using a Set of type Block to specify on what blocks the tools would work. This is all in my ItemInit class which I use to register items. See below. private static Set<Block> EFFECTIVE_ON = Sets.newHashSet(Blocks.ANDESITE); This works fine with minecraft blocks. Problems occur when I want to use mod blocks like this: private static Set<Block> EFFECTIVE_ON = Sets.newHashSet(BlockInit.AMBER_BLOCK.get());   I get an error while loading the game, which is a NullPointerException.  Exception message: java.lang.NullPointerException: Registry Object not present: extinctioncraft:amber_block   It seems my block can't be found by this set despite the block working fine in the game itself.    I already tried the following without success: - Checked if the BlockInit is registered in the main class. ( BlockInit.BLOCKS.register(bus); ) - Checked if the block is registered in the BlockInit class. 
    • As the name implies I am trying to make a block with a "condition" value. I am doing this because I will be adding future features where a very strong type of block would be useful. I have started out with making a simple custom blockstate property (1-4) which determines the model (Polished, Un-polished, scuffed, cracked). However, I want those 4 states to then be determined by a larger number (more wiggle room with how much damage a certain event can do to this type of block). I was thinking 3000-5000, which I can then say "oh the block durability has to be at 200 to be cracked, but 750 for scuffed". I think the large health number think could be done with a tile entity I also want certain states to be maintained even after it has been picked up such as the larger number (maybe not the 1-4 since I think I would have to do something funky with datagen for my 90 items to have 360 item models), so perhaps NBT (which I have never done before). ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I could probably figure this out on my own given a good bit of time, but dual-enrollment does not allow much time in a day. So, basically just looking either for a github repos that shows persistent data & some funky tile entities (if that is the best route for the block health thing), or suggestions.    
    • ObfuscationReflectionHelper methods always take SRG names, even in the development environment. In development, the SRG name is automatically remapped to the corresponding MCP name.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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