-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev/1.20.1' into pr/420
- Loading branch information
Showing
464 changed files
with
9,129 additions
and
2,246 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.enderio.api.travel; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
public interface ITravelTarget { | ||
ResourceLocation getSerializationName(); | ||
|
||
BlockPos getPos(); | ||
|
||
CompoundTag save(); | ||
|
||
int getItem2BlockRange(); | ||
|
||
int getBlock2BlockRange(); | ||
|
||
default boolean canTravelTo() { | ||
return true; | ||
} | ||
} |
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,11 @@ | ||
package com.enderio.api.travel; | ||
|
||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraftforge.common.util.Lazy; | ||
|
||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
||
public record TravelEntry<T extends ITravelTarget>(ResourceLocation serializationName, Function<CompoundTag, T> constructor, | ||
Supplier<Lazy<TravelRenderer<T>>> renderer) {} |
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,46 @@ | ||
package com.enderio.api.travel; | ||
|
||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraftforge.common.util.Lazy; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
||
@ApiStatus.Internal | ||
public class TravelRegistry { | ||
|
||
private static final Map<ResourceLocation, TravelEntry<?>> registry = new HashMap<>(); | ||
|
||
public static <T extends ITravelTarget> void addTravelEntry(ResourceLocation serializationName, Function<CompoundTag, T> constructor, | ||
Supplier<Lazy<TravelRenderer<T>>> renderer) { | ||
registry.put(serializationName, new TravelEntry<>(serializationName, constructor, renderer)); | ||
} | ||
|
||
public static <T extends ITravelTarget> void addTravelEntry(TravelEntry<?> travelEntry) { | ||
registry.put(travelEntry.serializationName(), travelEntry); | ||
} | ||
|
||
public static <T extends ITravelTarget> TravelRenderer<T> getRenderer(T entry) { | ||
return (TravelRenderer<T>) registry.get(entry.getSerializationName()).renderer().get().get(); | ||
} | ||
|
||
public static Optional<ITravelTarget> deserialize(CompoundTag nbt) { | ||
return Optional.ofNullable(registry.get(new ResourceLocation(nbt.getString("name")))).map(entry -> entry.constructor().apply(nbt.getCompound("data"))); | ||
} | ||
|
||
public static boolean isRegistered(ITravelTarget target) { | ||
return registry.containsKey(target.getSerializationName()); | ||
} | ||
|
||
public static CompoundTag serialize(ITravelTarget travelData) { | ||
CompoundTag nbt = new CompoundTag(); | ||
nbt.putString("name", travelData.getSerializationName().toString()); | ||
nbt.put("data", travelData.save()); | ||
return nbt; | ||
} | ||
} |
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,8 @@ | ||
package com.enderio.api.travel; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import net.minecraft.client.renderer.LevelRenderer; | ||
|
||
public interface TravelRenderer<T extends ITravelTarget> { | ||
void render(T travelData, LevelRenderer levelRenderer, PoseStack poseStack, double distanceSquared, boolean active); | ||
} |
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,5 @@ | ||
@javax.annotation.ParametersAreNonnullByDefault | ||
@net.minecraft.MethodsReturnNonnullByDefault | ||
@com.tterrag.registrate.util.nullness.FieldsAreNonnullByDefault | ||
|
||
package com.enderio.api.travel; |
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
Oops, something went wrong.