Skip to content

Commit

Permalink
Merge pull request Arathain#5 from Arathain/buildscript-bork
Browse files Browse the repository at this point in the history
shit I forgot to change branch in dev env
  • Loading branch information
Arathain authored May 11, 2022
2 parents 8419fdb + 4a514ae commit 57ab732
Show file tree
Hide file tree
Showing 17 changed files with 132 additions and 27 deletions.
11 changes: 5 additions & 6 deletions src/main/java/net/arathain/tot/TomeOfTiamatha.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,24 @@
import net.arathain.tot.common.init.ToTObjects;
import net.arathain.tot.common.init.ToTScaleTypes;
import net.arathain.tot.common.network.packet.DriderComponentPacket;
import net.arathain.tot.common.network.packet.RemorsePacket;
import net.arathain.tot.common.util.ToTCallbacks;
import net.arathain.tot.common.util.config.ToTConfig;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
import org.quiltmc.qsl.item.group.api.QuiltItemGroup;
import org.quiltmc.qsl.networking.api.ServerPlayNetworking;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.bernie.geckolib3.GeckoLib;

public class TomeOfTiamatha implements ModInitializer {
public static String MODID = "tot";
public static final ItemGroup GROUP = FabricItemGroupBuilder.build(new Identifier(MODID, MODID), () -> new ItemStack(Blocks.MAGENTA_BED));
// public static final InventoryLock DRIDER_LOCK = Locki.registerLock(new Identifier(MODID, "drider"), true);
public static final ItemGroup GROUP = QuiltItemGroup.createWithIcon(new Identifier(MODID, MODID), () -> new ItemStack(ToTObjects.SILKSTEEL_HELMET));
public static final ToTConfig CONFIG = OmegaConfig.register(ToTConfig.class);
public static final Logger LOGGER = LoggerFactory.getLogger("tot");

Expand All @@ -37,6 +35,7 @@ public void onInitialize(ModContainer mod) {
ToTEffects.init();
ToTScaleTypes.init();
ServerPlayNetworking.registerGlobalReceiver(DriderComponentPacket.ID, DriderComponentPacket::handle);
ServerPlayNetworking.registerGlobalReceiver(RemorsePacket.ID, RemorsePacket::handle);
UseBlockCallback.EVENT.register(ToTCallbacks::stringUseEvent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public void setLivingAnimations(DriderEntity entity, Integer uniqueID, Animation
if(entity.isBlocking() && entity.getItemUseTimeLeft() > 0 && entity.getMainHandStack().getUseAction() == UseAction.BLOCK){
sendHelp.setRotationX(sendHelp.getRotationX() + (MinecraftClient.getInstance().isPaused() ? 0 : 1.3f));
sendHelp.setRotationY(sendHelp.getRotationY() + (MinecraftClient.getInstance().isPaused() ? 0 : 1));
} else if(entity.getItemUseTimeLeft() > 0 && (entity.getMainHandStack().getUseAction() == UseAction.SPEAR || entity.getOffHandStack().getUseAction() == UseAction.SPEAR)) {
sendHelp.setRotationZ(sendHelp.getRotationX() + (MinecraftClient.getInstance().isPaused() ? 0 : 2.8f));
} else if(entity.getItemUseTimeLeft() > 0 && (entity.getMainHandStack().getUseAction() == UseAction.BOW || entity.getOffHandStack().getUseAction() == UseAction.BOW)) {
sendHelp.setRotationX(sendHelp.getRotationX() + (MinecraftClient.getInstance().isPaused() ? 0 : 1.3f));
sendHelp.setRotationX(sendHelp.getRotationX() + (MinecraftClient.getInstance().isPaused() ? 0 :(extraData.headPitch * (float) Math.PI / 180F)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void render(MatrixStack matrixStackIn, VertexConsumerProvider bufferIn, i
if(packedLightIn < 50) {
Identifier location = new Identifier(TomeOfTiamatha.MODID, "textures/entity/drider/arachne/arachne_emissive.png");
RenderLayer armor = RenderLayer.getEyes(location);
this.getRenderer().render(this.getEntityModel().getModel(this.getEntityModel().getTextureLocation(entitylivingbaseIn)), entitylivingbaseIn, partialTicks, armor, matrixStackIn, bufferIn, bufferIn.getBuffer(armor), -packedLightIn, OverlayTexture.DEFAULT_UV, 1.0f, 1.0f, 1.0f, (MathHelper.clamp(120f - packedLightIn, 0, 120f) / 160f));
this.getRenderer().render(this.getEntityModel().getModel(this.getEntityModel().getModelLocation(entitylivingbaseIn)), entitylivingbaseIn, partialTicks, armor, matrixStackIn, bufferIn, bufferIn.getBuffer(armor), -packedLightIn, OverlayTexture.DEFAULT_UV, 1.0f, 1.0f, 1.0f, (MathHelper.clamp(120f - packedLightIn, 0, 120f) / 160f));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void render(MatrixStack matrixStackIn, VertexConsumerProvider bufferIn, i
if(!entitylivingbaseIn.getEquippedStack(EquipmentSlot.CHEST).isEmpty()) {
Identifier location = new Identifier(TomeOfTiamatha.MODID, "textures/entity/drider/armor/" + entitylivingbaseIn.getEquippedStack(EquipmentSlot.CHEST).getItem().toString() + ".png");
RenderLayer armor = RenderLayer.getArmorCutoutNoCull(location);
GeoModel model = this.getEntityModel().getModel(this.getEntityModel().getTextureLocation(entitylivingbaseIn));
GeoModel model = this.getEntityModel().getModel(this.getEntityModel().getModelLocation(entitylivingbaseIn));
model.getBone("spider").get().setHidden(true);
((DriderEntityRenderer) driderEntityRenderer).isLayer = true;
//model.getBone("leftarm").get().setHidden(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void render(MatrixStack matrixStackIn, VertexConsumerProvider bufferIn, i
location = new Identifier(TomeOfTiamatha.MODID, "textures/entity/drider/eyes/drider_arathain_eyes.png");
}
RenderLayer armor = RenderLayer.getEyes(location);
this.getRenderer().render(this.getEntityModel().getModel(this.getEntityModel().getTextureLocation(entitylivingbaseIn)), entitylivingbaseIn, partialTicks, armor, matrixStackIn, bufferIn, bufferIn.getBuffer(armor), -packedLightIn, OverlayTexture.DEFAULT_UV, 1.0f, 1.0f, 1.0f, (MathHelper.clamp(120f - packedLightIn, 0, 120f) / 160f));
this.getRenderer().render(this.getEntityModel().getModel(this.getEntityModel().getModelLocation(entitylivingbaseIn)), entitylivingbaseIn, partialTicks, armor, matrixStackIn, bufferIn, bufferIn.getBuffer(armor), -packedLightIn, OverlayTexture.DEFAULT_UV, 1.0f, 1.0f, 1.0f, (MathHelper.clamp(120f - packedLightIn, 0, 120f) / 160f));
((DriderEntityRenderer) this.getRenderer()).isLayer = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ public void render(MatrixStack matrixStackIn, VertexConsumerProvider bufferIn, i
if(!entitylivingbaseIn.getEquippedStack(EquipmentSlot.HEAD).isEmpty()) {
Identifier location = new Identifier(TomeOfTiamatha.MODID, "textures/entity/drider/armor/" + entitylivingbaseIn.getEquippedStack(EquipmentSlot.HEAD).getItem().toString() + ".png");
RenderLayer armor = RenderLayer.getArmorCutoutNoCull(location);
GeoModel model = this.getEntityModel().getModel(this.getEntityModel().getTextureLocation(entitylivingbaseIn));
GeoModel model = this.getEntityModel().getModel(this.getEntityModel().getModelLocation(entitylivingbaseIn));
model.getBone("spider").get().setHidden(true);
((DriderEntityRenderer) driderEntityRenderer).isLayer = true;
if (entitylivingbaseIn.getEquippedStack(EquipmentSlot.HEAD).getItem() instanceof DyeableArmorItem) {
int i = ((DyeableArmorItem)entitylivingbaseIn.getEquippedStack(EquipmentSlot.HEAD).getItem()).getColor((entitylivingbaseIn.getEquippedStack(EquipmentSlot.HEAD)));
float f = (float)(i >> 16 & 0xFF) / 255.0F;
float g = (float)(i >> 8 & 0xFF) / 255.0F;
float h = (float)(i & 0xFF) / 255.0F;
this.getRenderer().render(this.getEntityModel().getModel(this.getEntityModel().getTextureLocation(entitylivingbaseIn)), entitylivingbaseIn, partialTicks, armor, matrixStackIn, bufferIn, bufferIn.getBuffer(armor), packedLightIn, OverlayTexture.DEFAULT_UV, f, g, h, 1.0f);
this.getRenderer().render(this.getEntityModel().getModel(this.getEntityModel().getModelLocation(entitylivingbaseIn)), entitylivingbaseIn, partialTicks, armor, matrixStackIn, bufferIn, bufferIn.getBuffer(armor), packedLightIn, OverlayTexture.DEFAULT_UV, f, g, h, 1.0f);
}
else {
this.getRenderer().render(this.getEntityModel().getModel(this.getEntityModel().getTextureLocation(entitylivingbaseIn)), entitylivingbaseIn, partialTicks, armor, matrixStackIn, bufferIn, bufferIn.getBuffer(armor), packedLightIn, OverlayTexture.DEFAULT_UV, 1.0f, 1.0f, 1.0f, 1.0f);
this.getRenderer().render(this.getEntityModel().getModel(this.getEntityModel().getModelLocation(entitylivingbaseIn)), entitylivingbaseIn, partialTicks, armor, matrixStackIn, bufferIn, bufferIn.getBuffer(armor), packedLightIn, OverlayTexture.DEFAULT_UV, 1.0f, 1.0f, 1.0f, 1.0f);
}
((DriderEntityRenderer) driderEntityRenderer).isLayer = false;
model.getBone("spider").get().setHidden(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public WeavechildEyeLayer(IGeoRenderer<WeavechildEntity> entityRendererIn) {
public void render(MatrixStack matrixStackIn, VertexConsumerProvider bufferIn, int packedLightIn, WeavechildEntity entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
Identifier location = new Identifier(TomeOfTiamatha.MODID, "textures/entity/weavekin/weavechild_emissive.png");
RenderLayer armor = RenderLayer.getEyes(location);
this.getRenderer().render(this.getEntityModel().getModel(this.getEntityModel().getTextureLocation(entitylivingbaseIn)), entitylivingbaseIn, partialTicks, armor, matrixStackIn, bufferIn, bufferIn.getBuffer(armor), -packedLightIn, OverlayTexture.DEFAULT_UV, 1.0f, 1.0f, 1.0f, (MathHelper.clamp(120f - packedLightIn, 0, 120f) / 160f));
this.getRenderer().render(this.getEntityModel().getModel(this.getEntityModel().getModelLocation(entitylivingbaseIn)), entitylivingbaseIn, partialTicks, armor, matrixStackIn, bufferIn, bufferIn.getBuffer(armor), -packedLightIn, OverlayTexture.DEFAULT_UV, 1.0f, 1.0f, 1.0f, (MathHelper.clamp(120f - packedLightIn, 0, 120f) / 160f));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public WeavethrallEyeLayer(IGeoRenderer<WeavethrallEntity> entityRendererIn) {
public void render(MatrixStack matrixStackIn, VertexConsumerProvider bufferIn, int packedLightIn, WeavethrallEntity entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
Identifier location = new Identifier(TomeOfTiamatha.MODID, "textures/entity/weavekin/weavethrall_emissive.png");
RenderLayer armor = RenderLayer.getEyes(location);
this.getRenderer().render(this.getEntityModel().getModel(this.getEntityModel().getTextureLocation(entitylivingbaseIn)), entitylivingbaseIn, partialTicks, armor, matrixStackIn, bufferIn, bufferIn.getBuffer(armor), -packedLightIn, OverlayTexture.DEFAULT_UV, 1.0f, 1.0f, 1.0f, (MathHelper.clamp(120f - packedLightIn, 0, 120f) / 160f));
this.getRenderer().render(this.getEntityModel().getModel(this.getEntityModel().getModelLocation(entitylivingbaseIn)), entitylivingbaseIn, partialTicks, armor, matrixStackIn, bufferIn, bufferIn.getBuffer(armor), -packedLightIn, OverlayTexture.DEFAULT_UV, 1.0f, 1.0f, 1.0f, (MathHelper.clamp(120f - packedLightIn, 0, 120f) / 160f));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ private void renderStringLink(StringLink link, float tickDelta, MatrixStack matr
Vec3f offset = Helper.getChainOffset(srcPos, dstPos);
matrices.translate(offset.getX(), 0, offset.getZ());

// Now we gather light information for the chain. Since the chain is lighter if there is more light.
BlockPos blockPosOfStart = new BlockPos(MathHelper.lerp(0.2, fromEntity.getCameraPosVec(tickDelta).x, toEntity.getCameraPosVec(tickDelta).x), MathHelper.lerp(0.2, fromEntity.getCameraPosVec(tickDelta).y, toEntity.getCameraPosVec(tickDelta).y), MathHelper.lerp(0.2, fromEntity.getCameraPosVec(tickDelta).z, toEntity.getCameraPosVec(tickDelta).z));
BlockPos blockPosOfEnd = new BlockPos(MathHelper.lerp(0.8, fromEntity.getCameraPosVec(tickDelta).x, toEntity.getCameraPosVec(tickDelta).x), MathHelper.lerp(0.8, fromEntity.getCameraPosVec(tickDelta).y, toEntity.getCameraPosVec(tickDelta).y), MathHelper.lerp(0.8, fromEntity.getCameraPosVec(tickDelta).z, toEntity.getCameraPosVec(tickDelta).z));
// Now we gather light information for the string. This is janky, but it somewhat works.
BlockPos blockPosOfStart = new BlockPos(MathHelper.lerp(0.3, fromEntity.getCameraPosVec(tickDelta).x, toEntity.getCameraPosVec(tickDelta).x), MathHelper.lerp(0.3, fromEntity.getCameraPosVec(tickDelta).y, toEntity.getCameraPosVec(tickDelta).y), MathHelper.lerp(0.3, fromEntity.getCameraPosVec(tickDelta).z, toEntity.getCameraPosVec(tickDelta).z));
BlockPos blockPosOfEnd = new BlockPos(MathHelper.lerp(0.7, fromEntity.getCameraPosVec(tickDelta).x, toEntity.getCameraPosVec(tickDelta).x), MathHelper.lerp(0.7, fromEntity.getCameraPosVec(tickDelta).y, toEntity.getCameraPosVec(tickDelta).y), MathHelper.lerp(0.7, fromEntity.getCameraPosVec(tickDelta).z, toEntity.getCameraPosVec(tickDelta).z));
int blockLightLevelOfStart = fromEntity.world.getLightLevel(LightType.BLOCK, blockPosOfStart);
int blockLightLevelOfEnd = toEntity.world.getLightLevel(LightType.BLOCK, blockPosOfEnd);
int skylightLevelOfStart = fromEntity.world.getLightLevel(LightType.SKY, blockPosOfStart);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public void tick() {
if (this.attackCooldown == 0) {
this.attack();
this.nevermore.playSound(this.nevermore.getAttackSound(), 1.0F, 1.0F);
this.nevermore.stopAnger();
}
}
protected abstract int getCooldown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import net.arathain.tot.common.init.ToTEffects;
import net.arathain.tot.common.init.ToTEntities;
import net.arathain.tot.common.init.ToTScaleTypes;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.PacketSender;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
Expand All @@ -17,6 +15,8 @@
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;
import org.quiltmc.qsl.networking.api.PacketSender;
import org.quiltmc.qsl.networking.api.client.ClientPlayNetworking;
import virtuoel.pehkui.api.ScaleData;

public class DriderComponentPacket {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package net.arathain.tot.common.network.packet;

import net.arathain.tot.TomeOfTiamatha;
import net.arathain.tot.common.init.ToTObjects;
import net.fabricmc.fabric.impl.networking.ClientSidePacketRegistryImpl;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityGroup;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import org.quiltmc.qsl.networking.api.PacketByteBufs;
import org.quiltmc.qsl.networking.api.PacketSender;

import javax.annotation.Nullable;

public class RemorsePacket {
public static final Identifier ID = new Identifier(TomeOfTiamatha.MODID, "remorse");

public static void send(@Nullable Entity entity) {
PacketByteBuf buf = PacketByteBufs.create();

if(entity != null)
buf.writeInt(entity.getId());

ClientSidePacketRegistryImpl.INSTANCE.sendToServer(ID, buf);
}

public static void handle(MinecraftServer server, ServerPlayerEntity player, ServerPlayNetworkHandler network, PacketByteBuf buf, PacketSender sender) {
int entityId = buf.isReadable() ? buf.readInt() : -1;

server.execute(() -> {
if(player.getStackInHand(Hand.MAIN_HAND).getItem().equals(ToTObjects.REMORSE)) {
float f = (float)player.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE);
float g;
g = EnchantmentHelper.getAttackDamage(player.getMainHandStack(), player.getGroup());

float h = player.getAttackCooldownProgress(0.5F);
f *= 0.2F + h * h * 0.8F;
g *= h;
f += g;
player.damage(DamageSource.player(player), f);
}
});
}
}
52 changes: 52 additions & 0 deletions src/main/java/net/arathain/tot/mixin/MinecraftClientMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package net.arathain.tot.mixin;

import net.arathain.tot.common.init.ToTObjects;
import net.arathain.tot.common.item.RemorseItem;
import net.arathain.tot.common.network.packet.RemorsePacket;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.option.KeyBind;
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.hit.HitResult;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import javax.annotation.Nullable;
import javax.swing.text.JTextComponent;

@Mixin(MinecraftClient.class)
public abstract class MinecraftClientMixin {
@Shadow @Nullable
public ClientPlayerEntity player;
@Shadow protected int attackCooldown;
@Shadow
@Nullable public HitResult crosshairTarget;
@Unique
private boolean attackQueued = false;


@Inject(method = "handleInputEvents", at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/MinecraftClient;doAttack()Z",
ordinal = 0
))
public void combattweaks$handleAttacking(CallbackInfo info) {
if(player != null) {
if(player.getStackInHand(player.getActiveHand()).isOf(ToTObjects.REMORSE)) {
if(player.getAttackCooldownProgress(0.5F) == 1F && (!player.getItemCooldownManager().isCoolingDown(player.getMainHandStack().getItem())) && crosshairTarget != null) {
RemorsePacket.send(crosshairTarget.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) crosshairTarget).getEntity() : null);

if(crosshairTarget.getType() == HitResult.Type.BLOCK)
player.resetLastAttackedTicks();
}
}
}

if(!info.isCancelled() && attackQueued)
attackQueued = false;
}
}
Loading

0 comments on commit 57ab732

Please sign in to comment.