mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
feat: hmm, more porting
This commit is contained in:
parent
05d64c1539
commit
d922cbdc9e
15 changed files with 712 additions and 712 deletions
|
@ -19,7 +19,6 @@ import net.minecraft.tags.ItemTags;
|
|||
import net.minecraft.util.IItemProvider;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.Tags;
|
||||
import sun.plugin.dom.exception.InvalidStateException;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
|
@ -38,86 +37,86 @@ public class EmpoweringRecipeGenerator extends RecipeProvider {
|
|||
@Override
|
||||
protected void buildShapelessRecipes(Consumer<IFinishedRecipe> consumer) {
|
||||
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_RESTONIA_CRYSTAL.get(), ActuallyItems.RESTONIA_CRYSTAL.get(), 5000, 50, Crystals.REDSTONE.conversionColorParticles)
|
||||
.addModifier(Tags.Items.DYES_RED)
|
||||
.addModifier(Items.NETHER_BRICK)
|
||||
.addModifier(Tags.Items.DUSTS_REDSTONE)
|
||||
.addModifier(Items.BRICK).save(consumer, "restonia");
|
||||
.addModifier(Tags.Items.DYES_RED)
|
||||
.addModifier(Items.NETHER_BRICK)
|
||||
.addModifier(Tags.Items.DUSTS_REDSTONE)
|
||||
.addModifier(Items.BRICK).save(consumer, "restonia");
|
||||
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_RESTONIA_CRYSTAL.get(), ActuallyBlocks.RESTONIA_CRYSTAL.get(), 50000, 500, Crystals.REDSTONE.conversionColorParticles)
|
||||
.addModifier(Tags.Items.DYES_RED)
|
||||
.addModifier(Items.NETHER_BRICK)
|
||||
.addModifier(Tags.Items.DUSTS_REDSTONE)
|
||||
.addModifier(Items.BRICK).save(consumer, "restonia_block");
|
||||
.addModifier(Tags.Items.DYES_RED)
|
||||
.addModifier(Items.NETHER_BRICK)
|
||||
.addModifier(Tags.Items.DUSTS_REDSTONE)
|
||||
.addModifier(Items.BRICK).save(consumer, "restonia_block");
|
||||
|
||||
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_PALIS_CRYSTAL.get(), ActuallyItems.PALIS_CRYSTAL.get(), 5000, 50, Crystals.LAPIS.conversionColorParticles)
|
||||
.addModifier(Tags.Items.DYES_CYAN)
|
||||
.addModifier(Items.PRISMARINE_SHARD)
|
||||
.addModifier(Items.PRISMARINE_SHARD)
|
||||
.addModifier(Items.PRISMARINE_SHARD).save(consumer, "palis");
|
||||
.addModifier(Tags.Items.DYES_CYAN)
|
||||
.addModifier(Items.PRISMARINE_SHARD)
|
||||
.addModifier(Items.PRISMARINE_SHARD)
|
||||
.addModifier(Items.PRISMARINE_SHARD).save(consumer, "palis");
|
||||
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_PALIS_CRYSTAL.get(), ActuallyBlocks.PALIS_CRYSTAL.get(), 50000, 500, Crystals.LAPIS.conversionColorParticles)
|
||||
.addModifier(Tags.Items.DYES_CYAN)
|
||||
.addModifier(Items.PRISMARINE_SHARD)
|
||||
.addModifier(Items.PRISMARINE_SHARD)
|
||||
.addModifier(Items.PRISMARINE_SHARD).save(consumer, "palis_block");
|
||||
.addModifier(Tags.Items.DYES_CYAN)
|
||||
.addModifier(Items.PRISMARINE_SHARD)
|
||||
.addModifier(Items.PRISMARINE_SHARD)
|
||||
.addModifier(Items.PRISMARINE_SHARD).save(consumer, "palis_block");
|
||||
|
||||
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_DIAMATINE_CRYSTAL.get(), ActuallyItems.DIAMATINE_CRYSTAL.get(), 5000, 50, Crystals.DIAMOND.conversionColorParticles)
|
||||
.addModifier(Tags.Items.DYES_LIGHT_BLUE)
|
||||
.addModifier(Items.CLAY_BALL)
|
||||
.addModifier(Items.CLAY_BALL)
|
||||
.addModifier(Items.CLAY).save(consumer, "diamatine");
|
||||
.addModifier(Tags.Items.DYES_LIGHT_BLUE)
|
||||
.addModifier(Items.CLAY_BALL)
|
||||
.addModifier(Items.CLAY_BALL)
|
||||
.addModifier(Items.CLAY).save(consumer, "diamatine");
|
||||
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_DIAMATINE_CRYSTAL.get(), ActuallyBlocks.DIAMATINE_CRYSTAL.get(), 50000, 500, Crystals.DIAMOND.conversionColorParticles)
|
||||
.addModifier(Tags.Items.DYES_LIGHT_BLUE)
|
||||
.addModifier(Items.CLAY_BALL)
|
||||
.addModifier(Items.CLAY_BALL)
|
||||
.addModifier(Items.CLAY).save(consumer, "diamatine_block");
|
||||
.addModifier(Tags.Items.DYES_LIGHT_BLUE)
|
||||
.addModifier(Items.CLAY_BALL)
|
||||
.addModifier(Items.CLAY_BALL)
|
||||
.addModifier(Items.CLAY).save(consumer, "diamatine_block");
|
||||
|
||||
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_ENORI_CRYSTAL.get(), ActuallyItems.ENORI_CRYSTAL.get(), 5000, 50, Crystals.IRON.conversionColorParticles)
|
||||
.addModifier(Tags.Items.DYES_GRAY)
|
||||
.addModifier(Items.SNOWBALL)
|
||||
.addModifier(Items.STONE_BUTTON)
|
||||
.addModifier(Tags.Items.COBBLESTONE).save(consumer, "enori");
|
||||
.addModifier(Tags.Items.DYES_GRAY)
|
||||
.addModifier(Items.SNOWBALL)
|
||||
.addModifier(Items.STONE_BUTTON)
|
||||
.addModifier(Tags.Items.COBBLESTONE).save(consumer, "enori");
|
||||
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_ENORI_CRYSTAL.get(), ActuallyBlocks.ENORI_CRYSTAL.get(), 50000, 500, Crystals.IRON.conversionColorParticles)
|
||||
.addModifier(Tags.Items.DYES_GRAY)
|
||||
.addModifier(Items.SNOWBALL)
|
||||
.addModifier(Items.STONE_BUTTON)
|
||||
.addModifier(Tags.Items.COBBLESTONE).save(consumer, "enori_block");
|
||||
.addModifier(Tags.Items.DYES_GRAY)
|
||||
.addModifier(Items.SNOWBALL)
|
||||
.addModifier(Items.STONE_BUTTON)
|
||||
.addModifier(Tags.Items.COBBLESTONE).save(consumer, "enori_block");
|
||||
|
||||
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_VOID_CRYSTAL.get(), ActuallyItems.VOID_CRYSTAL.get(), 5000, 50, Crystals.COAL.conversionColorParticles)
|
||||
.addModifier(Tags.Items.DYES_BLACK)
|
||||
.addModifier(ItemTags.COALS)
|
||||
.addModifier(Items.FLINT)
|
||||
.addModifier(Tags.Items.STONE).save(consumer, "void");
|
||||
.addModifier(Tags.Items.DYES_BLACK)
|
||||
.addModifier(ItemTags.COALS)
|
||||
.addModifier(Items.FLINT)
|
||||
.addModifier(Tags.Items.STONE).save(consumer, "void");
|
||||
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_VOID_CRYSTAL.get(), ActuallyBlocks.VOID_CRYSTAL.get(), 50000, 500, Crystals.COAL.conversionColorParticles)
|
||||
.addModifier(Tags.Items.DYES_BLACK)
|
||||
.addModifier(ItemTags.COALS)
|
||||
.addModifier(Items.FLINT)
|
||||
.addModifier(Tags.Items.STONE).save(consumer, "void_block");
|
||||
.addModifier(Tags.Items.DYES_BLACK)
|
||||
.addModifier(ItemTags.COALS)
|
||||
.addModifier(Items.FLINT)
|
||||
.addModifier(Tags.Items.STONE).save(consumer, "void_block");
|
||||
|
||||
EmpoweringBuilder.builder(ActuallyItems.EMPOWERED_EMERADIC_CRYSTAL.get(), ActuallyItems.EMERADIC_CRYSTAL.get(), 5000, 50, Crystals.EMERALD.conversionColorParticles)
|
||||
.addModifier(Tags.Items.DYES_LIME)
|
||||
.addModifier(Items.TALL_GRASS)
|
||||
.addModifier(ItemTags.SAPLINGS)
|
||||
.addModifier(Tags.Items.SLIMEBALLS).save(consumer, "emeradic");
|
||||
.addModifier(Tags.Items.DYES_LIME)
|
||||
.addModifier(Items.TALL_GRASS)
|
||||
.addModifier(ItemTags.SAPLINGS)
|
||||
.addModifier(Tags.Items.SLIMEBALLS).save(consumer, "emeradic");
|
||||
EmpoweringBuilder.builder(ActuallyBlocks.EMPOWERED_EMERADIC_CRYSTAL.get(), ActuallyBlocks.EMERADIC_CRYSTAL.get(), 50000, 500, Crystals.EMERALD.conversionColorParticles)
|
||||
.addModifier(Tags.Items.DYES_LIME)
|
||||
.addModifier(Items.TALL_GRASS)
|
||||
.addModifier(ItemTags.SAPLINGS)
|
||||
.addModifier(Tags.Items.SLIMEBALLS).save(consumer, "emeradic_block");
|
||||
.addModifier(Tags.Items.DYES_LIME)
|
||||
.addModifier(Items.TALL_GRASS)
|
||||
.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)
|
||||
.addModifier(ActuallyItems.CANOLA_SEED.get())
|
||||
.addModifier(ActuallyItems.CANOLA_SEED.get())
|
||||
.addModifier(ActuallyItems.CANOLA_SEED.get())
|
||||
.addModifier(ActuallyItems.CANOLA_SEED.get()).save(consumer, "empowered_canola");
|
||||
.addModifier(ActuallyItems.CANOLA_SEED.get())
|
||||
.addModifier(ActuallyItems.CANOLA_SEED.get())
|
||||
.addModifier(ActuallyItems.CANOLA_SEED.get())
|
||||
.addModifier(ActuallyItems.CANOLA_SEED.get()).save(consumer, "empowered_canola");
|
||||
}
|
||||
|
||||
|
||||
public static class EmpoweringBuilder {
|
||||
private final Item result;
|
||||
private final Ingredient base;
|
||||
private List<Ingredient> modifiers = new ArrayList<>();
|
||||
private final int energy;
|
||||
private final int time;
|
||||
private final int color;
|
||||
private final List<Ingredient> modifiers = new ArrayList<>();
|
||||
|
||||
public EmpoweringBuilder(IItemProvider resultIn, Ingredient baseIn, int energyIn, int timeIn, int colorIn) {
|
||||
result = resultIn.asItem();
|
||||
|
@ -137,12 +136,14 @@ public class EmpoweringRecipeGenerator extends RecipeProvider {
|
|||
modifiers.add(Ingredient.of(input));
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmpoweringBuilder addModifier(ItemStack input) {
|
||||
if (modifiers.size() >= 4)
|
||||
throw new InvalidStateException("too many modifiers for empowering recipe, input: " + input.getItem().getRegistryName());
|
||||
modifiers.add(Ingredient.of(input));
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmpoweringBuilder addModifier(ITag<Item> input) {
|
||||
if (modifiers.size() >= 4)
|
||||
throw new InvalidStateException("too many modifiers for empowering recipe, input: " + input.toString());
|
||||
|
@ -155,10 +156,11 @@ public class EmpoweringRecipeGenerator extends RecipeProvider {
|
|||
throw new InvalidStateException("invalid modifier count: " + modifiers.size() + ", recipe: " + name.toString());
|
||||
consumer.accept(new EmpowererRecipe.FinishedRecipe(name, result, base, modifiers.get(0), modifiers.get(1), modifiers.get(2), modifiers.get(3), energy, time, color));
|
||||
}
|
||||
|
||||
public void save(Consumer<IFinishedRecipe> consumer, String name) {
|
||||
ResourceLocation res = new ResourceLocation(ActuallyAdditions.MODID, "empowering/" + name);
|
||||
if (modifiers.size() != 4)
|
||||
throw new InvalidStateException("invalid modifier count: " + modifiers.size() + ", recipe: " + res.toString());
|
||||
throw new InvalidStateException("invalid modifier count: " + modifiers.size() + ", recipe: " + res);
|
||||
consumer.accept(new EmpowererRecipe.FinishedRecipe(res, result, base, modifiers.get(0), modifiers.get(1), modifiers.get(2), modifiers.get(3), energy, time, color));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@ package de.ellpeck.actuallyadditions.mod;
|
|||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.InitBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.ActuallyRecipes;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.TargetNBTIngredient;
|
||||
import de.ellpeck.actuallyadditions.mod.data.WorldData;
|
||||
import de.ellpeck.actuallyadditions.mod.entity.EntityWorm;
|
||||
import de.ellpeck.actuallyadditions.mod.entity.InitEntities;
|
||||
import de.ellpeck.actuallyadditions.mod.event.CommonEvents;
|
||||
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
||||
|
@ -34,18 +34,23 @@ import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
|||
import de.ellpeck.actuallyadditions.mod.recipe.HairyBallHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ResourceReloader;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.event.AddReloadListenerEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStoppedEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
@ -71,6 +76,10 @@ public class ActuallyAdditions {
|
|||
}
|
||||
};
|
||||
public static final Logger LOGGER = LogManager.getLogger(NAME);
|
||||
|
||||
public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, "entities");
|
||||
public static final RegistryObject<EntityType<EntityWorm>> ENTITY_WORM = ENTITIES.register("worm", () -> EntityType.Builder.of(EntityWorm::new, EntityClassification.CREATURE).build(MODID + ":worm"));
|
||||
|
||||
@Deprecated
|
||||
public static ActuallyAdditions INSTANCE;
|
||||
|
||||
|
@ -87,6 +96,7 @@ public class ActuallyAdditions {
|
|||
ActuallyBlocks.TILES.register(eventBus);
|
||||
ActuallyRecipes.init(eventBus);
|
||||
ActuallyContainers.CONTAINERS.register(eventBus);
|
||||
ENTITIES.register(eventBus);
|
||||
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStarted);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStopped);
|
||||
|
@ -99,6 +109,10 @@ public class ActuallyAdditions {
|
|||
eventBus.addListener(this::clientSetup);
|
||||
}
|
||||
|
||||
private static void reloadEvent(AddReloadListenerEvent event) {
|
||||
event.addListener(new ResourceReloader(event.getDataPackRegistries()));
|
||||
}
|
||||
|
||||
private void setup(FMLCommonSetupEvent event) {
|
||||
PacketHandler.init();
|
||||
|
||||
|
@ -119,11 +133,6 @@ public class ActuallyAdditions {
|
|||
HairyBallHandler.init();
|
||||
LensRecipeHandler.init();
|
||||
LensMining.init();
|
||||
InitBooklet.init();
|
||||
}
|
||||
|
||||
private static void reloadEvent(AddReloadListenerEvent event){
|
||||
event.addListener(new ResourceReloader(event.getDataPackRegistries()));
|
||||
}
|
||||
|
||||
private void clientSetup(FMLClientSetupEvent event) {
|
||||
|
|
|
@ -10,57 +10,48 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.config;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntListValues;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
public final class ConfigValues {
|
||||
|
||||
//
|
||||
public static Item itemRedstoneTorchConfigurator;
|
||||
public static Item itemCompassConfigurator;
|
||||
|
||||
public static void defineConfigValues(Configuration config) {
|
||||
for (ConfigIntValues currConf : ConfigIntValues.values()) {
|
||||
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc, currConf.min, currConf.max).getInt();
|
||||
}
|
||||
|
||||
for (ConfigBoolValues currConf : ConfigBoolValues.values()) {
|
||||
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getBoolean();
|
||||
}
|
||||
|
||||
for (ConfigIntListValues currConf : ConfigIntListValues.values()) {
|
||||
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getIntList();
|
||||
}
|
||||
|
||||
for (ConfigStringListValues currConf : ConfigStringListValues.values()) {
|
||||
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getStringList();
|
||||
}
|
||||
|
||||
parseConfiguratorConfig();
|
||||
}
|
||||
|
||||
private static void parseConfiguratorConfig() {
|
||||
itemRedstoneTorchConfigurator = null;
|
||||
itemCompassConfigurator = null;
|
||||
|
||||
String[] conf = ConfigStringListValues.CONFIGURE_ITEMS.getValue();
|
||||
if (conf.length == 2) {
|
||||
itemRedstoneTorchConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[0]));
|
||||
itemCompassConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[1]));
|
||||
}
|
||||
|
||||
if (itemRedstoneTorchConfigurator == null || itemCompassConfigurator == null) {
|
||||
ActuallyAdditions.LOGGER.error("Parsing the Configuration Items config failed, reverting back to the default settings!");
|
||||
|
||||
itemRedstoneTorchConfigurator = Item.byBlock(Blocks.REDSTONE_TORCH);
|
||||
itemCompassConfigurator = Items.COMPASS;
|
||||
}
|
||||
}
|
||||
//
|
||||
// public static void defineConfigValues(Configuration config) {
|
||||
// for (ConfigIntValues currConf : ConfigIntValues.values()) {
|
||||
// currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc, currConf.min, currConf.max).getInt();
|
||||
// }
|
||||
//
|
||||
// for (ConfigBoolValues currConf : ConfigBoolValues.values()) {
|
||||
// currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getBoolean();
|
||||
// }
|
||||
//
|
||||
// for (ConfigIntListValues currConf : ConfigIntListValues.values()) {
|
||||
// currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getIntList();
|
||||
// }
|
||||
//
|
||||
// for (ConfigStringListValues currConf : ConfigStringListValues.values()) {
|
||||
// currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getStringList();
|
||||
// }
|
||||
//
|
||||
// parseConfiguratorConfig();
|
||||
// }
|
||||
//
|
||||
// private static void parseConfiguratorConfig() {
|
||||
// itemRedstoneTorchConfigurator = null;
|
||||
// itemCompassConfigurator = null;
|
||||
//
|
||||
// String[] conf = ConfigStringListValues.CONFIGURE_ITEMS.getValue();
|
||||
// if (conf.length == 2) {
|
||||
// itemRedstoneTorchConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[0]));
|
||||
// itemCompassConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[1]));
|
||||
// }
|
||||
//
|
||||
// if (itemRedstoneTorchConfigurator == null || itemCompassConfigurator == null) {
|
||||
// ActuallyAdditions.LOGGER.error("Parsing the Configuration Items config failed, reverting back to the default settings!");
|
||||
//
|
||||
// itemRedstoneTorchConfigurator = Item.byBlock(Blocks.REDSTONE_TORCH);
|
||||
// itemCompassConfigurator = Items.COMPASS;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -10,39 +10,33 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.config;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class ConfigurationHandler {
|
||||
|
||||
public static Configuration config;
|
||||
|
||||
public ConfigurationHandler(File configFile) {
|
||||
ActuallyAdditions.LOGGER.info("Grabbing Configurations...");
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
config = new Configuration(configFile);
|
||||
config.load();
|
||||
|
||||
redefineConfigs();
|
||||
}
|
||||
|
||||
public static void redefineConfigs() {
|
||||
ConfigValues.defineConfigValues(config);
|
||||
|
||||
if (config.hasChanged()) {
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) {
|
||||
if (event.getModID().equalsIgnoreCase(ActuallyAdditions.MODID)) {
|
||||
redefineConfigs();
|
||||
}
|
||||
}
|
||||
//
|
||||
// public static Configuration config;
|
||||
//
|
||||
// public ConfigurationHandler(File configFile) {
|
||||
// ActuallyAdditions.LOGGER.info("Grabbing Configurations...");
|
||||
//
|
||||
// MinecraftForge.EVENT_BUS.register(this);
|
||||
//
|
||||
// config = new Configuration(configFile);
|
||||
// config.load();
|
||||
//
|
||||
// redefineConfigs();
|
||||
// }
|
||||
//
|
||||
// public static void redefineConfigs() {
|
||||
// ConfigValues.defineConfigValues(config);
|
||||
//
|
||||
// if (config.hasChanged()) {
|
||||
// config.save();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @SubscribeEvent
|
||||
// public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) {
|
||||
// if (event.getModID().equalsIgnoreCase(ActuallyAdditions.MODID)) {
|
||||
// redefineConfigs();
|
||||
// }
|
||||
// }
|
||||
}
|
|
@ -11,14 +11,10 @@
|
|||
package de.ellpeck.actuallyadditions.mod.data;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.nbt.StringNBT;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -59,8 +55,8 @@ public final class PlayerData {
|
|||
public IBookletPage[] bookmarks = new IBookletPage[12];
|
||||
public List<String> completedTrials = new ArrayList<>();
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public GuiBooklet lastOpenBooklet;
|
||||
// @OnlyIn(Dist.CLIENT)
|
||||
// public GuiBooklet lastOpenBooklet;
|
||||
|
||||
public PlayerSave(UUID id) {
|
||||
this.id = id;
|
||||
|
@ -103,8 +99,8 @@ public final class PlayerData {
|
|||
ListNBT bookmarks = new ListNBT();
|
||||
for (IBookletPage bookmark : this.bookmarks) {
|
||||
bookmarks.add(StringNBT.valueOf(bookmark == null
|
||||
? ""
|
||||
: bookmark.getIdentifier()));
|
||||
? ""
|
||||
: bookmark.getIdentifier()));
|
||||
}
|
||||
return bookmarks;
|
||||
}
|
||||
|
@ -113,8 +109,8 @@ public final class PlayerData {
|
|||
for (int i = 0; i < bookmarks.size(); i++) {
|
||||
String strg = bookmarks.getString(i);
|
||||
if (!strg.isEmpty()) {
|
||||
IBookletPage page = BookletUtils.getBookletPageById(strg);
|
||||
this.bookmarks[i] = page;
|
||||
// IBookletPage page = BookletUtils.getBookletPageById(strg);
|
||||
this.bookmarks[i] = null; // page;
|
||||
} else {
|
||||
this.bookmarks[i] = null;
|
||||
}
|
||||
|
|
|
@ -12,85 +12,71 @@ package de.ellpeck.actuallyadditions.mod.entity;
|
|||
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.DefaultFarmerBehavior;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
public class EntityWorm extends Entity {
|
||||
|
||||
public int timer;
|
||||
|
||||
public EntityWorm(World world) {
|
||||
super(world);
|
||||
this.setEntityBoundingBox(new AxisAlignedBB(0, 0, 0, 0, 0, 0));
|
||||
public EntityWorm(EntityType<?> type, World world) {
|
||||
super(type, world);
|
||||
this.setBoundingBox(new AxisAlignedBB(0, 0, 0, 0, 0, 0));
|
||||
}
|
||||
|
||||
public static boolean canWormify(World world, BlockPos pos, BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
boolean rightBlock = block instanceof BlockFarmland || block instanceof BlockDirt || block instanceof BlockGrass;
|
||||
boolean rightBlock = block instanceof FarmlandBlock || block == Blocks.DIRT || block instanceof GrassBlock;
|
||||
if (rightBlock) {
|
||||
BlockPos posUp = pos.above();
|
||||
BlockState stateUp = world.getBlockState(posUp);
|
||||
Block blockUp = stateUp.getBlock();
|
||||
return blockUp instanceof IPlantable || blockUp instanceof BlockBush || blockUp.canBeReplaced(world, posUp);
|
||||
return blockUp instanceof IPlantable || blockUp instanceof BushBlock || stateUp.getMaterial().isReplaceable();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
|
||||
public boolean canUpdate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(CompoundNBT compound) {
|
||||
this.timer = compound.getInt("Timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(CompoundNBT compound) {
|
||||
compound.putInt("Timer", this.timer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
this.onEntityUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityUpdate() {
|
||||
public void tick() {
|
||||
if (!this.level.isClientSide) {
|
||||
this.timer++;
|
||||
|
||||
if (this.timer % 50 == 0) {
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
BlockPos pos = new BlockPos(this.posX + x, this.posY, this.posZ + z);
|
||||
BlockPos pos = new BlockPos(this.getX() + x, this.getY(), this.getZ() + z);
|
||||
BlockState state = this.level.getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
boolean isMiddlePose = x == 0 && z == 0;
|
||||
|
||||
if (canWormify(this.level, pos, state)) {
|
||||
boolean isFarmland = block instanceof BlockFarmland;
|
||||
boolean isFarmland = block instanceof FarmlandBlock;
|
||||
|
||||
if (!isFarmland || state.getValue(BlockFarmland.MOISTURE) < 7) {
|
||||
if (!isFarmland || state.getValue(FarmlandBlock.MOISTURE) < 7) {
|
||||
if (isMiddlePose || this.level.random.nextFloat() >= 0.45F) {
|
||||
|
||||
if (!isFarmland) {
|
||||
DefaultFarmerBehavior.useHoeAt(this.level, pos);
|
||||
}
|
||||
state = this.level.getBlockState(pos);
|
||||
isFarmland = state.getBlock() instanceof BlockFarmland;
|
||||
isFarmland = state.getBlock() instanceof FarmlandBlock;
|
||||
|
||||
if (isFarmland) {
|
||||
this.level.setBlock(pos, state.withProperty(BlockFarmland.MOISTURE, 7), 2);
|
||||
this.level.setBlock(pos, state.setValue(FarmlandBlock.MOISTURE, 7), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,8 +87,8 @@ public class EntityWorm extends Entity {
|
|||
BlockState plantState = this.level.getBlockState(plant);
|
||||
Block plantBlock = plantState.getBlock();
|
||||
|
||||
if ((plantBlock instanceof IGrowable || plantBlock instanceof IPlantable) && !(plantBlock instanceof BlockGrass)) {
|
||||
plantBlock.updateTick(this.level, plant, plantState, this.level.random);
|
||||
if ((plantBlock instanceof IGrowable || plantBlock instanceof IPlantable) && !(plantBlock instanceof GrassBlock)) {
|
||||
plantBlock.randomTick(plantState, (ServerWorld) this.level, plant, this.level.random);
|
||||
|
||||
BlockState newState = this.level.getBlockState(plant);
|
||||
if (newState != plantState) {
|
||||
|
@ -124,4 +110,24 @@ public class EntityWorm extends Entity {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void defineSynchedData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readAdditionalSaveData(CompoundNBT compound) {
|
||||
this.timer = compound.getInt("Timer");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addAdditionalSaveData(CompoundNBT compound) {
|
||||
compound.putInt("Timer", this.timer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacket<?> getAddEntityPacket() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,47 +10,69 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.entity;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.sun.prism.TextureMap;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.inventory.container.PlayerContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class RenderWorm extends Render<EntityWorm> {
|
||||
public class RenderWorm extends EntityRenderer<EntityWorm> {
|
||||
|
||||
private static ItemStack stack = ItemStack.EMPTY;
|
||||
|
||||
public RenderWorm(EntityRendererManager p_i46179_1_) {
|
||||
super(p_i46179_1_);
|
||||
}
|
||||
|
||||
public static void fixItemStack() {
|
||||
stack = new ItemStack(ActuallyItems.WORM.get());
|
||||
}
|
||||
|
||||
protected RenderWorm(RenderManager renderManager) {
|
||||
super(renderManager);
|
||||
@Override
|
||||
public void render(EntityWorm entity, float partialTicks, float p_225623_3_, MatrixStack matrix, IRenderTypeBuffer buffer, int light) {
|
||||
matrix.pushPose();
|
||||
|
||||
matrix.translate(0, 0.7F, 0);
|
||||
double boop = Util.getMillis() / 70D;
|
||||
matrix.mulPose(new Quaternion(-(float) (boop % 360), 0, 1, 0));
|
||||
|
||||
// stack.getDisplayName()
|
||||
Minecraft.getInstance().getItemRenderer().renderStatic(
|
||||
stack, ItemCameraTransforms.TransformType.FIXED, light, OverlayTexture.NO_OVERLAY, matrix, buffer
|
||||
);
|
||||
|
||||
matrix.popPose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(EntityWorm entity) {
|
||||
return TextureMap.LOCATION_BLOCKS_TEXTURE;
|
||||
}
|
||||
// @Override
|
||||
// public void doRender(EntityWorm entity, double x, double y, double z, float entityYaw, float partialTicks) {
|
||||
// GlStateManager.pushMatrix();
|
||||
// this.bindEntityTexture(entity);
|
||||
// GlStateManager.translate(x, y + 0.7F, z);
|
||||
// double boop = Minecraft.getSystemTime() / 70D;
|
||||
// GlStateManager.rotate(-(float) (boop % 360), 0, 1, 0);
|
||||
// GlStateManager.translate(0, 0, 0.4);
|
||||
//
|
||||
// stack.setStackDisplayName(entity.getName());
|
||||
// AssetUtil.renderItemInWorld(stack, combinedLightIn, combinedOverlayIn, matrices, buffer);
|
||||
//
|
||||
// GlStateManager.popMatrix();
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void doRender(EntityWorm entity, double x, double y, double z, float entityYaw, float partialTicks) {
|
||||
GlStateManager.pushMatrix();
|
||||
this.bindEntityTexture(entity);
|
||||
GlStateManager.translate(x, y + 0.7F, z);
|
||||
double boop = Minecraft.getSystemTime() / 70D;
|
||||
GlStateManager.rotate(-(float) (boop % 360), 0, 1, 0);
|
||||
GlStateManager.translate(0, 0, 0.4);
|
||||
|
||||
stack.setStackDisplayName(entity.getName());
|
||||
AssetUtil.renderItemInWorld(stack, combinedLightIn, combinedOverlayIn, matrices, buffer);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
public ResourceLocation getTextureLocation(EntityWorm pEntity) {
|
||||
return PlayerContainer.BLOCK_ATLAS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,243 +10,243 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.inventory;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiMainPage;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.gui.*;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemBooklet;
|
||||
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
|
||||
//import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiMainPage;
|
||||
//import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@Deprecated
|
||||
enum GuiTypes {
|
||||
FEEDER,
|
||||
GIANT_CHEST,
|
||||
GIANT_CHEST_PAGE_2,
|
||||
GIANT_CHEST_PAGE_3,
|
||||
CRAFTER(false),
|
||||
GRINDER,
|
||||
GRINDER_DOUBLE,
|
||||
FURNACE_DOUBLE,
|
||||
INPUTTER,
|
||||
REPAIRER,
|
||||
INPUTTER_ADVANCED,
|
||||
BREAKER,
|
||||
DROPPER,
|
||||
CANOLA_PRESS,
|
||||
FERMENTING_BARREL,
|
||||
COAL_GENERATOR,
|
||||
OIL_GENERATOR,
|
||||
PHANTOM_PLACER,
|
||||
FLUID_COLLECTOR,
|
||||
COFFEE_MACHINE,
|
||||
DRILL(false),
|
||||
ENERGIZER,
|
||||
ENERVATOR,
|
||||
XP_SOLIDIFIER,
|
||||
CLOUD,
|
||||
BOOK(false),
|
||||
DIRECTIONAL_BREAKER,
|
||||
RANGED_COLLECTOR,
|
||||
MINER,
|
||||
LASER_RELAY_ITEM_WHITELIST,
|
||||
FILTER(false),
|
||||
BAG(false),
|
||||
VOID_BAG(false),
|
||||
BIO_REACTOR,
|
||||
FARMER,
|
||||
FIREWORK_BOX;
|
||||
|
||||
public final boolean checkTileEntity;
|
||||
|
||||
GuiTypes() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
GuiTypes(boolean checkTileEntity) {
|
||||
this.checkTileEntity = checkTileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
public class GuiHandler {
|
||||
|
||||
@Deprecated
|
||||
public Object getServerGuiElement(int id, PlayerEntity player, World world, int x, int y, int z) {
|
||||
TileEntityBase tile = null;
|
||||
if (GuiTypes.values()[id].checkTileEntity) {
|
||||
tile = (TileEntityBase) world.getBlockEntity(new BlockPos(x, y, z));
|
||||
}
|
||||
switch (GuiTypes.values()[id]) {
|
||||
// case FEEDER:
|
||||
// return new ContainerFeeder(player.inventory, tile);
|
||||
// case GIANT_CHEST:
|
||||
// return new ContainerGiantChest(player.inventory, tile, 0);
|
||||
// case GIANT_CHEST_PAGE_2:
|
||||
// return new ContainerGiantChest(player.inventory, tile, 1);
|
||||
// case GIANT_CHEST_PAGE_3:
|
||||
// return new ContainerGiantChest(player.inventory, tile, 2);
|
||||
// case CRAFTER:
|
||||
// return CompatUtil.getCrafterContainerElement(player, world, x, y, z);
|
||||
// case GRINDER:
|
||||
// return new ContainerGrinder(player.inventory, tile, false);
|
||||
// case GRINDER_DOUBLE:
|
||||
// return new ContainerGrinder(player.inventory, tile, true);
|
||||
// case FURNACE_DOUBLE:
|
||||
// return new ContainerFurnaceDouble(player.inventory, tile);
|
||||
// case INPUTTER:
|
||||
// return new ContainerInputter(player.inventory, tile, false);
|
||||
// case INPUTTER_ADVANCED:
|
||||
// return new ContainerInputter(player.inventory, tile, true);
|
||||
// case REPAIRER:
|
||||
// return new ContainerRepairer(player.inventory, tile);
|
||||
// case BREAKER:
|
||||
// return new ContainerBreaker(player.inventory, tile);
|
||||
// case DROPPER:
|
||||
// return new ContainerDropper(player, tile);
|
||||
// case CANOLA_PRESS:
|
||||
// return new ContainerCanolaPress(player.inventory, tile);
|
||||
// case FERMENTING_BARREL:
|
||||
// return new ContainerFermentingBarrel(player.inventory, tile);
|
||||
// case COAL_GENERATOR:
|
||||
// return new ContainerCoalGenerator(player.inventory, tile);
|
||||
// case OIL_GENERATOR:
|
||||
// return new ContainerOilGenerator(player.inventory, tile);
|
||||
// case PHANTOM_PLACER:
|
||||
// return new ContainerPhantomPlacer(player.inventory, tile);
|
||||
// case FLUID_COLLECTOR:
|
||||
// return new ContainerFluidCollector(player.inventory, tile);
|
||||
// case COFFEE_MACHINE:
|
||||
// return new ContainerCoffeeMachine(player.inventory, tile);
|
||||
// case DRILL:
|
||||
// return new ContainerDrill(player.inventory);
|
||||
// case FILTER:
|
||||
// return new ContainerFilter(player.inventory);
|
||||
// case ENERGIZER:
|
||||
// return new ContainerEnergizer(player, tile);
|
||||
// case ENERVATOR:
|
||||
// return new ContainerEnervator(player, tile);
|
||||
// case XP_SOLIDIFIER:
|
||||
// return new ContainerXPSolidifier(player.inventory, tile);
|
||||
// case CLOUD:
|
||||
// return new ContainerSmileyCloud();
|
||||
// case DIRECTIONAL_BREAKER:
|
||||
// return new ContainerDirectionalBreaker(player.inventory, tile);
|
||||
// case RANGED_COLLECTOR:
|
||||
// return new ContainerRangedCollector(player.inventory, tile);
|
||||
// case MINER:
|
||||
// return new ContainerMiner(player.inventory, tile);
|
||||
// case LASER_RELAY_ITEM_WHITELIST:
|
||||
// return new ContainerLaserRelayItemWhitelist(player.inventory, tile);
|
||||
// case BAG:
|
||||
// return new ContainerBag(player.getHeldItemMainhand(), player.inventory, false);
|
||||
// case VOID_BAG:
|
||||
// return new ContainerBag(player.getHeldItemMainhand(), player.inventory, true);
|
||||
// case BIO_REACTOR:
|
||||
// return new ContainerBioReactor(player.inventory, tile);
|
||||
// case FARMER:
|
||||
// return new ContainerFarmer(player.inventory, tile);
|
||||
// case FIREWORK_BOX:
|
||||
// return new ContainerFireworkBox();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
// if (GuiTypes.values()[id].checkTileEntity) {
|
||||
// tile = (TileEntityBase) world.getBlockEntity(new BlockPos(x, y, z));
|
||||
// }
|
||||
// switch (GuiTypes.values()[id]) {
|
||||
// case FEEDER:
|
||||
// return new ContainerFeeder(player.inventory, tile);
|
||||
// case GIANT_CHEST:
|
||||
// return new ContainerGiantChest(player.inventory, tile, 0);
|
||||
// case GIANT_CHEST_PAGE_2:
|
||||
// return new ContainerGiantChest(player.inventory, tile, 1);
|
||||
// case GIANT_CHEST_PAGE_3:
|
||||
// return new ContainerGiantChest(player.inventory, tile, 2);
|
||||
// case CRAFTER:
|
||||
// return CompatUtil.getCrafterContainerElement(player, world, x, y, z);
|
||||
// case GRINDER:
|
||||
// return new ContainerGrinder(player.inventory, tile, false);
|
||||
// case GRINDER_DOUBLE:
|
||||
// return new ContainerGrinder(player.inventory, tile, true);
|
||||
// case FURNACE_DOUBLE:
|
||||
// return new ContainerFurnaceDouble(player.inventory, tile);
|
||||
// case INPUTTER:
|
||||
// return new ContainerInputter(player.inventory, tile, false);
|
||||
// case INPUTTER_ADVANCED:
|
||||
// return new ContainerInputter(player.inventory, tile, true);
|
||||
// case REPAIRER:
|
||||
// return new ContainerRepairer(player.inventory, tile);
|
||||
// case BREAKER:
|
||||
// return new ContainerBreaker(player.inventory, tile);
|
||||
// case DROPPER:
|
||||
// return new ContainerDropper(player, tile);
|
||||
// case CANOLA_PRESS:
|
||||
// return new ContainerCanolaPress(player.inventory, tile);
|
||||
// case FERMENTING_BARREL:
|
||||
// return new ContainerFermentingBarrel(player.inventory, tile);
|
||||
// case COAL_GENERATOR:
|
||||
// return new ContainerCoalGenerator(player.inventory, tile);
|
||||
// case OIL_GENERATOR:
|
||||
// return new ContainerOilGenerator(player.inventory, tile);
|
||||
// case PHANTOM_PLACER:
|
||||
// return new ContainerPhantomPlacer(player.inventory, tile);
|
||||
// case FLUID_COLLECTOR:
|
||||
// return new ContainerFluidCollector(player.inventory, tile);
|
||||
// case COFFEE_MACHINE:
|
||||
// return new ContainerCoffeeMachine(player.inventory, tile);
|
||||
// case DRILL:
|
||||
// return new ContainerDrill(player.inventory);
|
||||
// case FILTER:
|
||||
// return new ContainerFilter(player.inventory);
|
||||
// case ENERGIZER:
|
||||
// return new ContainerEnergizer(player, tile);
|
||||
// case ENERVATOR:
|
||||
// return new ContainerEnervator(player, tile);
|
||||
// case XP_SOLIDIFIER:
|
||||
// return new ContainerXPSolidifier(player.inventory, tile);
|
||||
// case CLOUD:
|
||||
// return new ContainerSmileyCloud();
|
||||
// case DIRECTIONAL_BREAKER:
|
||||
// return new ContainerDirectionalBreaker(player.inventory, tile);
|
||||
// case RANGED_COLLECTOR:
|
||||
// return new ContainerRangedCollector(player.inventory, tile);
|
||||
// case MINER:
|
||||
// return new ContainerMiner(player.inventory, tile);
|
||||
// case LASER_RELAY_ITEM_WHITELIST:
|
||||
// return new ContainerLaserRelayItemWhitelist(player.inventory, tile);
|
||||
// case BAG:
|
||||
// return new ContainerBag(player.getHeldItemMainhand(), player.inventory, false);
|
||||
// case VOID_BAG:
|
||||
// return new ContainerBag(player.getHeldItemMainhand(), player.inventory, true);
|
||||
// case BIO_REACTOR:
|
||||
// return new ContainerBioReactor(player.inventory, tile);
|
||||
// case FARMER:
|
||||
// return new ContainerFarmer(player.inventory, tile);
|
||||
// case FIREWORK_BOX:
|
||||
// return new ContainerFireworkBox();
|
||||
// default:
|
||||
// return null;
|
||||
// }
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Object getClientGuiElement(int id, PlayerEntity player, World world, int x, int y, int z) {
|
||||
TileEntityBase tile = null;
|
||||
if (GuiTypes.values()[id].checkTileEntity) {
|
||||
tile = (TileEntityBase) world.getBlockEntity(new BlockPos(x, y, z));
|
||||
}
|
||||
switch (GuiTypes.values()[id]) {
|
||||
case FEEDER:
|
||||
return new GuiFeeder(player.inventory, tile);
|
||||
case GIANT_CHEST:
|
||||
return new GuiGiantChest(player.inventory, tile, 0);
|
||||
case GIANT_CHEST_PAGE_2:
|
||||
return new GuiGiantChest(player.inventory, tile, 1);
|
||||
case GIANT_CHEST_PAGE_3:
|
||||
return new GuiGiantChest(player.inventory, tile, 2);
|
||||
case CRAFTER:
|
||||
return CompatUtil.getCrafterGuiElement(player, world, x, y, z);
|
||||
case GRINDER:
|
||||
return new GuiGrinder(player.inventory, tile);
|
||||
case GRINDER_DOUBLE:
|
||||
return new GuiGrinder.GuiGrinderDouble(player.inventory, tile);
|
||||
case FURNACE_DOUBLE:
|
||||
return new GuiFurnaceDouble(player.inventory, tile);
|
||||
case INPUTTER:
|
||||
return new GuiInputter(player.inventory, tile, false);
|
||||
case INPUTTER_ADVANCED:
|
||||
return new GuiInputter(player.inventory, tile, true);
|
||||
case REPAIRER:
|
||||
return new GuiRepairer(player.inventory, tile);
|
||||
// case BREAKER:
|
||||
// return new GuiBreaker(player.inventory, tile);
|
||||
case DROPPER:
|
||||
return new GuiDropper(player, tile);
|
||||
case CANOLA_PRESS:
|
||||
return new GuiCanolaPress(player.inventory, tile);
|
||||
case FERMENTING_BARREL:
|
||||
return new GuiFermentingBarrel(player.inventory, tile);
|
||||
case COAL_GENERATOR:
|
||||
return new GuiCoalGenerator(player.inventory, tile);
|
||||
case OIL_GENERATOR:
|
||||
return new GuiOilGenerator(player.inventory, tile);
|
||||
case PHANTOM_PLACER:
|
||||
return new GuiPhantomPlacer(player.inventory, tile);
|
||||
case FLUID_COLLECTOR:
|
||||
return new GuiFluidCollector(player.inventory, tile);
|
||||
case COFFEE_MACHINE:
|
||||
return new GuiCoffeeMachine(player.inventory, tile);
|
||||
case DRILL:
|
||||
return new GuiDrill(player.inventory);
|
||||
case FILTER:
|
||||
return new GuiFilter(player.inventory);
|
||||
case ENERGIZER:
|
||||
return new GuiEnergizer(player, tile);
|
||||
case ENERVATOR:
|
||||
return new GuiEnervator(player, tile);
|
||||
case XP_SOLIDIFIER:
|
||||
return new GuiXPSolidifier(player.inventory, tile);
|
||||
case CLOUD:
|
||||
return new GuiSmileyCloud(tile, x, y, z, world);
|
||||
case BOOK:
|
||||
if (ItemBooklet.forcedPage != null) {
|
||||
GuiBooklet gui = BookletUtils.createBookletGuiFromPage(null, ItemBooklet.forcedPage);
|
||||
ItemBooklet.forcedPage = null;
|
||||
return gui;
|
||||
} else {
|
||||
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
||||
if (data.lastOpenBooklet != null) {
|
||||
return data.lastOpenBooklet;
|
||||
} else {
|
||||
return new GuiMainPage(null);
|
||||
}
|
||||
}
|
||||
case DIRECTIONAL_BREAKER:
|
||||
return new GuiDirectionalBreaker(player.inventory, tile);
|
||||
case RANGED_COLLECTOR:
|
||||
return new GuiRangedCollector(player.inventory, tile);
|
||||
case MINER:
|
||||
return new GuiMiner(player.inventory, tile);
|
||||
case LASER_RELAY_ITEM_WHITELIST:
|
||||
return new GuiLaserRelayItemWhitelist(player.inventory, tile);
|
||||
// case BAG:
|
||||
// return new GuiBag(player.getHeldItemMainhand(), player.inventory, false);
|
||||
// case VOID_BAG:
|
||||
// return new GuiBag(player.getHeldItemMainhand(), player.inventory, true);
|
||||
case BIO_REACTOR:
|
||||
return new GuiBioReactor(player.inventory, tile);
|
||||
case FARMER:
|
||||
return new GuiFarmer(player.inventory, tile);
|
||||
case FIREWORK_BOX:
|
||||
return new GuiFireworkBox(tile);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// TileEntityBase tile = null;
|
||||
// if (GuiTypes.values()[id].checkTileEntity) {
|
||||
// tile = (TileEntityBase) world.getBlockEntity(new BlockPos(x, y, z));
|
||||
// }
|
||||
// switch (GuiTypes.values()[id]) {
|
||||
// case FEEDER:
|
||||
// return new GuiFeeder(player.inventory, tile);
|
||||
// case GIANT_CHEST:
|
||||
// return new GuiGiantChest(player.inventory, tile, 0);
|
||||
// case GIANT_CHEST_PAGE_2:
|
||||
// return new GuiGiantChest(player.inventory, tile, 1);
|
||||
// case GIANT_CHEST_PAGE_3:
|
||||
// return new GuiGiantChest(player.inventory, tile, 2);
|
||||
// case CRAFTER:
|
||||
// return CompatUtil.getCrafterGuiElement(player, world, x, y, z);
|
||||
// case GRINDER:
|
||||
// return new GuiGrinder(player.inventory, tile);
|
||||
// case GRINDER_DOUBLE:
|
||||
// return new GuiGrinder.GuiGrinderDouble(player.inventory, tile);
|
||||
// case FURNACE_DOUBLE:
|
||||
// return new GuiFurnaceDouble(player.inventory, tile);
|
||||
// case INPUTTER:
|
||||
// return new GuiInputter(player.inventory, tile, false);
|
||||
// case INPUTTER_ADVANCED:
|
||||
// return new GuiInputter(player.inventory, tile, true);
|
||||
// case REPAIRER:
|
||||
// return new GuiRepairer(player.inventory, tile);
|
||||
// // case BREAKER:
|
||||
// // return new GuiBreaker(player.inventory, tile);
|
||||
// case DROPPER:
|
||||
// return new GuiDropper(player, tile);
|
||||
// case CANOLA_PRESS:
|
||||
// return new GuiCanolaPress(player.inventory, tile);
|
||||
// case FERMENTING_BARREL:
|
||||
// return new GuiFermentingBarrel(player.inventory, tile);
|
||||
// case COAL_GENERATOR:
|
||||
// return new GuiCoalGenerator(player.inventory, tile);
|
||||
// case OIL_GENERATOR:
|
||||
// return new GuiOilGenerator(player.inventory, tile);
|
||||
// case PHANTOM_PLACER:
|
||||
// return new GuiPhantomPlacer(player.inventory, tile);
|
||||
// case FLUID_COLLECTOR:
|
||||
// return new GuiFluidCollector(player.inventory, tile);
|
||||
// case COFFEE_MACHINE:
|
||||
// return new GuiCoffeeMachine(player.inventory, tile);
|
||||
// case DRILL:
|
||||
// return new GuiDrill(player.inventory);
|
||||
// case FILTER:
|
||||
// return new GuiFilter(player.inventory);
|
||||
// case ENERGIZER:
|
||||
// return new GuiEnergizer(player, tile);
|
||||
// case ENERVATOR:
|
||||
// return new GuiEnervator(player, tile);
|
||||
// case XP_SOLIDIFIER:
|
||||
// return new GuiXPSolidifier(player.inventory, tile);
|
||||
// case CLOUD:
|
||||
// return new GuiSmileyCloud(tile, x, y, z, world);
|
||||
// case BOOK:
|
||||
// if (ItemBooklet.forcedPage != null) {
|
||||
// GuiBooklet gui = BookletUtils.createBookletGuiFromPage(null, ItemBooklet.forcedPage);
|
||||
// ItemBooklet.forcedPage = null;
|
||||
// return gui;
|
||||
// } else {
|
||||
// PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
||||
// if (data.lastOpenBooklet != null) {
|
||||
// return data.lastOpenBooklet;
|
||||
// } else {
|
||||
// return new GuiMainPage(null);
|
||||
// }
|
||||
// }
|
||||
// case DIRECTIONAL_BREAKER:
|
||||
// return new GuiDirectionalBreaker(player.inventory, tile);
|
||||
// case RANGED_COLLECTOR:
|
||||
// return new GuiRangedCollector(player.inventory, tile);
|
||||
// case MINER:
|
||||
// return new GuiMiner(player.inventory, tile);
|
||||
// case LASER_RELAY_ITEM_WHITELIST:
|
||||
// return new GuiLaserRelayItemWhitelist(player.inventory, tile);
|
||||
// // case BAG:
|
||||
// // return new GuiBag(player.getHeldItemMainhand(), player.inventory, false);
|
||||
// // case VOID_BAG:
|
||||
// // return new GuiBag(player.getHeldItemMainhand(), player.inventory, true);
|
||||
// case BIO_REACTOR:
|
||||
// return new GuiBioReactor(player.inventory, tile);
|
||||
// case FARMER:
|
||||
// return new GuiFarmer(player.inventory, tile);
|
||||
// case FIREWORK_BOX:
|
||||
// return new GuiFireworkBox(tile);
|
||||
// default:
|
||||
// return null;
|
||||
|
||||
@Deprecated
|
||||
public enum GuiTypes {
|
||||
FEEDER,
|
||||
GIANT_CHEST,
|
||||
GIANT_CHEST_PAGE_2,
|
||||
GIANT_CHEST_PAGE_3,
|
||||
CRAFTER(false),
|
||||
GRINDER,
|
||||
GRINDER_DOUBLE,
|
||||
FURNACE_DOUBLE,
|
||||
INPUTTER,
|
||||
REPAIRER,
|
||||
INPUTTER_ADVANCED,
|
||||
BREAKER,
|
||||
DROPPER,
|
||||
CANOLA_PRESS,
|
||||
FERMENTING_BARREL,
|
||||
COAL_GENERATOR,
|
||||
OIL_GENERATOR,
|
||||
PHANTOM_PLACER,
|
||||
FLUID_COLLECTOR,
|
||||
COFFEE_MACHINE,
|
||||
DRILL(false),
|
||||
ENERGIZER,
|
||||
ENERVATOR,
|
||||
XP_SOLIDIFIER,
|
||||
CLOUD,
|
||||
BOOK(false),
|
||||
DIRECTIONAL_BREAKER,
|
||||
RANGED_COLLECTOR,
|
||||
MINER,
|
||||
LASER_RELAY_ITEM_WHITELIST,
|
||||
FILTER(false),
|
||||
BAG(false),
|
||||
VOID_BAG(false),
|
||||
BIO_REACTOR,
|
||||
FARMER,
|
||||
FIREWORK_BOX;
|
||||
|
||||
public final boolean checkTileEntity;
|
||||
|
||||
GuiTypes() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
GuiTypes(boolean checkTileEntity) {
|
||||
this.checkTileEntity = checkTileEntity;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,14 +14,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
|||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MainWindow;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
|
@ -53,30 +46,30 @@ public class ItemBooklet extends ItemBase implements IHudDisplay {
|
|||
|
||||
@Override
|
||||
public ActionResultType useOn(ItemUseContext context) {
|
||||
if (context.getPlayer().isShiftKeyDown()) {
|
||||
BlockState state = context.getLevel().getBlockState(context.getClickedPos());
|
||||
Block block = state.getBlock();
|
||||
ItemStack blockStack = new ItemStack(block);
|
||||
IBookletPage page = BookletUtils.findFirstPageForStack(blockStack);
|
||||
if (page != null) {
|
||||
if (context.getLevel().isClientSide) {
|
||||
forcedPage = page;
|
||||
}
|
||||
this.use(context.getLevel(), context.getPlayer(), context.getHand());
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
// if (context.getPlayer().isShiftKeyDown()) {
|
||||
// BlockState state = context.getLevel().getBlockState(context.getClickedPos());
|
||||
// Block block = state.getBlock();
|
||||
// ItemStack blockStack = new ItemStack(block);
|
||||
// IBookletPage page = BookletUtils.findFirstPageForStack(blockStack);
|
||||
// if (page != null) {
|
||||
// if (context.getLevel().isClientSide) {
|
||||
// forcedPage = page;
|
||||
// }
|
||||
// this.use(context.getLevel(), context.getPlayer(), context.getHand());
|
||||
// return ActionResultType.SUCCESS;
|
||||
// }
|
||||
// }
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BOOK.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
|
||||
if (!world.isClientSide) {
|
||||
//TheAchievements.OPEN_BOOKLET.get(player);
|
||||
//TheAchievements.OPEN_BOOKLET_MILESTONE.get(player);
|
||||
}
|
||||
// player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BOOK.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
//
|
||||
// if (!world.isClientSide) {
|
||||
// //TheAchievements.OPEN_BOOKLET.get(player);
|
||||
// //TheAchievements.OPEN_BOOKLET_MILESTONE.get(player);
|
||||
// }
|
||||
return ActionResult.success(player.getItemInHand(hand));
|
||||
}
|
||||
|
||||
|
@ -87,46 +80,46 @@ public class ItemBooklet extends ItemBase implements IHudDisplay {
|
|||
// TODO: this is bad
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
tooltip.add(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + "." + this.getDescription().getString() + ".sub." + i).withStyle(i == 4
|
||||
? TextFormatting.GOLD
|
||||
: TextFormatting.RESET).withStyle(i == 4
|
||||
? TextFormatting.ITALIC
|
||||
: TextFormatting.RESET));
|
||||
? TextFormatting.GOLD
|
||||
: TextFormatting.RESET).withStyle(i == 4
|
||||
? TextFormatting.ITALIC
|
||||
: TextFormatting.RESET));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void displayHud(MatrixStack matrices, Minecraft minecraft, PlayerEntity player, ItemStack stack, RayTraceResult rayCast, MainWindow resolution) {
|
||||
if (rayCast != null && rayCast.getBlockPos() != null) {
|
||||
BlockState state = minecraft.level.getBlockState(rayCast.getBlockPos());
|
||||
Block block = state.getBlock();
|
||||
if (block != null && !block.isAir(minecraft.level.getBlockState(rayCast.getBlockPos()), minecraft.level, rayCast.getBlockPos())) {
|
||||
ItemStack blockStack = new ItemStack(block, 1, block.getMetaFromState(state));
|
||||
int height = resolution.getGuiScaledHeight() / 5 * 3;
|
||||
if (player.isShiftKeyDown()) {
|
||||
IBookletPage page = BookletUtils.findFirstPageForStack(blockStack);
|
||||
if (page != null) {
|
||||
String strg1 = page.getChapter().getLocalizedName();
|
||||
String strg2 = StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.page") + " " + (page.getChapter().getPageIndex(page) + 1);
|
||||
String strg3 = StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.open");
|
||||
|
||||
AssetUtil.renderStackToGui(StackUtil.isValid(page.getChapter().getDisplayItemStack())
|
||||
? page.getChapter().getDisplayItemStack()
|
||||
: new ItemStack(ActuallyItems.ITEM_BOOKLET.get()), resolution.getGuiScaledWidth() / 2 - 10, height + 41, 1F);
|
||||
minecraft.font.drawShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg1, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg1) / 2, height + 20, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
minecraft.font.drawShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg2, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg2) / 2, height + 30, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
minecraft.font.drawShadow(TextFormatting.GOLD + strg3, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg3) / 2, height + 60, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
} else {
|
||||
String strg1 = TextFormatting.DARK_RED + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.noInfo");
|
||||
String strg2 = TextFormatting.DARK_GREEN + "" + TextFormatting.ITALIC + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.noInfo.desc.1");
|
||||
String strg3 = TextFormatting.DARK_GREEN + "" + TextFormatting.ITALIC + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.noInfo.desc.2");
|
||||
|
||||
minecraft.font.drawShadow(strg1, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg1) / 2, height + 30, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
minecraft.font.drawShadow(strg2, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg2) / 2, height + 50, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
minecraft.font.drawShadow(strg3, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg3) / 2, height + 60, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (rayCast != null && rayCast.getBlockPos() != null) {
|
||||
// BlockState state = minecraft.level.getBlockState(rayCast.getBlockPos());
|
||||
// Block block = state.getBlock();
|
||||
// if (block != null && !block.isAir(minecraft.level.getBlockState(rayCast.getBlockPos()), minecraft.level, rayCast.getBlockPos())) {
|
||||
// ItemStack blockStack = new ItemStack(block, 1, block.getMetaFromState(state));
|
||||
// int height = resolution.getGuiScaledHeight() / 5 * 3;
|
||||
// if (player.isShiftKeyDown()) {
|
||||
// IBookletPage page = BookletUtils.findFirstPageForStack(blockStack);
|
||||
// if (page != null) {
|
||||
// String strg1 = page.getChapter().getLocalizedName();
|
||||
// String strg2 = StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.page") + " " + (page.getChapter().getPageIndex(page) + 1);
|
||||
// String strg3 = StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.open");
|
||||
//
|
||||
// AssetUtil.renderStackToGui(StackUtil.isValid(page.getChapter().getDisplayItemStack())
|
||||
// ? page.getChapter().getDisplayItemStack()
|
||||
// : new ItemStack(ActuallyItems.ITEM_BOOKLET.get()), resolution.getGuiScaledWidth() / 2 - 10, height + 41, 1F);
|
||||
// minecraft.font.drawShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg1, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg1) / 2, height + 20, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
// minecraft.font.drawShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg2, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg2) / 2, height + 30, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
// minecraft.font.drawShadow(TextFormatting.GOLD + strg3, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg3) / 2, height + 60, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
// } else {
|
||||
// String strg1 = TextFormatting.DARK_RED + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.noInfo");
|
||||
// String strg2 = TextFormatting.DARK_GREEN + "" + TextFormatting.ITALIC + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.noInfo.desc.1");
|
||||
// String strg3 = TextFormatting.DARK_GREEN + "" + TextFormatting.ITALIC + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.noInfo.desc.2");
|
||||
//
|
||||
// minecraft.font.drawShadow(strg1, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg1) / 2, height + 30, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
// minecraft.font.drawShadow(strg2, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg2) / 2, height + 50, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
// minecraft.font.drawShadow(strg3, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg3) / 2, height + 60, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,82 +1,82 @@
|
|||
/*
|
||||
* This file ("ItemCrystalShard.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.items;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockCrystal;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.IRarity;
|
||||
|
||||
|
||||
public class ItemCrystalShard extends ItemBase implements IColorProvidingItem {
|
||||
|
||||
public ItemCrystalShard() {
|
||||
super(name);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescriptionId(ItemStack stack) {
|
||||
return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length
|
||||
? StringUtil.BUGGED_ITEM_NAME
|
||||
: this.getDescriptionId() + "_" + BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRarity getForgeRarity(ItemStack stack) {
|
||||
return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length
|
||||
? EnumRarity.COMMON
|
||||
: BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].rarity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
if (this.isInCreativeTab(tab)) {
|
||||
for (int j = 0; j < BlockCrystal.ALL_CRYSTALS.length; j++) {
|
||||
list.add(new ItemStack(this, 1, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRendering() {
|
||||
for (int i = 0; i < BlockCrystal.ALL_CRYSTALS.length; i++) {
|
||||
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), "inventory");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public IItemColor getItemColor() {
|
||||
return (stack, tintIndex) -> {
|
||||
int damage = stack.getItemDamage();
|
||||
if (damage >= 0 && damage < BlockCrystal.ALL_CRYSTALS.length) {
|
||||
return BlockCrystal.ALL_CRYSTALS[damage].clusterColor;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * This file ("ItemCrystalShard.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.items;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.BlockCrystal;
|
||||
//import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
//import net.minecraft.client.renderer.color.IItemColor;
|
||||
//import net.minecraft.creativetab.CreativeTabs;
|
||||
//import net.minecraft.item.EnumRarity;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraft.util.NonNullList;
|
||||
//import net.minecraftforge.common.IRarity;
|
||||
//
|
||||
//
|
||||
//public class ItemCrystalShard extends ItemBase implements IColorProvidingItem {
|
||||
//
|
||||
// public ItemCrystalShard() {
|
||||
// super(name);
|
||||
// this.setHasSubtypes(true);
|
||||
// this.setMaxDamage(0);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getMetadata(int damage) {
|
||||
// return damage;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getDescriptionId(ItemStack stack) {
|
||||
// return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length
|
||||
// ? StringUtil.BUGGED_ITEM_NAME
|
||||
// : this.getDescriptionId() + "_" + BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].name;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IRarity getForgeRarity(ItemStack stack) {
|
||||
// return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length
|
||||
// ? EnumRarity.COMMON
|
||||
// : BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].rarity;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @OnlyIn(Dist.CLIENT)
|
||||
// public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
// if (this.isInCreativeTab(tab)) {
|
||||
// for (int j = 0; j < BlockCrystal.ALL_CRYSTALS.length; j++) {
|
||||
// list.add(new ItemStack(this, 1, j));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void registerRendering() {
|
||||
// for (int i = 0; i < BlockCrystal.ALL_CRYSTALS.length; i++) {
|
||||
// ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), "inventory");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @OnlyIn(Dist.CLIENT)
|
||||
// public IItemColor getItemColor() {
|
||||
// return (stack, tintIndex) -> {
|
||||
// int damage = stack.getItemDamage();
|
||||
// if (damage >= 0 && damage < BlockCrystal.ALL_CRYSTALS.length) {
|
||||
// return BlockCrystal.ALL_CRYSTALS[damage].clusterColor;
|
||||
// } else {
|
||||
// return 0;
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -14,7 +14,6 @@ import com.google.common.collect.Multimap;
|
|||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerDrill;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||
|
@ -26,11 +25,13 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.inventory.container.SimpleNamedContainerProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
|
@ -38,18 +39,14 @@ import net.minecraft.util.*;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemDrill extends ItemEnergy {
|
||||
|
||||
|
@ -57,10 +54,7 @@ public class ItemDrill extends ItemEnergy {
|
|||
private static final int ENERGY_USE = 100;
|
||||
|
||||
public ItemDrill() {
|
||||
super(ActuallyItems.defaultProps().defaultDurability(0).stacksTo(1), 250000, 1000);
|
||||
this.setHasSubtypes(true);
|
||||
this.setHarvestLevel("shovel", HARVEST_LEVEL);
|
||||
this.setHarvestLevel("pickaxe", HARVEST_LEVEL);
|
||||
super(ActuallyItems.defaultProps().defaultDurability(0).stacksTo(1).addToolType(ToolType.SHOVEL, HARVEST_LEVEL).addToolType(ToolType.PICKAXE, HARVEST_LEVEL), 250000, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -153,25 +147,21 @@ public class ItemDrill extends ItemEnergy {
|
|||
@Override
|
||||
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||
if (!world.isClientSide && player.isShiftKeyDown() && hand == Hand.MAIN_HAND) {
|
||||
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DRILL.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
player.openMenu(new SimpleNamedContainerProvider((id, inv, p) -> new ContainerDrill(id, inv), new StringTextComponent("")));
|
||||
// player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DRILL.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
}
|
||||
return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase entity1, EntityLivingBase entity2) {
|
||||
public ActionResultType interactLivingEntity(ItemStack stack, PlayerEntity player, LivingEntity entityHit, Hand hand) {
|
||||
int use = this.getEnergyUsePerBlock(stack);
|
||||
if (!(entity2 instanceof PlayerEntity) || !((PlayerEntity) entity2).isCreative()) {
|
||||
if (!(entityHit instanceof PlayerEntity) || !((PlayerEntity) entityHit).isCreative()) {
|
||||
if (this.getEnergyStored(stack) >= use) {
|
||||
this.extractEnergyInternal(stack, use, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -192,7 +182,7 @@ public class ItemDrill extends ItemEnergy {
|
|||
@Override
|
||||
public float getDestroySpeed(ItemStack stack, BlockState state) {
|
||||
return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack)
|
||||
? this.hasExtraWhitelist(state.getBlock()) || state.getBlock().getHarvestTool(state) == null || state.getBlock().getHarvestTool(state) || this.getToolClasses(stack).contains(state.getBlock().getHarvestTool(state))
|
||||
? (this.hasExtraWhitelist(state.getBlock()) || state.getBlock().getHarvestTool(state) == null || state.getBlock().getHarvestTool(state) == ToolType.PICKAXE || state.getBlock().getHarvestTool(state) == ToolType.SHOVEL)
|
||||
? this.getEfficiencyFromUpgrade(stack)
|
||||
: 1.0F
|
||||
: 0.1F;
|
||||
|
@ -240,7 +230,7 @@ public class ItemDrill extends ItemEnergy {
|
|||
@Override
|
||||
public boolean canHarvestBlock(ItemStack stack, BlockState state) {
|
||||
Block block = state.getBlock();
|
||||
return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) && (this.hasExtraWhitelist(block) || state.getMaterial().isToolNotRequired() || block == Blocks.SNOW_LAYER || block == Blocks.SNOW || (block == Blocks.OBSIDIAN
|
||||
return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) && (this.hasExtraWhitelist(block) || state.getMaterial().isReplaceable() || block == Blocks.SNOW_BLOCK || block == Blocks.SNOW || (block == Blocks.OBSIDIAN
|
||||
? HARVEST_LEVEL >= 3
|
||||
: block != Blocks.DIAMOND_BLOCK && block != Blocks.DIAMOND_ORE
|
||||
? block != Blocks.EMERALD_ORE && block != Blocks.EMERALD_BLOCK
|
||||
|
@ -257,14 +247,6 @@ public class ItemDrill extends ItemEnergy {
|
|||
: HARVEST_LEVEL >= 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getToolClasses(ItemStack stack) {
|
||||
HashSet<String> hashSet = new HashSet<>();
|
||||
hashSet.add("pickaxe");
|
||||
hashSet.add("shovel");
|
||||
return hashSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(ItemStack stack, ToolType p_getHarvestLevel_2_, @Nullable PlayerEntity p_getHarvestLevel_3_, @Nullable BlockState p_getHarvestLevel_4_) {
|
||||
return HARVEST_LEVEL;
|
||||
|
@ -325,25 +307,25 @@ public class ItemDrill extends ItemEnergy {
|
|||
return StackUtil.isValid(this.getHasUpgradeAsStack(stack, upgrade));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void getSubItems(CreativeTabs tabs, NonNullList<ItemStack> list) {
|
||||
if (this.isInCreativeTab(tabs)) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
this.addDrillStack(list, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
// @Override
|
||||
// @OnlyIn(Dist.CLIENT)
|
||||
// public void getSubItems(CreativeTabs tabs, NonNullList<ItemStack> list) {
|
||||
// if (this.isInCreativeTab(tabs)) {
|
||||
// for (int i = 0; i < 16; i++) {
|
||||
// this.addDrillStack(list, i);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
private void addDrillStack(List<ItemStack> list, int meta) {
|
||||
ItemStack stackFull = new ItemStack(this, 1, meta);
|
||||
this.setEnergy(stackFull, this.getMaxEnergyStored(stackFull));
|
||||
list.add(stackFull);
|
||||
|
||||
ItemStack stackEmpty = new ItemStack(this, 1, meta);
|
||||
this.setEnergy(stackEmpty, 0);
|
||||
list.add(stackEmpty);
|
||||
}
|
||||
// private void addDrillStack(List<ItemStack> list, int meta) {
|
||||
// ItemStack stackFull = new ItemStack(this, 1, meta);
|
||||
// this.setEnergy(stackFull, this.getMaxEnergyStored(stackFull));
|
||||
// list.add(stackFull);
|
||||
//
|
||||
// ItemStack stackEmpty = new ItemStack(this, 1, meta);
|
||||
// this.setEnergy(stackEmpty, 0);
|
||||
// list.add(stackEmpty);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Gets the Mining Speed of the Drill
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.items;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||
import de.ellpeck.actuallyadditions.mod.entity.EntityWorm;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
|
@ -51,7 +52,7 @@ public class ItemWorm extends ItemBase {
|
|||
List<EntityWorm> worms = context.getLevel().getEntitiesOfClass(EntityWorm.class, new AxisAlignedBB(pos.getX() - 1, pos.getY(), pos.getZ() - 1, pos.getX() + 2, pos.getY() + 1, pos.getZ() + 2));
|
||||
if (worms.isEmpty()) {
|
||||
if (!context.getLevel().isClientSide) {
|
||||
EntityWorm worm = new EntityWorm(context.getLevel());
|
||||
EntityWorm worm = new EntityWorm(ActuallyAdditions.ENTITY_WORM.get(), context.getLevel());
|
||||
worm.setPos(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
||||
worm.setCustomName(stack.getHoverName()); // TODO: WHAT DOES THIS EVEN DO?
|
||||
context.getLevel().addFreshEntity(worm);
|
||||
|
|
|
@ -11,12 +11,13 @@
|
|||
package de.ellpeck.actuallyadditions.mod.items.base;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.misc.IDisableableItem;
|
||||
import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.IItemTier;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ToolItem;
|
||||
import net.minecraft.tags.ITag;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -28,23 +29,32 @@ public class ItemToolAA extends ToolItem implements IDisableableItem {
|
|||
private final ITag<Item> repairTag;
|
||||
private final boolean disabled;
|
||||
|
||||
public ItemToolAA(float attack, float speed, IItemTier toolMat, String repairItem, String unlocalizedName, Rarity rarity, Set<Block> effectiveStuff) {
|
||||
this(attack, speed, toolMat, ItemStack.EMPTY, unlocalizedName, rarity, effectiveStuff);
|
||||
this.repairOredict = repairItem;
|
||||
}
|
||||
|
||||
public ItemToolAA(float attack, float speed, ToolMaterial toolMat, ItemStack repairItem, String unlocalizedName, IRarity rarity, Set<Block> effectiveStuff) {
|
||||
super(attack, speed, toolMat, effectiveStuff);
|
||||
public ItemToolAA(float p_i48512_1_, float p_i48512_2_, IItemTier p_i48512_3_, Set<Block> p_i48512_4_, Properties p_i48512_5_, String name, ItemStack repairItem, ITag<Item> repairTag) {
|
||||
super(p_i48512_1_, p_i48512_2_, p_i48512_3_, p_i48512_4_, p_i48512_5_);
|
||||
|
||||
this.name = name;
|
||||
this.repairItem = repairItem;
|
||||
this.name = unlocalizedName;
|
||||
this.rarity = rarity;
|
||||
this.disabled = ConfigurationHandler.config.getBoolean("Disable: " + StringUtil.badTranslate(unlocalizedName), "Tool Control", false, "This will disable the " + StringUtil.badTranslate(unlocalizedName) + ". It will not be registered.");
|
||||
if (!this.disabled) {
|
||||
this.register();
|
||||
}
|
||||
this.repairTag = repairTag;
|
||||
this.disabled = false;
|
||||
}
|
||||
|
||||
// public ItemToolAA(float attack, float speed, IItemTier toolMat, String repairItem, String unlocalizedName, Rarity rarity, Set<Block> effectiveStuff) {
|
||||
// this(attack, speed, toolMat, ItemStack.EMPTY, unlocalizedName, rarity, effectiveStuff);
|
||||
// this.repairOredict = repairItem;
|
||||
// }
|
||||
|
||||
// public ItemToolAA(float attack, float speed, ToolMaterial toolMat, ItemStack repairItem, String unlocalizedName, Rarity rarity, Set<Block> effectiveStuff) {
|
||||
// super(attack, speed, toolMat, effectiveStuff);
|
||||
//
|
||||
// this.repairItem = repairItem;
|
||||
// this.name = unlocalizedName;
|
||||
// this.rarity = rarity;
|
||||
//// this.disabled = ConfigurationHandler.config.getBoolean("Disable: " + StringUtil.badTranslate(unlocalizedName), "Tool Control", false, "This will disable the " + StringUtil.badTranslate(unlocalizedName) + ". It will not be registered.");
|
||||
//// if (!this.disabled) {
|
||||
//// this.register();
|
||||
//// }
|
||||
// }
|
||||
|
||||
private void register() {
|
||||
}
|
||||
|
||||
|
|
|
@ -20,12 +20,6 @@ import de.ellpeck.actuallyadditions.api.lens.Lens;
|
|||
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockLaserRelay;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapter;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapterTrials;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrafting;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.page.PageFurnace;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.page.PagePicture;
|
||||
import de.ellpeck.actuallyadditions.mod.booklet.page.PageTextOnly;
|
||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||
import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
|
||||
|
@ -39,8 +33,8 @@ import net.minecraft.item.BlockItem;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.potion.Effect;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -97,12 +91,12 @@ public class MethodHandler implements IMethodHandler {
|
|||
for (int i = 0; i < effects.length; i++) {
|
||||
if (effects[i].getEffect() == effect.getEffect()) {
|
||||
effects[i] = new EffectInstance(effects[i].getEffect(), effects[i].getDuration() + (addDur
|
||||
? effect.getDuration()
|
||||
: 0), effects[i].getAmplifier() + (addAmp
|
||||
? effect.getAmplifier() > 0
|
||||
? effect.getAmplifier()
|
||||
: 1
|
||||
: 0));
|
||||
? effect.getDuration()
|
||||
: 0), effects[i].getAmplifier() + (addAmp
|
||||
? effect.getAmplifier() > 0
|
||||
? effect.getAmplifier()
|
||||
: 1
|
||||
: 0));
|
||||
}
|
||||
this.addEffectToStack(stack, effects[i]);
|
||||
}
|
||||
|
@ -112,7 +106,7 @@ public class MethodHandler implements IMethodHandler {
|
|||
public void addEffectToStack(ItemStack stack, EffectInstance effect) {
|
||||
CompoundNBT tag = stack.getOrCreateTag();
|
||||
|
||||
int prevCounter = tag.putInt("Counter");
|
||||
int prevCounter = tag.getInt("Counter");
|
||||
CompoundNBT compound = new CompoundNBT();
|
||||
//compound.putInt("ID", Potion.getIdFromPotion(effect.getEffect())); //TODO ?!
|
||||
compound.putInt("Duration", effect.getDuration());
|
||||
|
@ -132,13 +126,13 @@ public class MethodHandler implements IMethodHandler {
|
|||
int counter = tag.getInt("Counter");
|
||||
while (counter > 0) {
|
||||
CompoundNBT compound = (CompoundNBT) tag.get(counter + "");
|
||||
EffectInstance effect = new EffectInstance(Potion.getPotionById(compound.getInt("ID")), compound.getInt("Duration"), compound.getByte("Amplifier"));
|
||||
EffectInstance effect = new EffectInstance(Effect.byId(compound.getInt("ID")), compound.getInt("Duration"), compound.getByte("Amplifier"));
|
||||
effects.add(effect);
|
||||
counter--;
|
||||
}
|
||||
return effects.size() > 0
|
||||
? effects.toArray(new EffectInstance[effects.size()])
|
||||
: null;
|
||||
? effects.toArray(new EffectInstance[effects.size()])
|
||||
: null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,56 +1,56 @@
|
|||
package de.ellpeck.actuallyadditions.mod.recipe;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.DyeColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ColorLensRotator implements IColorLensChanger {
|
||||
|
||||
public static final Map<String, DyeColor> STRING_TO_ENUM = new HashMap<>();
|
||||
|
||||
static {
|
||||
String[] dyes = {"White", "Orange", "Magenta", "LightBlue", "Yellow", "Lime", "Pink", "Gray", "LightGray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black"};
|
||||
for (int i = 0; i < dyes.length; i++) {
|
||||
STRING_TO_ENUM.put("dye" + dyes[i], DyeColor.byMetadata(i));
|
||||
}
|
||||
}
|
||||
|
||||
final List<ItemStack> rotations;
|
||||
|
||||
public ColorLensRotator(List<ItemStack> rotations) {
|
||||
this.rotations = rotations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack modifyItem(ItemStack stack, BlockState hitBlockState, BlockPos hitBlock, IAtomicReconstructor tile) {
|
||||
|
||||
int idx = -1;
|
||||
|
||||
for (int i : OreDictionary.getOreIDs(stack)) {
|
||||
String s = OreDictionary.getOreName(i);
|
||||
if (s.startsWith("dye")) {
|
||||
DyeColor color = STRING_TO_ENUM.get(s);
|
||||
if (color != null) {
|
||||
idx = color.getMetadata();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (idx == -1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
ItemStack s = this.rotations.get((idx + 1) % this.rotations.size()).copy();
|
||||
s.setCount(stack.getCount());
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
//package de.ellpeck.actuallyadditions.mod.recipe;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||
//import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger;
|
||||
//import net.minecraft.block.BlockState;
|
||||
//import net.minecraft.item.DyeColor;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraft.util.math.BlockPos;
|
||||
//
|
||||
//import java.util.HashMap;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//public class ColorLensRotator implements IColorLensChanger {
|
||||
//
|
||||
// public static final Map<String, DyeColor> STRING_TO_ENUM = new HashMap<>();
|
||||
//
|
||||
// static {
|
||||
// String[] dyes = {"White", "Orange", "Magenta", "LightBlue", "Yellow", "Lime", "Pink", "Gray", "LightGray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black"};
|
||||
// for (int i = 0; i < dyes.length; i++) {
|
||||
// STRING_TO_ENUM.put("dye" + dyes[i], DyeColor.byMetadata(i));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// final List<ItemStack> rotations;
|
||||
//
|
||||
// public ColorLensRotator(List<ItemStack> rotations) {
|
||||
// this.rotations = rotations;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ItemStack modifyItem(ItemStack stack, BlockState hitBlockState, BlockPos hitBlock, IAtomicReconstructor tile) {
|
||||
//
|
||||
// int idx = -1;
|
||||
//
|
||||
// for (int i : OreDictionary.getOreIDs(stack)) {
|
||||
// String s = OreDictionary.getOreName(i);
|
||||
// if (s.startsWith("dye")) {
|
||||
// DyeColor color = STRING_TO_ENUM.get(s);
|
||||
// if (color != null) {
|
||||
// idx = color.getMetadata();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (idx == -1) {
|
||||
// return ItemStack.EMPTY;
|
||||
// }
|
||||
//
|
||||
// ItemStack s = this.rotations.get((idx + 1) % this.rotations.size()).copy();
|
||||
// s.setCount(stack.getCount());
|
||||
// return s;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
Loading…
Reference in a new issue