Skip to content

Commit

Permalink
final commit b4 update here we gooo
Browse files Browse the repository at this point in the history
  • Loading branch information
ANightDazingZoroark committed Jul 3, 2024
1 parent d3c49e4 commit fc72670
Show file tree
Hide file tree
Showing 25 changed files with 403 additions and 32 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ dependencies {
compileOnly "curse.maven:mysticalmechanics-300742:3006392"
compileOnly "mezz.jei:jei_${mc_version}:${jei_version}:api"
compileOnly "curse.maven:crafttweaker-239197:5354089"
compileOnly files("libs/Hwyla-1.8.26-B41_1.12.2-api.jar")
implementation "mezz.jei:jei_${mc_version}:${jei_version}"
}

Expand Down
Binary file added libs/Hwyla-1.8.26-B41_1.12.2-api.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,11 @@ public void renderEgg(int posX, int posY, int scaleValue, float renderYaw, float
GlStateManager.rotate(-45.0F, 0.0F, 1.0F, 0.0F);
RenderHelper.enableStandardItemLighting();
GlStateManager.rotate(-135.0F, 0.0F, 0.0F, 0.0F);
GlStateManager.rotate(-180.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(-((float) Math.atan(renderPitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F);
egg.rotationYaw = (float) Math.atan(renderYaw / 40.0F) * 40.0F;
egg.rotationPitch = -((float) Math.atan(renderPitch / 40.0F)) * 20.0F;
GlStateManager.translate(0.0F, (float) egg.getYOffset(), 0.0F);
GlStateManager.translate(0.0F, -0.125F, 0.0F);
GlStateManager.rotate(egg.ticksExisted, 0.0F, 1.0F, 0.0F);
Minecraft.getMinecraft().getRenderManager().playerViewY = 180.0F;
Minecraft.getMinecraft().getRenderManager().renderEntity(egg, 0.0D, 0.0D, 0.0D, 0.0F, 0F, false);
Expand All @@ -230,10 +231,12 @@ else if (this.hatchable instanceof RiftSac) {
GlStateManager.rotate(-45.0F, 0.0F, 1.0F, 0.0F);
RenderHelper.enableStandardItemLighting();
GlStateManager.rotate(-135.0F, 0.0F, 0.0F, 0.0F);
GlStateManager.rotate(-180.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(-((float) Math.atan(renderPitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F);
sac.rotationYaw = (float) Math.atan(renderYaw / 40.0F) * 40.0F;
sac.rotationPitch = -((float) Math.atan(renderPitch / 40.0F)) * 20.0F;
GlStateManager.translate(0.0F, (float) sac.getYOffset(), 0.0F);
GlStateManager.translate(0.0F, -0.125F, 0.0F);
GlStateManager.rotate(sac.ticksExisted, 0.0F, 1.0F, 0.0F);
Minecraft.getMinecraft().getRenderManager().playerViewY = 180.0F;
Minecraft.getMinecraft().getRenderManager().renderEntity(sac, 0.0D, 0.0D, 0.0D, 0.0F, 0F, false);
Expand All @@ -253,10 +256,12 @@ else if (this.hatchable instanceof IImpregnable) {
GlStateManager.rotate(-45.0F, 0.0F, 1.0F, 0.0F);
RenderHelper.enableStandardItemLighting();
GlStateManager.rotate(-135.0F, 0.0F, 0.0F, 0.0F);
GlStateManager.rotate(-180.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(-((float) Math.atan(renderPitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F);
embryo.rotationYaw = (float) Math.atan(renderYaw / 40.0F) * 40.0F;
embryo.rotationPitch = -((float) Math.atan(renderPitch / 40.0F)) * 20.0F;
GlStateManager.translate(0.0F, (float) embryo.getYOffset(), 0.0F);
GlStateManager.translate(0.0F, -0.225F, 0.0F);
GlStateManager.rotate(this.embryoRotation++, 0.0F, 1.0F, 0.0F);
Minecraft.getMinecraft().getRenderManager().playerViewY = 180.0F;
Minecraft.getMinecraft().getRenderManager().renderEntity(embryo, 0.0D, 0.0D, 0.0D, 0.0F, 0F, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
private void drawProgressBar() {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
float progress = (float)this.semiManualPresser.getTopTEntity().getTimeHeld();
System.out.println("progress: "+progress);
float max = (float)this.semiManualPresser.getTopTEntity().getMaxRecipeTime();
float fill = progress / max * 21f;
this.mc.getTextureManager().bindTexture(progressBar);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package anightdazingzoroark.prift.compat.hwyla;

import anightdazingzoroark.prift.RiftInitialize;
import anightdazingzoroark.prift.compat.hwyla.provider.RiftBlowPoweredTurbineProvider;
import anightdazingzoroark.prift.compat.hwyla.provider.RiftCrankProvider;
import anightdazingzoroark.prift.compat.hwyla.provider.RiftCreaturePartProvider;
import anightdazingzoroark.prift.compat.hwyla.provider.RiftSemiManualMachineProvider;
import anightdazingzoroark.prift.compat.mysticalmechanics.tileentities.*;
import anightdazingzoroark.prift.config.GeneralConfig;
import anightdazingzoroark.prift.server.entity.creature.RiftCreaturePart;
import mcp.mobius.waila.api.IWailaPlugin;
import mcp.mobius.waila.api.IWailaRegistrar;
import mcp.mobius.waila.api.WailaPlugin;

@WailaPlugin(RiftInitialize.MODID)
public class RiftHWYLA implements IWailaPlugin {
@Override
public void register(IWailaRegistrar registrar) {
RiftCreaturePartProvider creaturePartProvider = new RiftCreaturePartProvider();
registrar.registerHeadProvider(creaturePartProvider, RiftCreaturePart.class);
registrar.registerBodyProvider(creaturePartProvider, RiftCreaturePart.class);
registrar.registerTailProvider(creaturePartProvider, RiftCreaturePart.class);

if (GeneralConfig.canUseMM()) {
RiftBlowPoweredTurbineProvider turbineProvider = new RiftBlowPoweredTurbineProvider();
registrar.registerBodyProvider(turbineProvider, TileEntityBlowPoweredTurbine.class);
registrar.registerBodyProvider(turbineProvider, TileEntityBlowPoweredTurbinePart.class);

RiftCrankProvider leadPoweredCrankProvider = new RiftCrankProvider();
registrar.registerBodyProvider(leadPoweredCrankProvider, TileEntityHandCrank.class);
registrar.registerBodyProvider(leadPoweredCrankProvider, TileEntityLeadPoweredCrank.class);

RiftSemiManualMachineProvider smPresserProvider = new RiftSemiManualMachineProvider();
registrar.registerBodyProvider(smPresserProvider, TileEntitySemiManualExtractor.class);
registrar.registerBodyProvider(smPresserProvider, TileEntitySemiManualExtractorTop.class);
registrar.registerBodyProvider(smPresserProvider, TileEntitySemiManualPresser.class);
registrar.registerBodyProvider(smPresserProvider, TileEntitySemiManualPresserTop.class);
registrar.registerBodyProvider(smPresserProvider, TileEntitySemiManualExtruder.class);
registrar.registerBodyProvider(smPresserProvider, TileEntitySemiManualExtruderTop.class);
registrar.registerBodyProvider(smPresserProvider, TileEntitySemiManualHammerer.class);
registrar.registerBodyProvider(smPresserProvider, TileEntitySemiManualHammererTop.class);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package anightdazingzoroark.prift.compat.hwyla.provider;

import anightdazingzoroark.prift.compat.mysticalmechanics.tileentities.TileEntityBlowPoweredTurbine;
import anightdazingzoroark.prift.compat.mysticalmechanics.tileentities.TileEntityBlowPoweredTurbinePart;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;

import javax.annotation.Nonnull;
import java.util.List;

public class RiftBlowPoweredTurbineProvider implements IWailaDataProvider {
@Nonnull
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> tooltip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
TileEntity tileEntity = accessor.getTileEntity();
if (tileEntity instanceof TileEntityBlowPoweredTurbine) {
TileEntityBlowPoweredTurbine turbine = (TileEntityBlowPoweredTurbine) tileEntity;
tooltip.add(I18n.format("hwyla.power_created", (int)turbine.getPower()+".0 R"));
}
else if (tileEntity instanceof TileEntityBlowPoweredTurbinePart) {
TileEntityBlowPoweredTurbinePart turbinePart = (TileEntityBlowPoweredTurbinePart)tileEntity;
TileEntityBlowPoweredTurbine turbine = turbinePart.getTurbine();
int power = (int)turbine.getPower();
tooltip.add(I18n.format("hwyla.power_created", power+".0 R"));
}
return tooltip;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package anightdazingzoroark.prift.compat.hwyla.provider;

import anightdazingzoroark.prift.compat.mysticalmechanics.tileentities.TileEntityHandCrank;
import anightdazingzoroark.prift.compat.mysticalmechanics.tileentities.TileEntityLeadPoweredCrank;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;

import javax.annotation.Nonnull;
import java.util.List;

public class RiftCrankProvider implements IWailaDataProvider {
@Nonnull
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> tooltip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
TileEntity tileEntity = accessor.getTileEntity();
if (tileEntity instanceof TileEntityHandCrank) {
TileEntityHandCrank handCrank = (TileEntityHandCrank) tileEntity;
tooltip.add(I18n.format("hwyla.power_created", (int)handCrank.getPower()+".0 R"));
}
if (tileEntity instanceof TileEntityLeadPoweredCrank) {
TileEntityLeadPoweredCrank leadPoweredCrank = (TileEntityLeadPoweredCrank) tileEntity;
tooltip.add(I18n.format("hwyla.power_created", leadPoweredCrank.mechPower.getPower(null)+" R"));
}
return tooltip;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package anightdazingzoroark.prift.compat.hwyla.provider;

import anightdazingzoroark.prift.RiftInitialize;
import anightdazingzoroark.prift.server.entity.creature.RiftCreaturePart;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaEntityAccessor;
import mcp.mobius.waila.api.IWailaEntityProvider;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.Entity;
import net.minecraft.util.text.TextFormatting;

import javax.annotation.Nonnull;
import java.util.List;

public class RiftCreaturePartProvider implements IWailaEntityProvider {
@Nonnull
@Override
public List<String> getWailaHead(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
currenttip.clear();
RiftCreaturePart part = (RiftCreaturePart) entity;
if (part != null) {
String creatureName = TextFormatting.WHITE + part.getParent().getName(false);
String level = TextFormatting.GRAY + I18n.format("tametrait.level", part.getParent().getLevel());
currenttip.add(creatureName + " (" + level + ")");
}
return currenttip;
}

@Nonnull
@Override
public List<String> getWailaBody(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
RiftCreaturePart part = (RiftCreaturePart) entity;
if (part != null && config.getConfig("general.showhp")) {
int currentHealth = (int)part.getParent().getHealth();
int maxHealth = (int)part.getParent().getMaxHealth();
currenttip.add(I18n.format("hwyla.health", currentHealth, maxHealth));
}
return currenttip;
}

@Nonnull
@Override
public List<String> getWailaTail(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
currenttip.clear();
currenttip.add(TextFormatting.BLUE + "" + TextFormatting.ITALIC + RiftInitialize.MODNAME);
return currenttip;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package anightdazingzoroark.prift.compat.hwyla.provider;

import anightdazingzoroark.prift.compat.mysticalmechanics.tileentities.TileEntitySemiManualBase;
import anightdazingzoroark.prift.compat.mysticalmechanics.tileentities.TileEntitySemiManualTopBase;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;

import javax.annotation.Nonnull;
import java.util.List;

public class RiftSemiManualMachineProvider implements IWailaDataProvider {
@Nonnull
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> tooltip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
TileEntity tileEntity = accessor.getTileEntity();
if (tileEntity instanceof TileEntitySemiManualBase) {
TileEntitySemiManualBase baseTE = (TileEntitySemiManualBase) tileEntity;
tooltip.add(I18n.format("hwyla.power_consumed", (int)baseTE.getTopTEntity().getPower()+".0 R"));
}
else if (tileEntity instanceof TileEntitySemiManualTopBase) {
TileEntitySemiManualTopBase topTe = (TileEntitySemiManualTopBase) tileEntity;
tooltip.add(I18n.format("hwyla.power_consumed", (int)topTe.getPower()+".0 R"));
}
return tooltip;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraftforge.common.capabilities.Capability;
import software.bernie.geckolib3.core.IAnimatable;
import software.bernie.geckolib3.core.PlayState;
Expand Down Expand Up @@ -197,4 +198,9 @@ private <E extends IAnimatable> PlayState rotation(AnimationEvent<E> event) {
public AnimationFactory getFactory() {
return this.factory;
}

@Override
public AxisAlignedBB getRenderBoundingBox() {
return new AxisAlignedBB(this.getPos().add(-1, -1, -1), this.getPos().add(1, 2, 1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public void setCenterBlockPos(BlockPos centerBlockPos) {
}
}

public TileEntityBlowPoweredTurbine getTurbine() {
return (TileEntityBlowPoweredTurbine) this.world.getTileEntity(this.getCenterBlockPos());
}

@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);
Expand All @@ -36,6 +40,11 @@ public void readFromNBT(NBTTagCompound compound) {
this.centerBlockPos = new BlockPos(compound.getInteger("centerPosX"), compound.getInteger("centerPosY"), compound.getInteger("centerPosZ"));
}

@Override
public NBTTagCompound getUpdateTag() {
return this.writeToNBT(new NBTTagCompound());
}

@Override
public void handleUpdateTag(NBTTagCompound tag) {
this.centerBlockPos = new BlockPos(tag.getInteger("centerPosX"), tag.getInteger("centerPosY"), tag.getInteger("centerPosZ"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package anightdazingzoroark.prift.compat.mysticalmechanics.tileentities;

import anightdazingzoroark.prift.compat.mysticalmechanics.recipes.RiftMMRecipes;
import anightdazingzoroark.prift.compat.mysticalmechanics.recipes.SemiManualExtruderRecipe;
import anightdazingzoroark.prift.compat.mysticalmechanics.recipes.SemiManualPresserRecipe;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;

public class TileEntitySemiManualPresser extends TileEntitySemiManualBase {
public TileEntitySemiManualPresser() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public void preInit(FMLPreInitializationEvent e) {
RiftItems.registerItems();
RiftTileEntities.registerTileEntities();
RiftItems.registerOreDicTags();
RiftBlocks.registerOreDicTags();
RiftRecipes.registerSmelting();
if (GeneralConfig.canUseMM()) RiftMMRecipes.registerRecipes();
RiftCrafttweaker.loadCrafttweakerCompat();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.registries.IForgeRegistry;

import java.util.ArrayList;
Expand Down Expand Up @@ -44,6 +45,11 @@ public static void registerBlocks() {
if (GeneralConfig.canUseMM()) RiftMMBlocks.registerMMBlocks();
}

public static void registerOreDicTags() {
OreDictionary.registerOre("grass", RiftBlocks.PYROBERRY_BUSH);
OreDictionary.registerOre("grass", RiftBlocks.CRYOBERRY_BUSH);
}

public static Block registerBlock(Block block, String registryName, boolean includeItem) {
return registerBlock(block, registryName, includeItem, true, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,27 +142,29 @@ protected void checkAndPerformAttack(EntityLivingBase enemy, double distToEnemyS

if (--this.attackCooldown <= 0) {
if (distToEnemySqr <= d0) this.attacker.setAttacking(true);
if (this.animTime == 0) this.attacker.removeSpeed();
this.animTime++;
if (this.animTime == this.attackAnimTime) {
if (distToEnemySqr <= d0) this.attacker.attackEntityAsMob(enemy);
}
if (this.animTime > this.attackAnimLength + 1) {
this.animTime = 0;
this.attacker.setAttacking(false);
this.attackCooldown = 20;
this.attacker.resetSpeed();
if (this.attacker.isTamed()) this.attacker.energyActionMod++;
if (this.attacker.isAttacking()) {
this.animTime++;
if (this.animTime == this.attackAnimTime) {
this.attacker.removeSpeed();
if (distToEnemySqr <= d0) this.attacker.attackEntityAsMob(enemy);
}
if (this.animTime > this.attackAnimLength + 1) {
this.animTime = 0;
this.attacker.setAttacking(false);
this.attackCooldown = 20;
this.attacker.resetSpeed();
if (this.attacker.isTamed()) this.attacker.energyActionMod++;
}
}
}
}

protected double getAttackReachSqr(EntityLivingBase attackTarget) {
return (double)(this.attacker.attackWidth * this.attacker.attackWidth + attackTarget.width);
return (this.attacker.attackWidth * this.attacker.attackWidth + attackTarget.width);
}

protected double getRangedAttackReachSqr(EntityLivingBase attackTarget) {
if (this.attacker instanceof IRangedAttackMob) return (double)(this.attacker.rangedWidth * this.attacker.rangedWidth + attackTarget.width);
if (this.attacker instanceof IRangedAttackMob) return (double)(this.attacker.rangedWidth * this.attacker.rangedWidth + attackTarget.width + 25);
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public boolean shouldExecute() {
else if (!entitylivingbase.isEntityAlive()) return false;
else {
double d0 = this.attacker.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ);
System.out.println("min charge: "+this.getAttackReachSqr(entitylivingbase));
System.out.println("target dist: "+d0);
System.out.println("max charge: "+this.getChargeAttackReachSqr(entitylivingbase));
return this.attacker.getEnergy() > 6 && d0 > this.getAttackReachSqr(entitylivingbase) && d0 <= this.getChargeAttackReachSqr(entitylivingbase) && !this.attacker.isInWater();
}
}
Expand Down Expand Up @@ -198,7 +201,7 @@ else if (entity instanceof RiftCreaturePart) {
}

protected double getAttackReachSqr(EntityLivingBase attackTarget) {
return (double)(this.attacker.attackWidth * this.attacker.attackWidth + attackTarget.width);
return (double)(this.attacker.attackWidth * this.attacker.attackWidth + attackTarget.width + 25);
}

protected double getChargeAttackReachSqr(EntityLivingBase attackTarget) {
Expand Down
Loading

0 comments on commit fc72670

Please sign in to comment.