-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[1.21.3] Add GatherValidBlocksEvent #10152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.21.x
Are you sure you want to change the base?
[1.21.3] Add GatherValidBlocksEvent #10152
Conversation
public static final BlockEntityType<VaultBlockEntity> VAULT = register("vault", VaultBlockEntity::new, Blocks.VAULT); | ||
private final BlockEntityType.BlockEntitySupplier<? extends T> factory; | ||
- private final Set<Block> validBlocks; | ||
+ private final net.minecraftforge.common.util.ValidBlocksSet validBlocks; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is heavily reflected/edited by mods so its not good to change this field type.
this.original = original; | ||
} | ||
|
||
public boolean contains(Block block, BlockEntityType<?> type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As i said on discord, I think it would be better to fire this event at a known time, during post registration, instead of on first use. Theoretically it'd be fine as this method should only be used when the entries are loaded into world which is far after registration. But its a race and i'd rather just be clear on when its fired.
} | ||
|
||
public boolean isSame(BlockEntityType<?> type) { | ||
return type == blockEntityType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just have getType()?
} | ||
|
||
public void addBlock(Block block) { | ||
if (original.contains(block) || modded.contains(block)) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its a set.. no need for modded.contains
This PR is getting stale, but I think it can be easily cleaned up. It's not a priority but if you want to resume work on this, I'd recommend exactly what Lex said in comments, which is to keep it as a set but fire an event at a known time for all block entities. Common setup would be a good place for this one. |
Adds an event where modders can add blocks that are considered valid for block entity types