From db00cb34d4c0795f5ecc6fded24fa6c1b5d50d7a Mon Sep 17 00:00:00 2001 From: Flanks255 <32142731+Flanks255@users.noreply.github.com> Date: Fri, 1 Apr 2022 17:51:55 -0500 Subject: [PATCH] Empowerer go brrrr --- src/generated/resources/.cache/cache | 2 +- .../recipes/empowering/empowered_canola.json | 2 +- .../data/EmpoweringRecipeGenerator.java | 2 +- .../mod/blocks/BlockDisplayStand.java | 2 +- .../mod/blocks/render/RenderEmpowerer.java | 10 +++++ .../mod/tile/TileEntityEmpowerer.java | 42 +++++++++++++------ .../actuallyadditions/mod/util/AssetUtil.java | 10 +++++ 7 files changed, 54 insertions(+), 16 deletions(-) diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 7b3c880d6..51ed9bc2b 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -731,7 +731,7 @@ c1db85574a99e9e45e1ca2dd1703cc53d4699469 data/actuallyadditions/recipes/empowere 539b7277fb268425ac6302a0ab9c53076f4b3096 data/actuallyadditions/recipes/empowering/diamatine_block.json 466bb9c977d91a7a43fdb77589a7618a727e86a7 data/actuallyadditions/recipes/empowering/emeradic.json 1228197667cccd15d8e35fadac0ac7582decbae5 data/actuallyadditions/recipes/empowering/emeradic_block.json -0fa5a05c622d7e6541368e8c0d1d8f7d8c0aed5e data/actuallyadditions/recipes/empowering/empowered_canola.json +ecbc0d8107b656ce571c0f9114f4e7d310dd4ffe data/actuallyadditions/recipes/empowering/empowered_canola.json 213cd0104647e820a59001c970e0e529fc8aeb0a data/actuallyadditions/recipes/empowering/enori.json b857d3d08f386b2f39bfe0d0f859ed09e626f617 data/actuallyadditions/recipes/empowering/enori_block.json 27f284d2e2d0121468d73dd60ffa5f25e8858920 data/actuallyadditions/recipes/empowering/palis.json diff --git a/src/generated/resources/data/actuallyadditions/recipes/empowering/empowered_canola.json b/src/generated/resources/data/actuallyadditions/recipes/empowering/empowered_canola.json index 202fc4743..2cee2a39a 100644 --- a/src/generated/resources/data/actuallyadditions/recipes/empowering/empowered_canola.json +++ b/src/generated/resources/data/actuallyadditions/recipes/empowering/empowered_canola.json @@ -19,7 +19,7 @@ ], "energy": 1000, "time": 30, - "color": 88908, + "color": 16735052, "result": { "item": "actuallyadditions:empowered_canola_seed" } diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/EmpoweringRecipeGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/EmpoweringRecipeGenerator.java index eb9892524..20d961664 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/data/EmpoweringRecipeGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/data/EmpoweringRecipeGenerator.java @@ -102,7 +102,7 @@ public class EmpoweringRecipeGenerator extends RecipeProvider { .addModifier(ItemTags.SAPLINGS) .addModifier(Tags.Items.SLIMEBALLS).save(consumer, "emeradic_block"); - EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_CANOLA_SEED.get(), ActuallyItems.CRYSTALLIZED_CANOLA_SEED.get(), 1000, 30, 0x015b4c) + EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_CANOLA_SEED.get(), ActuallyItems.CRYSTALLIZED_CANOLA_SEED.get(), 1000, 30, 0xFF5B4C) .addModifier(ActuallyItems.CANOLA_SEEDS.get()) .addModifier(ActuallyItems.CANOLA_SEEDS.get()) .addModifier(ActuallyItems.CANOLA_SEEDS.get()) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java index fe1108ac0..f84103db9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java @@ -93,7 +93,7 @@ public class BlockDisplayStand extends BlockContainerBase { return ActionResultType.FAIL; } - return ActionResultType.PASS; + return ActionResultType.CONSUME; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderEmpowerer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderEmpowerer.java index f435be936..9a5fa5888 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderEmpowerer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderEmpowerer.java @@ -26,6 +26,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.Util; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.vector.Quaternion; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.math.vector.Vector3f; public class RenderEmpowerer extends TileEntityRenderer { @@ -72,5 +73,14 @@ public class RenderEmpowerer extends TileEntityRenderer { } */ + if (tile.getCurrentRecipe() != null) { + EmpowererRecipe recipe = tile.getCurrentRecipe(); + for (int i = 0; i <= 3; i++) { + Direction facing = Direction.from2DDataValue(i); + BlockPos offset = new BlockPos(0,0,0).relative(facing, 3); + + AssetUtil.renderLaser(matrices, buffer, new Vector3d(0.0d, 0.0d, 0.0d), new Vector3d(offset.getX(), offset.getY() + 0.45, offset.getZ()), 80, recipe.getParticleColors(), 1.0f ,0.1F); + } + } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEmpowerer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEmpowerer.java index ead25d450..bdf828274 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEmpowerer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEmpowerer.java @@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.crafting.ActuallyRecipes; import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe; +import de.ellpeck.actuallyadditions.mod.crafting.SolidFuelRecipe; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import de.ellpeck.actuallyadditions.mod.util.StackUtil; @@ -22,6 +23,7 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.particles.ParticleTypes; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.server.ServerWorld; @@ -34,8 +36,12 @@ import net.minecraftforge.fml.server.ServerLifecycleHooks; public class TileEntityEmpowerer extends TileEntityInventoryBase { public int processTime; - public int recipeForRenderIndex = -1; - private int lastRecipe; + private EmpowererRecipe currentRecipe = null; + private EmpowererRecipe lastRecipe = null; + + public EmpowererRecipe getCurrentRecipe(){ + return this.currentRecipe; + } public TileEntityEmpowerer() { super(ActuallyBlocks.EMPOWERER.getTileEntityType(), 1); @@ -69,7 +75,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase { if (stands != null) { EmpowererRecipe recipe = findMatchingRecipe(this.inv.getStackInSlot(0), stands[0].getStack(), stands[1].getStack(), stands[2].getStack(), stands[3].getStack()); if (recipe != null) { - //this.recipeForRenderIndex = ActuallyAdditionsAPI.EMPOWERER_RECIPES.indexOf(recipe); //TODO whats this? + currentRecipe = recipe; boolean hasPower = true; @@ -104,16 +110,16 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase { this.setChanged(); this.processTime = 0; - this.recipeForRenderIndex = -1; + this.currentRecipe = null; } } } else { this.processTime = 0; - this.recipeForRenderIndex = -1; + this.currentRecipe = null; } - if (this.lastRecipe != this.recipeForRenderIndex) { - this.lastRecipe = this.recipeForRenderIndex; + if (this.lastRecipe != this.currentRecipe) { + this.lastRecipe = this.currentRecipe; this.sendUpdate(); } } @@ -123,8 +129,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase { private TileEntityDisplayStand[] getNearbyStands() { TileEntityDisplayStand[] stands = new TileEntityDisplayStand[4]; - // TODO: [port] validate this - for (int i = 0; i < 3; i++) { + for (int i = 0; i <= 3; i++) { Direction facing = Direction.from2DDataValue(i); BlockPos offset = this.worldPosition.relative(facing, 3); TileEntity tile = this.level.getBlockEntity(offset); @@ -145,7 +150,10 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase { compound.putInt("ProcessTime", this.processTime); } if (type == NBTType.SYNC) { - compound.putInt("RenderIndex", this.recipeForRenderIndex); + if (this.currentRecipe != null) + compound.putString("CurrentRecipe", this.currentRecipe.getId().toString()); + else + compound.putString("CurrentRecipe", ""); } } @@ -155,8 +163,18 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase { if (type == NBTType.SAVE_TILE) { this.processTime = compound.getInt("ProcessTime"); } - if (type == NBTType.SYNC) { - this.recipeForRenderIndex = compound.getInt("RenderIndex"); + if (type == NBTType.SYNC && compound.contains("CurrentRecipe")) { + if (!compound.getString("CurrentRecipe").equals("")) { + ResourceLocation id = new ResourceLocation(compound.getString("CurrentRecipe")); + for (EmpowererRecipe empowererRecipe : ActuallyAdditionsAPI.EMPOWERER_RECIPES) { + if (empowererRecipe.getId().equals(id)) { + this.currentRecipe = empowererRecipe; + break; + } + } + } + else + this.currentRecipe = null; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java index 15189d631..0abca7ac9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java @@ -303,6 +303,16 @@ public final class AssetUtil { matrixStack.popPose(); } + public static void renderLaser(MatrixStack matrixStack, IRenderTypeBuffer buffer, Vector3d startOffset, Vector3d endOffset, float rotationTime, int color, float alpha, float beamWidth) { + Vector3d combined = endOffset.subtract(startOffset); + + double pitch = Math.toDegrees(Math.atan2(combined.y, Math.sqrt(combined.x * combined.x + combined.z * combined.z))); + double yaw = Math.toDegrees(Math.atan2(-combined.z, combined.x)); + double length = combined.length(); + + renderLaser(matrixStack, buffer, (float) startOffset.x, (float) startOffset.y, (float) startOffset.z, (float) yaw, (float) pitch, (float) length, rotationTime, color, alpha, beamWidth); + } + //Thanks to feldim2425 for this. //I can't do rendering code. Ever. @OnlyIn(Dist.CLIENT)