Empowerer go brrrr

This commit is contained in:
Flanks255 2022-04-01 17:51:55 -05:00
parent b0c1e8e8cc
commit db00cb34d4
7 changed files with 54 additions and 16 deletions

View file

@ -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

View file

@ -19,7 +19,7 @@
],
"energy": 1000,
"time": 30,
"color": 88908,
"color": 16735052,
"result": {
"item": "actuallyadditions:empowered_canola_seed"
}

View file

@ -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())

View file

@ -93,7 +93,7 @@ public class BlockDisplayStand extends BlockContainerBase {
return ActionResultType.FAIL;
}
return ActionResultType.PASS;
return ActionResultType.CONSUME;
}
@Override

View file

@ -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<TileEntityEmpowerer> {
@ -72,5 +73,14 @@ public class RenderEmpowerer extends TileEntityRenderer<TileEntityEmpowerer> {
}
*/
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);
}
}
}
}

View file

@ -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;
}
}

View file

@ -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)