mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-25 00:18:34 +01:00
Compare commits
No commits in common. "08112ea11cbbb4dd6768ba2f8b3d47fa22ff9136" and "2a6126a1dfa8f63ac93e2e9a39c02ab508f8155e" have entirely different histories.
08112ea11c
...
2a6126a1df
10 changed files with 142 additions and 80 deletions
|
@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.items.base;
|
|||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemSeeds;
|
||||
|
|
|
@ -13,11 +13,15 @@ package de.ellpeck.actuallyadditions.mod.misc;
|
|||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.BannerPattern;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public final class BannerHelper {
|
||||
|
||||
public static void init() {
|
||||
addCraftingPattern("drill", new ItemStack(ActuallyItems.DRILL.get()));
|
||||
addCraftingPattern("drill", new ItemStack(ActuallyItems.DRILL.get(), 1, 3));
|
||||
addCraftingPattern("leaf_blo", new ItemStack(ActuallyItems.LEAF_BLOWER.get()));
|
||||
addCraftingPattern("phan_con", new ItemStack(ActuallyItems.PHANTOM_CONNECTOR.get()));
|
||||
addCraftingPattern("book", new ItemStack(ActuallyItems.ITEM_BOOKLET.get()));
|
||||
|
@ -43,7 +47,7 @@ public final class BannerHelper {
|
|||
public static void addCraftingPattern(String name, ItemStack craftingStack) {
|
||||
Class<?>[] paramTypes = {String.class, String.class, ItemStack.class};
|
||||
Object[] paramValues = {ActuallyAdditions.MODID + "_" + name, ActuallyAdditions.MODID + "_" + name, craftingStack};
|
||||
// EnumHelper.addEnum(BannerPattern.class, (ActuallyAdditions.MODID + "_" + name).toUpperCase(Locale.ROOT), paramTypes, paramValues); //TODO wth banners
|
||||
EnumHelper.addEnum(BannerPattern.class, (ActuallyAdditions.MODID + "_" + name).toUpperCase(Locale.ROOT), paramTypes, paramValues);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
|
@ -114,7 +113,7 @@ public class MethodHandler implements IMethodHandler {
|
|||
|
||||
int prevCounter = tag.putInt("Counter");
|
||||
CompoundNBT compound = new CompoundNBT();
|
||||
//compound.putInt("ID", Potion.getIdFromPotion(effect.getEffect())); //TODO ?!
|
||||
compound.putInt("ID", Potion.getIdFromPotion(effect.getEffect()));
|
||||
compound.putInt("Duration", effect.getDuration());
|
||||
compound.putInt("Amplifier", effect.getAmplifier());
|
||||
|
||||
|
@ -179,7 +178,7 @@ public class MethodHandler implements IMethodHandler {
|
|||
if (StackUtil.isValid(output)) {
|
||||
tile.getWorldObject().levelEvent(2001, pos, Block.getId(state));
|
||||
recipe.transformHook(ItemStack.EMPTY, state, pos, tile);
|
||||
if (output.getItem() instanceof BlockItem) {
|
||||
if (output.getItem() instanceof ItemBlock) {
|
||||
Block toPlace = Block.byItem(output.getItem());
|
||||
BlockState state2Place = toPlace.getStateForPlacement(tile.getWorldObject(), pos, facing, 0, 0, 0, output.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject()), Hand.MAIN_HAND);
|
||||
tile.getWorldObject().setBlock(pos, state2Place, 2);
|
||||
|
|
|
@ -16,8 +16,6 @@ import net.minecraft.nbt.CompoundNBT;
|
|||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PacketClientToServer {
|
||||
|
||||
private CompoundNBT data;
|
||||
|
@ -32,31 +30,39 @@ public class PacketClientToServer {
|
|||
this.handler = handler;
|
||||
}
|
||||
|
||||
public static PacketClientToServer fromBytes(PacketBuffer buffer) {
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
PacketBuffer buffer = new PacketBuffer(buf);
|
||||
try {
|
||||
CompoundNBT data = buffer.readNbt();
|
||||
this.data = buffer.readNbt();
|
||||
|
||||
int handlerId = buffer.readInt();
|
||||
if (handlerId >= 0 && handlerId < PacketHandler.DATA_HANDLERS.size()) {
|
||||
return new PacketClientToServer(data, PacketHandler.DATA_HANDLERS.get(handlerId));
|
||||
this.handler = PacketHandler.DATA_HANDLERS.get(handlerId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ActuallyAdditions.LOGGER.error("Something went wrong trying to receive a server packet!", e);
|
||||
}
|
||||
return new PacketClientToServer();
|
||||
}
|
||||
|
||||
public static void toBytes(PacketClientToServer message, PacketBuffer buffer) {
|
||||
buffer.writeNbt(message.data);
|
||||
buffer.writeInt(PacketHandler.DATA_HANDLERS.indexOf(message.handler));
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
PacketBuffer buffer = new PacketBuffer(buf);
|
||||
|
||||
buffer.writeNbt(this.data);
|
||||
buffer.writeInt(PacketHandler.DATA_HANDLERS.indexOf(this.handler));
|
||||
}
|
||||
|
||||
public static void handle(final PacketClientToServer message, final Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork( () -> {
|
||||
public static class Handler implements IMessageHandler<PacketClientToServer, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketClientToServer message, NetworkEvent.Context ctx) {
|
||||
FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(() -> {
|
||||
if (message.data != null && message.handler != null) {
|
||||
message.handler.handleData(message.data, ctx.get());
|
||||
message.handler.handleData(message.data, ctx);
|
||||
}
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,18 +27,14 @@ import net.minecraft.entity.player.ServerPlayerEntity;
|
|||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.fml.network.NetworkDirection;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||
|
@ -52,19 +48,19 @@ public final class PacketHandler {
|
|||
public static final IDataHandler LASER_HANDLER = new IDataHandler() {
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void handleData(CompoundNBT compound, NetworkEvent.Context context) {
|
||||
public void handleData(CompoundNBT compound, MessageContext context) {
|
||||
AssetUtil.spawnLaserWithTimeClient(compound.getDouble("StartX"), compound.getDouble("StartY"), compound.getDouble("StartZ"), compound.getDouble("EndX"), compound.getDouble("EndY"), compound.getDouble("EndZ"), new float[]{compound.getFloat("Color1"), compound.getFloat("Color2"), compound.getFloat("Color3")}, compound.getInt("MaxAge"), compound.getDouble("RotationTime"), compound.getFloat("Size"), compound.getFloat("Alpha"));
|
||||
}
|
||||
};
|
||||
public static final IDataHandler TILE_ENTITY_HANDLER = new IDataHandler() {
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void handleData(CompoundNBT compound, NetworkEvent.Context context) {
|
||||
public void handleData(CompoundNBT compound, MessageContext context) {
|
||||
World world = Minecraft.getInstance().level;
|
||||
if (world != null) {
|
||||
TileEntity tile = world.getBlockEntity(new BlockPos(compound.getInt("X"), compound.getInt("Y"), compound.getInt("Z")));
|
||||
if (tile instanceof TileEntityBase) {
|
||||
((TileEntityBase) tile).readSyncableNBT(compound.getCompound("Data"), TileEntityBase.NBTType.SYNC);
|
||||
((TileEntityBase) tile).readSyncableNBT(compound.getCompoundTag("Data"), TileEntityBase.NBTType.SYNC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,9 +68,9 @@ public final class PacketHandler {
|
|||
public static final IDataHandler LASER_PARTICLE_HANDLER = new IDataHandler() {
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void handleData(CompoundNBT compound, NetworkEvent.Context context) {
|
||||
public void handleData(CompoundNBT compound, MessageContext context) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
ItemStack stack = ItemStack.of(compound);
|
||||
ItemStack stack = new ItemStack(compound);
|
||||
|
||||
double inX = compound.getDouble("InX") + 0.5;
|
||||
double inY = compound.getDouble("InY") + 0.78;
|
||||
|
@ -85,11 +81,11 @@ public final class PacketHandler {
|
|||
double outZ = compound.getDouble("OutZ") + 0.5;
|
||||
|
||||
Particle fx = new ParticleLaserItem(mc.level, outX, outY, outZ, stack, 0.025, inX, inY, inZ);
|
||||
//mc.effectRenderer.addEffect(fx); //TODO
|
||||
mc.effectRenderer.addEffect(fx);
|
||||
}
|
||||
};
|
||||
public static final IDataHandler GUI_BUTTON_TO_TILE_HANDLER = (compound, context) -> {
|
||||
World world = context.getSender().getServer().getLevel(RegistryKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(compound.getString("WorldID"))));
|
||||
World world = DimensionManager.getWorld(compound.getInt("WorldID"));
|
||||
TileEntity tile = world.getBlockEntity(new BlockPos(compound.getInt("X"), compound.getInt("Y"), compound.getInt("Z")));
|
||||
|
||||
if (tile instanceof IButtonReactor) {
|
||||
|
@ -101,7 +97,7 @@ public final class PacketHandler {
|
|||
}
|
||||
};
|
||||
public static final IDataHandler GUI_BUTTON_TO_CONTAINER_HANDLER = (compound, context) -> {
|
||||
World world = context.getSender().getServer().getLevel(RegistryKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(compound.getString("WorldID"))));
|
||||
World world = DimensionManager.getWorld(compound.getInt("WorldID"));
|
||||
Entity entity = world.getEntity(compound.getInt("PlayerID"));
|
||||
if (entity instanceof PlayerEntity) {
|
||||
Container container = ((PlayerEntity) entity).containerMenu;
|
||||
|
@ -111,7 +107,7 @@ public final class PacketHandler {
|
|||
}
|
||||
};
|
||||
public static final IDataHandler GUI_NUMBER_TO_TILE_HANDLER = (compound, context) -> {
|
||||
World world = context.getSender().getServer().getLevel(RegistryKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(compound.getString("WorldID"))));
|
||||
World world = DimensionManager.getWorld(compound.getInt("WorldID"));
|
||||
TileEntity tile = world.getBlockEntity(new BlockPos(compound.getInt("X"), compound.getInt("Y"), compound.getInt("Z")));
|
||||
|
||||
if (tile instanceof INumberReactor) {
|
||||
|
@ -120,7 +116,7 @@ public final class PacketHandler {
|
|||
}
|
||||
};
|
||||
public static final IDataHandler GUI_STRING_TO_TILE_HANDLER = (compound, context) -> {
|
||||
World world = context.getSender().getServer().getLevel(RegistryKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(compound.getString("WorldID"))));
|
||||
World world = DimensionManager.getWorld(compound.getInt("WorldID"));
|
||||
TileEntity tile = world.getBlockEntity(new BlockPos(compound.getInt("X"), compound.getInt("Y"), compound.getInt("Z")));
|
||||
|
||||
if (tile instanceof IStringReactor) {
|
||||
|
@ -131,9 +127,9 @@ public final class PacketHandler {
|
|||
public static final IDataHandler SYNC_PLAYER_DATA = new IDataHandler() {
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void handleData(CompoundNBT compound, NetworkEvent.Context context) {
|
||||
CompoundNBT dataTag = compound.getCompound("Data");
|
||||
PlayerEntity player = context.getSender(); //ActuallyAdditions.PROXY.getCurrentPlayer();
|
||||
public void handleData(CompoundNBT compound, MessageContext context) {
|
||||
CompoundNBT dataTag = compound.getCompoundTag("Data");
|
||||
PlayerEntity player = ActuallyAdditions.PROXY.getCurrentPlayer();
|
||||
|
||||
if (player != null) {
|
||||
PlayerData.getDataFromPlayer(player).readFromNBT(dataTag, false);
|
||||
|
@ -147,8 +143,8 @@ public final class PacketHandler {
|
|||
}
|
||||
};
|
||||
public static final IDataHandler PLAYER_DATA_TO_SERVER = (compound, context) -> {
|
||||
World world = context.getSender().getServer().getLevel(RegistryKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(compound.getString("World"))));
|
||||
PlayerEntity player = world.getServer().getPlayerList().getPlayer(compound.getUUID("UUID"));
|
||||
World world = DimensionManager.getWorld(compound.getInt("World"));
|
||||
PlayerEntity player = world.getPlayerEntityByUUID(compound.getUUID("UUID"));
|
||||
if (player != null) {
|
||||
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
||||
|
||||
|
@ -183,16 +179,8 @@ public final class PacketHandler {
|
|||
);
|
||||
|
||||
public static void init() {
|
||||
THE_NETWORK.messageBuilder(PacketServerToClient.class, 0, NetworkDirection.PLAY_TO_CLIENT)
|
||||
.decoder(PacketServerToClient::fromBytes)
|
||||
.encoder(PacketServerToClient::toBytes)
|
||||
.consumer(PacketServerToClient::handle).add();
|
||||
|
||||
THE_NETWORK.messageBuilder(PacketClientToServer.class, 1, NetworkDirection.PLAY_TO_SERVER)
|
||||
.decoder(PacketClientToServer::fromBytes)
|
||||
.encoder(PacketClientToServer::toBytes)
|
||||
.consumer(PacketClientToServer::handle).add();
|
||||
|
||||
THE_NETWORK.registerMessage(PacketServerToClient.Handler.class, PacketServerToClient.class, 0, Side.CLIENT);
|
||||
THE_NETWORK.registerMessage(PacketClientToServer.Handler.class, PacketClientToServer.class, 1, Side.SERVER);
|
||||
|
||||
DATA_HANDLERS.add(LASER_HANDLER);
|
||||
DATA_HANDLERS.add(TILE_ENTITY_HANDLER);
|
||||
|
|
|
@ -23,7 +23,6 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
|
||||
public final class PacketHandlerHelper {
|
||||
|
||||
|
@ -34,7 +33,7 @@ public final class PacketHandlerHelper {
|
|||
compound.putInt("X", pos.getX());
|
||||
compound.putInt("Y", pos.getY());
|
||||
compound.putInt("Z", pos.getZ());
|
||||
compound.putString("WorldID", tile.getLevel().dimension().getRegistryName().toString());
|
||||
compound.putInt("WorldID", tile.getLevel().getDimension());
|
||||
compound.putInt("PlayerID", Minecraft.getInstance().player.getId());
|
||||
compound.putInt("ButtonID", buttonId);
|
||||
PacketHandler.THE_NETWORK.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER));
|
||||
|
@ -49,7 +48,7 @@ public final class PacketHandlerHelper {
|
|||
compound.put("Data", data);
|
||||
|
||||
if (player instanceof ServerPlayerEntity) {
|
||||
PacketHandler.THE_NETWORK.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new PacketServerToClient(compound, PacketHandler.SYNC_PLAYER_DATA));
|
||||
PacketHandler.THE_NETWORK.sendTo(new PacketServerToClient(compound, PacketHandler.SYNC_PLAYER_DATA), (ServerPlayerEntity) player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,8 +60,8 @@ public final class PacketHandlerHelper {
|
|||
|
||||
PlayerEntity player = Minecraft.getInstance().player;
|
||||
if (player != null) {
|
||||
compound.putString("World", player.level.dimension().getRegistryName().toString());
|
||||
compound.putUUID("UUID", player.getUUID());
|
||||
compound.putInt("World", player.level.provider.getDimension());
|
||||
compound.setUniqueId("UUID", player.getUUID());
|
||||
|
||||
PlayerSave data = PlayerData.getDataFromPlayer(player);
|
||||
|
||||
|
@ -95,7 +94,7 @@ public final class PacketHandlerHelper {
|
|||
compound.putInt("X", tile.getBlockPos().getX());
|
||||
compound.putInt("Y", tile.getBlockPos().getY());
|
||||
compound.putInt("Z", tile.getBlockPos().getZ());
|
||||
compound.putString("WorldID", tile.getLevel().dimension().getRegistryName().toString());
|
||||
compound.putInt("WorldID", tile.getLevel().provider.getDimension());
|
||||
compound.putInt("PlayerID", Minecraft.getInstance().player.getId());
|
||||
compound.putInt("NumberID", id);
|
||||
compound.putDouble("Number", number);
|
||||
|
|
|
@ -11,14 +11,18 @@
|
|||
package de.ellpeck.actuallyadditions.mod.network;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
|
||||
public class PacketServerToClient {
|
||||
public class PacketServerToClient implements Message {
|
||||
|
||||
private CompoundNBT data;
|
||||
private IDataHandler handler;
|
||||
|
@ -32,33 +36,40 @@ public class PacketServerToClient {
|
|||
this.handler = handler;
|
||||
}
|
||||
|
||||
public static PacketServerToClient fromBytes(final PacketBuffer buffer) {
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
PacketBuffer buffer = new PacketBuffer(buf);
|
||||
try {
|
||||
CompoundNBT data = buffer.readNbt();
|
||||
this.data = buffer.readNbt();
|
||||
|
||||
int handlerId = buffer.readInt();
|
||||
if (handlerId >= 0 && handlerId < PacketHandler.DATA_HANDLERS.size()) {
|
||||
return new PacketServerToClient(data, PacketHandler.DATA_HANDLERS.get(handlerId));
|
||||
this.handler = PacketHandler.DATA_HANDLERS.get(handlerId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ActuallyAdditions.LOGGER.error("Something went wrong trying to receive a client packet!", e);
|
||||
}
|
||||
return new PacketServerToClient();
|
||||
}
|
||||
|
||||
public static void toBytes(final PacketServerToClient message, PacketBuffer buffer) {
|
||||
buffer.writeNbt(message.data);
|
||||
buffer.writeInt(PacketHandler.DATA_HANDLERS.indexOf(message.handler));
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
PacketBuffer buffer = new PacketBuffer(buf);
|
||||
|
||||
buffer.writeNbt(this.data);
|
||||
buffer.writeInt(PacketHandler.DATA_HANDLERS.indexOf(this.handler));
|
||||
}
|
||||
|
||||
public static void handle(final PacketServerToClient message, final Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(
|
||||
() -> {
|
||||
public static class Handler implements IMessageHandler<PacketServerToClient, IMessage> {
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public IMessage onMessage(PacketServerToClient message, MessageContext ctx) {
|
||||
Minecraft.getInstance().addScheduledTask(() -> {
|
||||
if (message.data != null && message.handler != null) {
|
||||
message.handler.handleData(message.data, ctx.get());
|
||||
message.handler.handleData(message.data, ctx);
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
);
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public interface IEnergyDisplay {
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.ActuallyRecipes;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe;
|
||||
|
@ -29,6 +30,7 @@ import javax.annotation.Nullable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase.NBTType;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
|
||||
public class TileEntityEmpowerer extends TileEntityInventoryBase {
|
||||
|
@ -41,8 +43,23 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase {
|
|||
super(ActuallyBlocks.EMPOWERER.getTileEntityType(), 1);
|
||||
}
|
||||
|
||||
@Deprecated //Use findMatchingRecipe
|
||||
public static List<EmpowererRecipe> getRecipesForInput(ItemStack input) {
|
||||
List<EmpowererRecipe> recipesThatWork = new ArrayList<>();
|
||||
if (StackUtil.isValid(input)) {
|
||||
// TODO: [port] VALIDATOR OR REMOVE
|
||||
for (EmpowererRecipe recipe : ActuallyAdditionsAPI.EMPOWERER_RECIPES) {
|
||||
if (recipe.getInput().test(input)) {
|
||||
recipesThatWork.add(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
return recipesThatWork;
|
||||
}
|
||||
|
||||
public static boolean isPossibleInput(ItemStack stack) {
|
||||
for (EmpowererRecipe r : ServerLifecycleHooks.getCurrentServer().getRecipeManager().getAllRecipesFor(ActuallyRecipes.Types.EMPOWERING)) {
|
||||
for (EmpowererRecipe r : ActuallyAdditionsAPI.EMPOWERER_RECIPES) {
|
||||
// TODO: [port] move to proper recipe system
|
||||
if (r.getInput().test(stack)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -69,7 +86,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?
|
||||
this.recipeForRenderIndex = ActuallyAdditionsAPI.EMPOWERER_RECIPES.indexOf(recipe);
|
||||
|
||||
boolean hasPower = true;
|
||||
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* This file ("RecipeUtil.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.util.crafting.RecipeHandler;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
|
||||
public final class RecipeUtil {
|
||||
|
||||
public static LensConversionRecipe lastReconstructorRecipe() {
|
||||
List<LensConversionRecipe> list = ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES;
|
||||
return list.get(list.size() - 1);
|
||||
}
|
||||
|
||||
public static CrusherRecipe lastCrusherRecipe() {
|
||||
List<CrusherRecipe> list = ActuallyAdditionsAPI.CRUSHER_RECIPES;
|
||||
return list.get(list.size() - 1);
|
||||
}
|
||||
|
||||
public static IRecipe lastIRecipe() {
|
||||
return RecipeHandler.lastRecipe;
|
||||
}
|
||||
|
||||
public static EmpowererRecipe lastEmpowererRecipe() {
|
||||
List<EmpowererRecipe> list = ActuallyAdditionsAPI.EMPOWERER_RECIPES;
|
||||
return list.get(list.size() - 1);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue