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
Rework of AttachCapabilitiesEvent #9718
base: 1.20.x
Are you sure you want to change the base?
Rework of AttachCapabilitiesEvent #9718
Conversation
protected final BlockPos f_58858_; | ||
protected boolean f_58859_; | ||
private BlockState f_58856_; | ||
- |
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 patch change looks wrong to me, looks like this PR added a trivial whitespace change to the patch
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.
Agreed. Please remove it so we can keep the patch surface as low as possible.
@RealMangorage, this pull request has conflicts, please resolve them for this PR to move forward. |
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.
Effectively needs a rebase.
More info: https://discord.com/channels/1129059589325852724/1129059590156337154/1155564202853937283
e8ed973
to
37a373a
Compare
import java.util.function.BiConsumer; | ||
import java.util.function.Consumer; | ||
|
||
public class CapabilitySystem { |
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.
Bracket on new line, please
public static <T, W> void addWrappedListener(Class<T> type, Class<W> wrappedClass, BiConsumer<AttachCapabilitiesEvent<T>, W> eventConsumer) | ||
{ | ||
if (!Item.class.isAssignableFrom(type)) throw new IllegalStateException("Unable to add Listener for Items. Use CapabilitySystem.addListener(Class, Consumer) for non Item related stuff"); | ||
LISTENER_LIST.computeIfAbsent(type, (e) -> new ArrayList<>()).add((cls) -> { |
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.
I don't remember if lambda brackets also go on new line. @LexManos?
@@ -448,4 +448,4 @@ default boolean shouldUpdateFluidWhileBoating(FluidState state, Boat boat) | |||
{ | |||
return boat.shouldUpdateFluidWhileRiding(state, self()); | |||
} | |||
} |
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.
Unnecessary whitespace edit
@@ -10,4 +10,4 @@ | |||
public interface IForgeLevelChunk extends ICapabilityProvider | |||
{ | |||
|
|||
} |
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.
Unnecessary whitespace edit
@@ -1250,5 +1250,4 @@ public static void handleClientConfigurationComplete(Connection connection) { | |||
} else | |||
LOGGER.info("Connected to a modded server."); | |||
} | |||
|
|||
} |
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.
Unnecessary whitespace edit
@@ -174,4 +174,4 @@ public <T> LazyOptional<T> getCapability(@NotNull Capability<T> capability, @Nul | |||
{ | |||
return ForgeCapabilities.FLUID_HANDLER_ITEM.orEmpty(capability, holder); | |||
} | |||
} |
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.
Unnecessary whitespace edit
if (caps.containsKey(key)) | ||
throw new IllegalStateException("Duplicate Capability Key: " + key + " " + cap); |
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.
Unnecessary whitespace edit (unless this is an intentional part of the refactor)
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.
Similar formatting issues to CapabilitySystem.java
. Inconsistent usage of new-line brackets.
[[mods]] | ||
modId="captest" | ||
|
||
[[mods]] | ||
modId="creative_mode_tab_test" | ||
|
||
[[mods]] | ||
modId="captest" |
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.
I think the test mod only needs to be declared in this file once.
@@ -40,26 +42,44 @@ public class CapabilitiesTest | |||
{ | |||
public static final String MODID = "capabilities_test"; | |||
|
|||
private static final boolean ENABLED = false; | |||
private static final boolean ENABLED = true; |
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.
Don't forget to disable this after the PR is out of draft state
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.
Good shit so far. It works a lot better than the horse shit we had before, especially with the explicit class listening. Obviously it needs a lot more testing, but it's headed in the right direction. Like I said in VC, I am happy to help with remedial shit like javadocs and the primer.
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 class needs javadocs, especially since it looks like modders are going to be interfacing with this.
{ | ||
public static final String MOD_ID = "captest"; | ||
private static final ConcurrentHashMap<Class<?>, AtomicInteger> TRACK = new ConcurrentHashMap<>(); | ||
private static final boolean ENABLED = true; |
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.
Remember to set this to false before marking the PR as ready!
…r.getAttachCapabilitiesEventFactory for getting the Event releated to AttachCapabilitiesEvent.java
…r.getAttachCapabilitiesEventFactory for getting the Event releated to AttachCapabilitiesEvent.java
…r.getAttachCapabilitiesEventFactory for getting the Event releated to AttachCapabilitiesEvent.java
…r.getAttachCapabilitiesEventFactory for getting the Event releated to AttachCapabilitiesEvent.java
…xception when attempting to setClassType() after being already set. Made AttachCapabilitiesEvent.java final, so it cannot be extended. Refactored CapabilitySystem field find -> LISTENER_LIST and static func find -> getListenerList.
28a0bda
to
7743132
Compare
@RealMangorage, this pull request has conflicts, please resolve them for this PR to move forward. |
38f5be7
to
f931293
Compare
@RealMangorage, this pull request has conflicts, please resolve them for this PR to move forward. |
cb455e6
to
2d5ba40
Compare
PR for reworking the AttachCapabillitiesEvent.
Currently in a prototype/testing stage.
What is currently made is not final product. Changes may occur.
Documentation: Proposal (WIP)
We add a new class which handles all event posts for AttachCapabilitiesEvent (Which now extends Event, and not GenericEvent)
> CapabilitySystem.java