-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bro I learned Java reflection at past day and right now I am using it XDDDD
- Loading branch information
1 parent
910d661
commit be1714e
Showing
21 changed files
with
297 additions
and
221 deletions.
There are no files selected for viewing
11 changes: 0 additions & 11 deletions
11
fabric/src/main/java/org/mtr/mapping/registry/RegistryHelper.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
fabric/src/main/java/ziyue/tjmetro/mapping/RegistryHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package ziyue.tjmetro.mapping; | ||
|
||
import org.mtr.mapping.holder.Identifier; | ||
import org.mtr.mapping.holder.Item; | ||
import org.mtr.mapping.registry.BlockRegistryObject; | ||
import org.mtr.mapping.registry.ItemRegistryObject; | ||
|
||
import java.lang.reflect.Constructor; | ||
import java.lang.reflect.InvocationTargetException; | ||
|
||
/** | ||
* Converting block to item. This may not be stable since it uses reflection. | ||
* | ||
* @author ZiYueCommentary | ||
* @since 1.0.0-beta-2 | ||
*/ | ||
|
||
// This is a very mad way but I have no choice. | ||
public interface RegistryHelper | ||
{ | ||
static ItemRegistryObject RegistryObjectBlock2Item(BlockRegistryObject fabric, Identifier forge) | ||
throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException { | ||
Class<ItemRegistryObject> clazz = ItemRegistryObject.class; | ||
Constructor<ItemRegistryObject> constructor = clazz.getDeclaredConstructor(Item.class); | ||
constructor.setAccessible(true); | ||
return constructor.newInstance(fabric.get().asItem()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.