-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
145556d
commit 7823556
Showing
14 changed files
with
559 additions
and
46 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
13 changes: 13 additions & 0 deletions
13
src/main/java/com/github/tartaricacid/touhoulittlemaid/api/entity/fishing/IFishingType.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,13 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.api.entity.fishing; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid; | ||
import com.github.tartaricacid.touhoulittlemaid.entity.projectile.MaidFishingHook; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.phys.Vec3; | ||
|
||
public interface IFishingType { | ||
boolean isFishingRod(ItemStack itemStack); | ||
|
||
MaidFishingHook getFishingHook(EntityMaid maid, Level level, ItemStack itemStack, Vec3 pos); | ||
} |
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
45 changes: 45 additions & 0 deletions
45
...n/java/com/github/tartaricacid/touhoulittlemaid/compat/aquaculture/AquacultureCompat.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,45 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.compat.aquaculture; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.compat.aquaculture.client.AquacultureClientRegister; | ||
import com.github.tartaricacid.touhoulittlemaid.compat.aquaculture.entity.AquacultureFishingHook; | ||
import com.github.tartaricacid.touhoulittlemaid.compat.aquaculture.entity.AquacultureFishingType; | ||
import com.github.tartaricacid.touhoulittlemaid.entity.ai.fishing.FishingTypeManager; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.eventbus.api.IEventBus; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; | ||
import net.minecraftforge.fml.loading.FMLEnvironment; | ||
import net.minecraftforge.fml.loading.LoadingModList; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
import net.minecraftforge.registries.RegisterEvent; | ||
|
||
public class AquacultureCompat { | ||
private static final String MOD_ID = "aquaculture"; | ||
private static boolean INSTALLED; | ||
|
||
public static void init() { | ||
INSTALLED = LoadingModList.get().getModFileById(MOD_ID) != null; | ||
if (INSTALLED) { | ||
registerAll(); | ||
} | ||
} | ||
|
||
public static void registerFishingType(FishingTypeManager manager) { | ||
if (INSTALLED) { | ||
manager.addFishingType(new AquacultureFishingType()); | ||
} | ||
} | ||
|
||
private static void registerAll() { | ||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); | ||
modEventBus.register(new AquacultureCompat()); | ||
if (FMLEnvironment.dist == Dist.CLIENT) { | ||
modEventBus.register(new AquacultureClientRegister()); | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public void register(RegisterEvent event) { | ||
event.register(ForgeRegistries.Keys.ENTITY_TYPES, helper -> helper.register("aquaculture_fishing_hook", AquacultureFishingHook.TYPE)); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ub/tartaricacid/touhoulittlemaid/compat/aquaculture/client/AquacultureClientRegister.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,15 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.compat.aquaculture.client; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.compat.aquaculture.entity.AquacultureFishingHook; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.api.distmarker.OnlyIn; | ||
import net.minecraftforge.client.event.EntityRenderersEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
|
||
@OnlyIn(Dist.CLIENT) | ||
public class AquacultureClientRegister { | ||
@SubscribeEvent | ||
public void onEntityRenderers(EntityRenderersEvent.RegisterRenderers event) { | ||
event.registerEntityRenderer(AquacultureFishingHook.TYPE, AquacultureFishingHookRenderer::new); | ||
} | ||
} |
112 changes: 112 additions & 0 deletions
112
...rtaricacid/touhoulittlemaid/compat/aquaculture/client/AquacultureFishingHookRenderer.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,112 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.compat.aquaculture.client; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.client.renderer.entity.MaidFishingHookRenderer; | ||
import com.github.tartaricacid.touhoulittlemaid.compat.aquaculture.entity.AquacultureFishingHook; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.blaze3d.vertex.VertexConsumer; | ||
import com.mojang.math.Axis; | ||
import com.teammetallurgy.aquaculture.Aquaculture; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.client.renderer.entity.EntityRendererProvider; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.DyeableLeatherItem; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.api.distmarker.OnlyIn; | ||
import org.joml.Matrix3f; | ||
import org.joml.Matrix4f; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
@OnlyIn(Dist.CLIENT) | ||
public class AquacultureFishingHookRenderer extends MaidFishingHookRenderer<AquacultureFishingHook> { | ||
private static final ResourceLocation BOBBER = new ResourceLocation(Aquaculture.MOD_ID, "textures/entity/rod/bobber/bobber.png"); | ||
private static final ResourceLocation BOBBER_OVERLAY = new ResourceLocation(Aquaculture.MOD_ID, "textures/entity/rod/bobber/bobber_overlay.png"); | ||
private static final ResourceLocation BOBBER_VANILLA = new ResourceLocation(Aquaculture.MOD_ID, "textures/entity/rod/bobber/bobber_vanilla.png"); | ||
private static final ResourceLocation HOOK = new ResourceLocation(Aquaculture.MOD_ID, "textures/entity/rod/hook/hook.png"); | ||
private static final RenderType BOBBER_RENDER = RenderType.entityCutout(BOBBER); | ||
private static final RenderType BOBBER_OVERLAY_RENDER = RenderType.entityCutout(BOBBER_OVERLAY); | ||
private static final RenderType BOBBER_VANILLA_RENDER = RenderType.entityCutout(BOBBER_VANILLA); | ||
private static final RenderType HOOK_RENDER = RenderType.entityCutout(HOOK); | ||
|
||
public AquacultureFishingHookRenderer(EntityRendererProvider.Context context) { | ||
super(context); | ||
} | ||
|
||
@Override | ||
protected void renderBobber(AquacultureFishingHook fishingHook, PoseStack poseStack, MultiBufferSource buffer, int packedLight) { | ||
poseStack.pushPose(); | ||
poseStack.scale(0.5F, 0.5F, 0.5F); | ||
poseStack.mulPose(this.entityRenderDispatcher.cameraOrientation()); | ||
poseStack.mulPose(Axis.YP.rotationDegrees(180.0F)); | ||
|
||
PoseStack.Pose lasted = poseStack.last(); | ||
Matrix4f lastedPose = lasted.pose(); | ||
Matrix3f lastedNormal = lasted.normal(); | ||
|
||
VertexConsumer consumer = fishingHook.hasBobber() ? buffer.getBuffer(BOBBER_OVERLAY_RENDER) : buffer.getBuffer(BOBBER_VANILLA_RENDER); | ||
|
||
// Bobber Overlay | ||
ItemStack bobberStack = fishingHook.getBobber(); | ||
float bobberR = 1.0F; | ||
float bobberG = 1.0F; | ||
float bobberB = 1.0F; | ||
if (!bobberStack.isEmpty()) { | ||
if (bobberStack.getItem() instanceof DyeableLeatherItem) { | ||
int colorInt = ((DyeableLeatherItem) bobberStack.getItem()).getColor(bobberStack); | ||
bobberR = (float) (colorInt >> 16 & 255) / 255.0F; | ||
bobberG = (float) (colorInt >> 8 & 255) / 255.0F; | ||
bobberB = (float) (colorInt & 255) / 255.0F; | ||
} | ||
} | ||
vertex(consumer, lastedPose, lastedNormal, packedLight, 0.0F, 0, 0, 1, bobberR, bobberG, bobberB); | ||
vertex(consumer, lastedPose, lastedNormal, packedLight, 1.0F, 0, 1, 1, bobberR, bobberG, bobberB); | ||
vertex(consumer, lastedPose, lastedNormal, packedLight, 1.0F, 1, 1, 0, bobberR, bobberG, bobberB); | ||
vertex(consumer, lastedPose, lastedNormal, packedLight, 0.0F, 1, 0, 0, bobberR, bobberG, bobberB); | ||
|
||
// Bobber Background | ||
if (fishingHook.hasBobber()) { | ||
VertexConsumer bobberVertex = buffer.getBuffer(BOBBER_RENDER); | ||
renderPosTexture(bobberVertex, lastedPose, lastedNormal, packedLight, 0.0F, 0, 0, 1); | ||
renderPosTexture(bobberVertex, lastedPose, lastedNormal, packedLight, 1.0F, 0, 1, 1); | ||
renderPosTexture(bobberVertex, lastedPose, lastedNormal, packedLight, 1.0F, 1, 1, 0); | ||
renderPosTexture(bobberVertex, lastedPose, lastedNormal, packedLight, 0.0F, 1, 0, 0); | ||
} | ||
|
||
// Hook | ||
RenderType renderType = RenderType.entityCutout(fishingHook.getHook().getTexture()); | ||
VertexConsumer hookVertex = fishingHook.hasHook() ? buffer.getBuffer(renderType) : buffer.getBuffer(HOOK_RENDER); | ||
renderPosTexture(hookVertex, lastedPose, lastedNormal, packedLight, 0.0F, 0, 0, 1); | ||
renderPosTexture(hookVertex, lastedPose, lastedNormal, packedLight, 1.0F, 0, 1, 1); | ||
renderPosTexture(hookVertex, lastedPose, lastedNormal, packedLight, 1.0F, 1, 1, 0); | ||
renderPosTexture(hookVertex, lastedPose, lastedNormal, packedLight, 0.0F, 1, 0, 0); | ||
|
||
poseStack.popPose(); | ||
} | ||
|
||
@Override | ||
protected float[] getLineColor(AquacultureFishingHook fishingHook) { | ||
// Line color | ||
ItemStack line = fishingHook.getFishingLine(); | ||
float r = 0; | ||
float g = 0; | ||
float b = 0; | ||
if (!line.isEmpty()) { | ||
DyeableLeatherItem lineItem = (DyeableLeatherItem) line.getItem(); | ||
if (lineItem.hasCustomColor(line)) { | ||
int colorInt = lineItem.getColor(line); | ||
r = (float) (colorInt >> 16 & 255) / 255.0F; | ||
g = (float) (colorInt >> 8 & 255) / 255.0F; | ||
b = (float) (colorInt & 255) / 255.0F; | ||
} | ||
} | ||
return new float[]{r, g, b}; | ||
} | ||
|
||
@Override | ||
@Nonnull | ||
public ResourceLocation getTextureLocation(@Nonnull AquacultureFishingHook fishHook) { | ||
return BOBBER_VANILLA; | ||
} | ||
} |
Oops, something went wrong.