feat: hmm, more porting

This commit is contained in:
Michael Hillcox 2021-11-13 19:09:55 +00:00
parent 05d64c1539
commit d922cbdc9e
15 changed files with 712 additions and 712 deletions

View file

@ -19,7 +19,6 @@ import net.minecraft.tags.ItemTags;
import net.minecraft.util.IItemProvider; import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.Tags; import net.minecraftforge.common.Tags;
import sun.plugin.dom.exception.InvalidStateException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
@ -114,10 +113,10 @@ public class EmpoweringRecipeGenerator extends RecipeProvider {
public static class EmpoweringBuilder { public static class EmpoweringBuilder {
private final Item result; private final Item result;
private final Ingredient base; private final Ingredient base;
private List<Ingredient> modifiers = new ArrayList<>();
private final int energy; private final int energy;
private final int time; private final int time;
private final int color; private final int color;
private final List<Ingredient> modifiers = new ArrayList<>();
public EmpoweringBuilder(IItemProvider resultIn, Ingredient baseIn, int energyIn, int timeIn, int colorIn) { public EmpoweringBuilder(IItemProvider resultIn, Ingredient baseIn, int energyIn, int timeIn, int colorIn) {
result = resultIn.asItem(); result = resultIn.asItem();
@ -137,12 +136,14 @@ public class EmpoweringRecipeGenerator extends RecipeProvider {
modifiers.add(Ingredient.of(input)); modifiers.add(Ingredient.of(input));
return this; return this;
} }
public EmpoweringBuilder addModifier(ItemStack input) { public EmpoweringBuilder addModifier(ItemStack input) {
if (modifiers.size() >= 4) if (modifiers.size() >= 4)
throw new InvalidStateException("too many modifiers for empowering recipe, input: " + input.getItem().getRegistryName()); throw new InvalidStateException("too many modifiers for empowering recipe, input: " + input.getItem().getRegistryName());
modifiers.add(Ingredient.of(input)); modifiers.add(Ingredient.of(input));
return this; return this;
} }
public EmpoweringBuilder addModifier(ITag<Item> input) { public EmpoweringBuilder addModifier(ITag<Item> input) {
if (modifiers.size() >= 4) if (modifiers.size() >= 4)
throw new InvalidStateException("too many modifiers for empowering recipe, input: " + input.toString()); 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()); 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)); 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) { public void save(Consumer<IFinishedRecipe> consumer, String name) {
ResourceLocation res = new ResourceLocation(ActuallyAdditions.MODID, "empowering/" + name); ResourceLocation res = new ResourceLocation(ActuallyAdditions.MODID, "empowering/" + name);
if (modifiers.size() != 4) 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)); consumer.accept(new EmpowererRecipe.FinishedRecipe(res, result, base, modifiers.get(0), modifiers.get(1), modifiers.get(2), modifiers.get(3), energy, time, color));
} }
} }

View file

@ -12,11 +12,11 @@ package de.ellpeck.actuallyadditions.mod;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; 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.ActuallyRecipes;
import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting; import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting;
import de.ellpeck.actuallyadditions.mod.crafting.TargetNBTIngredient; import de.ellpeck.actuallyadditions.mod.crafting.TargetNBTIngredient;
import de.ellpeck.actuallyadditions.mod.data.WorldData; 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.entity.InitEntities;
import de.ellpeck.actuallyadditions.mod.event.CommonEvents; import de.ellpeck.actuallyadditions.mod.event.CommonEvents;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; 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.recipe.HairyBallHandler;
import de.ellpeck.actuallyadditions.mod.update.UpdateChecker; import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
import de.ellpeck.actuallyadditions.mod.util.ResourceReloader; 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.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.event.AddReloadListenerEvent; import net.minecraftforge.event.AddReloadListenerEvent;
import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.server.FMLServerStartedEvent; import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppedEvent; import net.minecraftforge.fml.event.server.FMLServerStoppedEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; 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.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -71,6 +76,10 @@ public class ActuallyAdditions {
} }
}; };
public static final Logger LOGGER = LogManager.getLogger(NAME); 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 @Deprecated
public static ActuallyAdditions INSTANCE; public static ActuallyAdditions INSTANCE;
@ -87,6 +96,7 @@ public class ActuallyAdditions {
ActuallyBlocks.TILES.register(eventBus); ActuallyBlocks.TILES.register(eventBus);
ActuallyRecipes.init(eventBus); ActuallyRecipes.init(eventBus);
ActuallyContainers.CONTAINERS.register(eventBus); ActuallyContainers.CONTAINERS.register(eventBus);
ENTITIES.register(eventBus);
MinecraftForge.EVENT_BUS.addListener(this::serverStarted); MinecraftForge.EVENT_BUS.addListener(this::serverStarted);
MinecraftForge.EVENT_BUS.addListener(this::serverStopped); MinecraftForge.EVENT_BUS.addListener(this::serverStopped);
@ -99,6 +109,10 @@ public class ActuallyAdditions {
eventBus.addListener(this::clientSetup); eventBus.addListener(this::clientSetup);
} }
private static void reloadEvent(AddReloadListenerEvent event) {
event.addListener(new ResourceReloader(event.getDataPackRegistries()));
}
private void setup(FMLCommonSetupEvent event) { private void setup(FMLCommonSetupEvent event) {
PacketHandler.init(); PacketHandler.init();
@ -119,11 +133,6 @@ public class ActuallyAdditions {
HairyBallHandler.init(); HairyBallHandler.init();
LensRecipeHandler.init(); LensRecipeHandler.init();
LensMining.init(); LensMining.init();
InitBooklet.init();
}
private static void reloadEvent(AddReloadListenerEvent event){
event.addListener(new ResourceReloader(event.getDataPackRegistries()));
} }
private void clientSetup(FMLClientSetupEvent event) { private void clientSetup(FMLClientSetupEvent event) {

View file

@ -10,57 +10,48 @@
package de.ellpeck.actuallyadditions.mod.config; 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.Item;
import net.minecraft.item.Items;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.config.Configuration;
public final class ConfigValues { public final class ConfigValues {
//
public static Item itemRedstoneTorchConfigurator; public static Item itemRedstoneTorchConfigurator;
public static Item itemCompassConfigurator; public static Item itemCompassConfigurator;
//
public static void defineConfigValues(Configuration config) { // public static void defineConfigValues(Configuration config) {
for (ConfigIntValues currConf : ConfigIntValues.values()) { // for (ConfigIntValues currConf : ConfigIntValues.values()) {
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc, currConf.min, currConf.max).getInt(); // currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc, currConf.min, currConf.max).getInt();
} // }
//
for (ConfigBoolValues currConf : ConfigBoolValues.values()) { // for (ConfigBoolValues currConf : ConfigBoolValues.values()) {
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getBoolean(); // currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getBoolean();
} // }
//
for (ConfigIntListValues currConf : ConfigIntListValues.values()) { // for (ConfigIntListValues currConf : ConfigIntListValues.values()) {
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getIntList(); // currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getIntList();
} // }
//
for (ConfigStringListValues currConf : ConfigStringListValues.values()) { // for (ConfigStringListValues currConf : ConfigStringListValues.values()) {
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getStringList(); // currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getStringList();
} // }
//
parseConfiguratorConfig(); // parseConfiguratorConfig();
} // }
//
private static void parseConfiguratorConfig() { // private static void parseConfiguratorConfig() {
itemRedstoneTorchConfigurator = null; // itemRedstoneTorchConfigurator = null;
itemCompassConfigurator = null; // itemCompassConfigurator = null;
//
String[] conf = ConfigStringListValues.CONFIGURE_ITEMS.getValue(); // String[] conf = ConfigStringListValues.CONFIGURE_ITEMS.getValue();
if (conf.length == 2) { // if (conf.length == 2) {
itemRedstoneTorchConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[0])); // itemRedstoneTorchConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[0]));
itemCompassConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[1])); // itemCompassConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[1]));
} // }
//
if (itemRedstoneTorchConfigurator == null || itemCompassConfigurator == null) { // if (itemRedstoneTorchConfigurator == null || itemCompassConfigurator == null) {
ActuallyAdditions.LOGGER.error("Parsing the Configuration Items config failed, reverting back to the default settings!"); // ActuallyAdditions.LOGGER.error("Parsing the Configuration Items config failed, reverting back to the default settings!");
//
itemRedstoneTorchConfigurator = Item.byBlock(Blocks.REDSTONE_TORCH); // itemRedstoneTorchConfigurator = Item.byBlock(Blocks.REDSTONE_TORCH);
itemCompassConfigurator = Items.COMPASS; // itemCompassConfigurator = Items.COMPASS;
} // }
} // }
} }

View file

@ -10,39 +10,33 @@
package de.ellpeck.actuallyadditions.mod.config; 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 class ConfigurationHandler {
//
public static Configuration config; // public static Configuration config;
//
public ConfigurationHandler(File configFile) { // public ConfigurationHandler(File configFile) {
ActuallyAdditions.LOGGER.info("Grabbing Configurations..."); // ActuallyAdditions.LOGGER.info("Grabbing Configurations...");
//
MinecraftForge.EVENT_BUS.register(this); // MinecraftForge.EVENT_BUS.register(this);
//
config = new Configuration(configFile); // config = new Configuration(configFile);
config.load(); // config.load();
//
redefineConfigs(); // redefineConfigs();
} // }
//
public static void redefineConfigs() { // public static void redefineConfigs() {
ConfigValues.defineConfigValues(config); // ConfigValues.defineConfigValues(config);
//
if (config.hasChanged()) { // if (config.hasChanged()) {
config.save(); // config.save();
} // }
} // }
//
@SubscribeEvent // @SubscribeEvent
public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) { // public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.getModID().equalsIgnoreCase(ActuallyAdditions.MODID)) { // if (event.getModID().equalsIgnoreCase(ActuallyAdditions.MODID)) {
redefineConfigs(); // redefineConfigs();
} // }
} // }
} }

View file

@ -11,14 +11,10 @@
package de.ellpeck.actuallyadditions.mod.data; package de.ellpeck.actuallyadditions.mod.data;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; 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.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.StringNBT; import net.minecraft.nbt.StringNBT;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -59,8 +55,8 @@ public final class PlayerData {
public IBookletPage[] bookmarks = new IBookletPage[12]; public IBookletPage[] bookmarks = new IBookletPage[12];
public List<String> completedTrials = new ArrayList<>(); public List<String> completedTrials = new ArrayList<>();
@OnlyIn(Dist.CLIENT) // @OnlyIn(Dist.CLIENT)
public GuiBooklet lastOpenBooklet; // public GuiBooklet lastOpenBooklet;
public PlayerSave(UUID id) { public PlayerSave(UUID id) {
this.id = id; this.id = id;
@ -113,8 +109,8 @@ public final class PlayerData {
for (int i = 0; i < bookmarks.size(); i++) { for (int i = 0; i < bookmarks.size(); i++) {
String strg = bookmarks.getString(i); String strg = bookmarks.getString(i);
if (!strg.isEmpty()) { if (!strg.isEmpty()) {
IBookletPage page = BookletUtils.getBookletPageById(strg); // IBookletPage page = BookletUtils.getBookletPageById(strg);
this.bookmarks[i] = page; this.bookmarks[i] = null; // page;
} else { } else {
this.bookmarks[i] = null; this.bookmarks[i] = null;
} }

View file

@ -12,85 +12,71 @@ package de.ellpeck.actuallyadditions.mod.entity;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.DefaultFarmerBehavior; import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.DefaultFarmerBehavior;
import net.minecraft.block.Block; import net.minecraft.block.*;
import net.minecraft.block.BlockState;
import net.minecraft.block.IGrowable;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.IPacket;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.IPlantable;
public class EntityWorm extends Entity { public class EntityWorm extends Entity {
public int timer; public int timer;
public EntityWorm(World world) { public EntityWorm(EntityType<?> type, World world) {
super(world); super(type, world);
this.setEntityBoundingBox(new AxisAlignedBB(0, 0, 0, 0, 0, 0)); this.setBoundingBox(new AxisAlignedBB(0, 0, 0, 0, 0, 0));
} }
public static boolean canWormify(World world, BlockPos pos, BlockState state) { public static boolean canWormify(World world, BlockPos pos, BlockState state) {
Block block = state.getBlock(); 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) { if (rightBlock) {
BlockPos posUp = pos.above(); BlockPos posUp = pos.above();
BlockState stateUp = world.getBlockState(posUp); BlockState stateUp = world.getBlockState(posUp);
Block blockUp = stateUp.getBlock(); 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 { } else {
return false; return false;
} }
} }
@Override @Override
protected void entityInit() { public boolean canUpdate() {
return true;
} }
@Override @Override
protected void readEntityFromNBT(CompoundNBT compound) { public void tick() {
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() {
if (!this.level.isClientSide) { if (!this.level.isClientSide) {
this.timer++; this.timer++;
if (this.timer % 50 == 0) { if (this.timer % 50 == 0) {
for (int x = -1; x <= 1; x++) { for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) { 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); BlockState state = this.level.getBlockState(pos);
Block block = state.getBlock(); Block block = state.getBlock();
boolean isMiddlePose = x == 0 && z == 0; boolean isMiddlePose = x == 0 && z == 0;
if (canWormify(this.level, pos, state)) { 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 (isMiddlePose || this.level.random.nextFloat() >= 0.45F) {
if (!isFarmland) { if (!isFarmland) {
DefaultFarmerBehavior.useHoeAt(this.level, pos); DefaultFarmerBehavior.useHoeAt(this.level, pos);
} }
state = this.level.getBlockState(pos); state = this.level.getBlockState(pos);
isFarmland = state.getBlock() instanceof BlockFarmland; isFarmland = state.getBlock() instanceof FarmlandBlock;
if (isFarmland) { 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); BlockState plantState = this.level.getBlockState(plant);
Block plantBlock = plantState.getBlock(); Block plantBlock = plantState.getBlock();
if ((plantBlock instanceof IGrowable || plantBlock instanceof IPlantable) && !(plantBlock instanceof BlockGrass)) { if ((plantBlock instanceof IGrowable || plantBlock instanceof IPlantable) && !(plantBlock instanceof GrassBlock)) {
plantBlock.updateTick(this.level, plant, plantState, this.level.random); plantBlock.randomTick(plantState, (ServerWorld) this.level, plant, this.level.random);
BlockState newState = this.level.getBlockState(plant); BlockState newState = this.level.getBlockState(plant);
if (newState != plantState) { 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;
}
} }

View file

@ -10,47 +10,69 @@
package de.ellpeck.actuallyadditions.mod.entity; package de.ellpeck.actuallyadditions.mod.entity;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.matrix.MatrixStack;
import com.sun.prism.TextureMap;
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import net.minecraft.client.Minecraft; 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.item.ItemStack;
import net.minecraft.util.ResourceLocation; 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.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class RenderWorm extends Render<EntityWorm> { public class RenderWorm extends EntityRenderer<EntityWorm> {
private static ItemStack stack = ItemStack.EMPTY; private static ItemStack stack = ItemStack.EMPTY;
public RenderWorm(EntityRendererManager p_i46179_1_) {
super(p_i46179_1_);
}
public static void fixItemStack() { public static void fixItemStack() {
stack = new ItemStack(ActuallyItems.WORM.get()); stack = new ItemStack(ActuallyItems.WORM.get());
} }
protected RenderWorm(RenderManager renderManager) { @Override
super(renderManager); 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 // @Override
protected ResourceLocation getEntityTexture(EntityWorm entity) { // public void doRender(EntityWorm entity, double x, double y, double z, float entityYaw, float partialTicks) {
return TextureMap.LOCATION_BLOCKS_TEXTURE; // 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 @Override
public void doRender(EntityWorm entity, double x, double y, double z, float entityYaw, float partialTicks) { public ResourceLocation getTextureLocation(EntityWorm pEntity) {
GlStateManager.pushMatrix(); return PlayerContainer.BLOCK_ATLAS;
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();
} }
} }

View file

@ -10,26 +10,73 @@
package de.ellpeck.actuallyadditions.mod.inventory; package de.ellpeck.actuallyadditions.mod.inventory;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet; //import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiMainPage; //import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiMainPage;
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; //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.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; 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 { public class GuiHandler {
@Deprecated @Deprecated
public Object getServerGuiElement(int id, PlayerEntity player, World world, int x, int y, int z) { public Object getServerGuiElement(int id, PlayerEntity player, World world, int x, int y, int z) {
TileEntityBase tile = null; TileEntityBase tile = null;
if (GuiTypes.values()[id].checkTileEntity) { // if (GuiTypes.values()[id].checkTileEntity) {
tile = (TileEntityBase) world.getBlockEntity(new BlockPos(x, y, z)); // tile = (TileEntityBase) world.getBlockEntity(new BlockPos(x, y, z));
} // }
switch (GuiTypes.values()[id]) { // switch (GuiTypes.values()[id]) {
// case FEEDER: // case FEEDER:
// return new ContainerFeeder(player.inventory, tile); // return new ContainerFeeder(player.inventory, tile);
// case GIANT_CHEST: // case GIANT_CHEST:
@ -100,153 +147,106 @@ public class GuiHandler {
// return new ContainerFarmer(player.inventory, tile); // return new ContainerFarmer(player.inventory, tile);
// case FIREWORK_BOX: // case FIREWORK_BOX:
// return new ContainerFireworkBox(); // return new ContainerFireworkBox();
default: // default:
// return null;
// }
return null; return null;
} }
}
@Deprecated @Deprecated
public Object getClientGuiElement(int id, PlayerEntity player, World world, int x, int y, int z) { public Object getClientGuiElement(int id, PlayerEntity player, World world, int x, int y, int z) {
TileEntityBase tile = null; // TileEntityBase tile = null;
if (GuiTypes.values()[id].checkTileEntity) { // if (GuiTypes.values()[id].checkTileEntity) {
tile = (TileEntityBase) world.getBlockEntity(new BlockPos(x, y, z)); // tile = (TileEntityBase) world.getBlockEntity(new BlockPos(x, y, z));
} // }
switch (GuiTypes.values()[id]) { // switch (GuiTypes.values()[id]) {
case FEEDER: // case FEEDER:
return new GuiFeeder(player.inventory, tile); // return new GuiFeeder(player.inventory, tile);
case GIANT_CHEST: // case GIANT_CHEST:
return new GuiGiantChest(player.inventory, tile, 0); // return new GuiGiantChest(player.inventory, tile, 0);
case GIANT_CHEST_PAGE_2: // case GIANT_CHEST_PAGE_2:
return new GuiGiantChest(player.inventory, tile, 1); // return new GuiGiantChest(player.inventory, tile, 1);
case GIANT_CHEST_PAGE_3: // case GIANT_CHEST_PAGE_3:
return new GuiGiantChest(player.inventory, tile, 2); // return new GuiGiantChest(player.inventory, tile, 2);
case CRAFTER: // case CRAFTER:
return CompatUtil.getCrafterGuiElement(player, world, x, y, z); // return CompatUtil.getCrafterGuiElement(player, world, x, y, z);
case GRINDER: // case GRINDER:
return new GuiGrinder(player.inventory, tile); // return new GuiGrinder(player.inventory, tile);
case GRINDER_DOUBLE: // case GRINDER_DOUBLE:
return new GuiGrinder.GuiGrinderDouble(player.inventory, tile); // return new GuiGrinder.GuiGrinderDouble(player.inventory, tile);
case FURNACE_DOUBLE: // case FURNACE_DOUBLE:
return new GuiFurnaceDouble(player.inventory, tile); // return new GuiFurnaceDouble(player.inventory, tile);
case INPUTTER: // case INPUTTER:
return new GuiInputter(player.inventory, tile, false); // return new GuiInputter(player.inventory, tile, false);
case INPUTTER_ADVANCED: // case INPUTTER_ADVANCED:
return new GuiInputter(player.inventory, tile, true); // return new GuiInputter(player.inventory, tile, true);
case REPAIRER: // case REPAIRER:
return new GuiRepairer(player.inventory, tile); // return new GuiRepairer(player.inventory, tile);
// case BREAKER: // // case BREAKER:
// return new GuiBreaker(player.inventory, tile); // // return new GuiBreaker(player.inventory, tile);
case DROPPER: // case DROPPER:
return new GuiDropper(player, tile); // return new GuiDropper(player, tile);
case CANOLA_PRESS: // case CANOLA_PRESS:
return new GuiCanolaPress(player.inventory, tile); // return new GuiCanolaPress(player.inventory, tile);
case FERMENTING_BARREL: // case FERMENTING_BARREL:
return new GuiFermentingBarrel(player.inventory, tile); // return new GuiFermentingBarrel(player.inventory, tile);
case COAL_GENERATOR: // case COAL_GENERATOR:
return new GuiCoalGenerator(player.inventory, tile); // return new GuiCoalGenerator(player.inventory, tile);
case OIL_GENERATOR: // case OIL_GENERATOR:
return new GuiOilGenerator(player.inventory, tile); // return new GuiOilGenerator(player.inventory, tile);
case PHANTOM_PLACER: // case PHANTOM_PLACER:
return new GuiPhantomPlacer(player.inventory, tile); // return new GuiPhantomPlacer(player.inventory, tile);
case FLUID_COLLECTOR: // case FLUID_COLLECTOR:
return new GuiFluidCollector(player.inventory, tile); // return new GuiFluidCollector(player.inventory, tile);
case COFFEE_MACHINE: // case COFFEE_MACHINE:
return new GuiCoffeeMachine(player.inventory, tile); // return new GuiCoffeeMachine(player.inventory, tile);
case DRILL: // case DRILL:
return new GuiDrill(player.inventory); // return new GuiDrill(player.inventory);
case FILTER: // case FILTER:
return new GuiFilter(player.inventory); // return new GuiFilter(player.inventory);
case ENERGIZER: // case ENERGIZER:
return new GuiEnergizer(player, tile); // return new GuiEnergizer(player, tile);
case ENERVATOR: // case ENERVATOR:
return new GuiEnervator(player, tile); // return new GuiEnervator(player, tile);
case XP_SOLIDIFIER: // case XP_SOLIDIFIER:
return new GuiXPSolidifier(player.inventory, tile); // return new GuiXPSolidifier(player.inventory, tile);
case CLOUD: // case CLOUD:
return new GuiSmileyCloud(tile, x, y, z, world); // return new GuiSmileyCloud(tile, x, y, z, world);
case BOOK: // case BOOK:
if (ItemBooklet.forcedPage != null) { // if (ItemBooklet.forcedPage != null) {
GuiBooklet gui = BookletUtils.createBookletGuiFromPage(null, ItemBooklet.forcedPage); // GuiBooklet gui = BookletUtils.createBookletGuiFromPage(null, ItemBooklet.forcedPage);
ItemBooklet.forcedPage = null; // ItemBooklet.forcedPage = null;
return gui; // return gui;
} else { // } else {
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player); // PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
if (data.lastOpenBooklet != null) { // if (data.lastOpenBooklet != null) {
return data.lastOpenBooklet; // return data.lastOpenBooklet;
} else { // } else {
return new GuiMainPage(null); // return new GuiMainPage(null);
} // }
} // }
case DIRECTIONAL_BREAKER: // case DIRECTIONAL_BREAKER:
return new GuiDirectionalBreaker(player.inventory, tile); // return new GuiDirectionalBreaker(player.inventory, tile);
case RANGED_COLLECTOR: // case RANGED_COLLECTOR:
return new GuiRangedCollector(player.inventory, tile); // return new GuiRangedCollector(player.inventory, tile);
case MINER: // case MINER:
return new GuiMiner(player.inventory, tile); // return new GuiMiner(player.inventory, tile);
case LASER_RELAY_ITEM_WHITELIST: // case LASER_RELAY_ITEM_WHITELIST:
return new GuiLaserRelayItemWhitelist(player.inventory, tile); // return new GuiLaserRelayItemWhitelist(player.inventory, tile);
// case BAG: // // case BAG:
// return new GuiBag(player.getHeldItemMainhand(), player.inventory, false); // // return new GuiBag(player.getHeldItemMainhand(), player.inventory, false);
// case VOID_BAG: // // case VOID_BAG:
// return new GuiBag(player.getHeldItemMainhand(), player.inventory, true); // // return new GuiBag(player.getHeldItemMainhand(), player.inventory, true);
case BIO_REACTOR: // case BIO_REACTOR:
return new GuiBioReactor(player.inventory, tile); // return new GuiBioReactor(player.inventory, tile);
case FARMER: // case FARMER:
return new GuiFarmer(player.inventory, tile); // return new GuiFarmer(player.inventory, tile);
case FIREWORK_BOX: // case FIREWORK_BOX:
return new GuiFireworkBox(tile); // return new GuiFireworkBox(tile);
default: // default:
// return null;
return null; 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;
}
}
} }

View file

@ -14,14 +14,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay; 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.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.MainWindow;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
@ -53,30 +46,30 @@ public class ItemBooklet extends ItemBase implements IHudDisplay {
@Override @Override
public ActionResultType useOn(ItemUseContext context) { public ActionResultType useOn(ItemUseContext context) {
if (context.getPlayer().isShiftKeyDown()) { // if (context.getPlayer().isShiftKeyDown()) {
BlockState state = context.getLevel().getBlockState(context.getClickedPos()); // BlockState state = context.getLevel().getBlockState(context.getClickedPos());
Block block = state.getBlock(); // Block block = state.getBlock();
ItemStack blockStack = new ItemStack(block); // ItemStack blockStack = new ItemStack(block);
IBookletPage page = BookletUtils.findFirstPageForStack(blockStack); // IBookletPage page = BookletUtils.findFirstPageForStack(blockStack);
if (page != null) { // if (page != null) {
if (context.getLevel().isClientSide) { // if (context.getLevel().isClientSide) {
forcedPage = page; // forcedPage = page;
} // }
this.use(context.getLevel(), context.getPlayer(), context.getHand()); // this.use(context.getLevel(), context.getPlayer(), context.getHand());
return ActionResultType.SUCCESS; // return ActionResultType.SUCCESS;
} // }
} // }
return ActionResultType.FAIL; return ActionResultType.FAIL;
} }
@Override @Override
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) { 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); // player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BOOK.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ);
//
if (!world.isClientSide) { // if (!world.isClientSide) {
//TheAchievements.OPEN_BOOKLET.get(player); // //TheAchievements.OPEN_BOOKLET.get(player);
//TheAchievements.OPEN_BOOKLET_MILESTONE.get(player); // //TheAchievements.OPEN_BOOKLET_MILESTONE.get(player);
} // }
return ActionResult.success(player.getItemInHand(hand)); return ActionResult.success(player.getItemInHand(hand));
} }
@ -97,36 +90,36 @@ public class ItemBooklet extends ItemBase implements IHudDisplay {
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void displayHud(MatrixStack matrices, Minecraft minecraft, PlayerEntity player, ItemStack stack, RayTraceResult rayCast, MainWindow resolution) { public void displayHud(MatrixStack matrices, Minecraft minecraft, PlayerEntity player, ItemStack stack, RayTraceResult rayCast, MainWindow resolution) {
if (rayCast != null && rayCast.getBlockPos() != null) { // if (rayCast != null && rayCast.getBlockPos() != null) {
BlockState state = minecraft.level.getBlockState(rayCast.getBlockPos()); // BlockState state = minecraft.level.getBlockState(rayCast.getBlockPos());
Block block = state.getBlock(); // Block block = state.getBlock();
if (block != null && !block.isAir(minecraft.level.getBlockState(rayCast.getBlockPos()), minecraft.level, rayCast.getBlockPos())) { // if (block != null && !block.isAir(minecraft.level.getBlockState(rayCast.getBlockPos()), minecraft.level, rayCast.getBlockPos())) {
ItemStack blockStack = new ItemStack(block, 1, block.getMetaFromState(state)); // ItemStack blockStack = new ItemStack(block, 1, block.getMetaFromState(state));
int height = resolution.getGuiScaledHeight() / 5 * 3; // int height = resolution.getGuiScaledHeight() / 5 * 3;
if (player.isShiftKeyDown()) { // if (player.isShiftKeyDown()) {
IBookletPage page = BookletUtils.findFirstPageForStack(blockStack); // IBookletPage page = BookletUtils.findFirstPageForStack(blockStack);
if (page != null) { // if (page != null) {
String strg1 = page.getChapter().getLocalizedName(); // String strg1 = page.getChapter().getLocalizedName();
String strg2 = StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.page") + " " + (page.getChapter().getPageIndex(page) + 1); // 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"); // String strg3 = StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.open");
//
AssetUtil.renderStackToGui(StackUtil.isValid(page.getChapter().getDisplayItemStack()) // AssetUtil.renderStackToGui(StackUtil.isValid(page.getChapter().getDisplayItemStack())
? page.getChapter().getDisplayItemStack() // ? page.getChapter().getDisplayItemStack()
: new ItemStack(ActuallyItems.ITEM_BOOKLET.get()), resolution.getGuiScaledWidth() / 2 - 10, height + 41, 1F); // : 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 + 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.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); // minecraft.font.drawShadow(TextFormatting.GOLD + strg3, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg3) / 2, height + 60, StringUtil.DECIMAL_COLOR_WHITE);
} else { // } else {
String strg1 = TextFormatting.DARK_RED + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.noInfo"); // 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 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"); // 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(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(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); // minecraft.font.drawShadow(strg3, resolution.getGuiScaledWidth() / 2 - minecraft.font.width(strg3) / 2, height + 60, StringUtil.DECIMAL_COLOR_WHITE);
} // }
} // }
} // }
} // }
} }
} }

View file

@ -1,82 +1,82 @@
/* ///*
* This file ("ItemCrystalShard.java") is part of the Actually Additions mod for Minecraft. // * This file ("ItemCrystalShard.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed // * It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at // * under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense // * http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions // * View the source code at https://github.com/Ellpeck/ActuallyAdditions
* // *
* © 2015-2017 Ellpeck // * © 2015-2017 Ellpeck
*/ // */
//
package de.ellpeck.actuallyadditions.mod.items; //package de.ellpeck.actuallyadditions.mod.items;
//
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; //import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.BlockCrystal; //import de.ellpeck.actuallyadditions.mod.blocks.BlockCrystal;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; //import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; //import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; //import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.renderer.color.IItemColor; //import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.creativetab.CreativeTabs; //import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumRarity; //import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; //import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList; //import net.minecraft.util.NonNullList;
import net.minecraftforge.common.IRarity; //import net.minecraftforge.common.IRarity;
//
//
public class ItemCrystalShard extends ItemBase implements IColorProvidingItem { //public class ItemCrystalShard extends ItemBase implements IColorProvidingItem {
//
public ItemCrystalShard() { // public ItemCrystalShard() {
super(name); // super(name);
this.setHasSubtypes(true); // this.setHasSubtypes(true);
this.setMaxDamage(0); // this.setMaxDamage(0);
} // }
//
@Override // @Override
public int getMetadata(int damage) { // public int getMetadata(int damage) {
return damage; // return damage;
} // }
//
@Override // @Override
public String getDescriptionId(ItemStack stack) { // public String getDescriptionId(ItemStack stack) {
return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length // return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length
? StringUtil.BUGGED_ITEM_NAME // ? StringUtil.BUGGED_ITEM_NAME
: this.getDescriptionId() + "_" + BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].name; // : this.getDescriptionId() + "_" + BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].name;
} // }
//
@Override // @Override
public IRarity getForgeRarity(ItemStack stack) { // public IRarity getForgeRarity(ItemStack stack) {
return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length // return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length
? EnumRarity.COMMON // ? EnumRarity.COMMON
: BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].rarity; // : BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].rarity;
} // }
//
@Override // @Override
@OnlyIn(Dist.CLIENT) // @OnlyIn(Dist.CLIENT)
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) { // public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) {
if (this.isInCreativeTab(tab)) { // if (this.isInCreativeTab(tab)) {
for (int j = 0; j < BlockCrystal.ALL_CRYSTALS.length; j++) { // for (int j = 0; j < BlockCrystal.ALL_CRYSTALS.length; j++) {
list.add(new ItemStack(this, 1, j)); // list.add(new ItemStack(this, 1, j));
} // }
} // }
} // }
//
@Override // @Override
protected void registerRendering() { // protected void registerRendering() {
for (int i = 0; i < BlockCrystal.ALL_CRYSTALS.length; i++) { // for (int i = 0; i < BlockCrystal.ALL_CRYSTALS.length; i++) {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), "inventory"); // ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), "inventory");
} // }
} // }
//
@Override // @Override
@OnlyIn(Dist.CLIENT) // @OnlyIn(Dist.CLIENT)
public IItemColor getItemColor() { // public IItemColor getItemColor() {
return (stack, tintIndex) -> { // return (stack, tintIndex) -> {
int damage = stack.getItemDamage(); // int damage = stack.getItemDamage();
if (damage >= 0 && damage < BlockCrystal.ALL_CRYSTALS.length) { // if (damage >= 0 && damage < BlockCrystal.ALL_CRYSTALS.length) {
return BlockCrystal.ALL_CRYSTALS[damage].clusterColor; // return BlockCrystal.ALL_CRYSTALS[damage].clusterColor;
} else { // } else {
return 0; // return 0;
} // }
}; // };
} // }
} //}

View file

@ -14,7 +14,6 @@ import com.google.common.collect.Multimap;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerDrill; 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.items.base.ItemEnergy;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; 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.Blocks;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.enchantment.Enchantments; import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.attributes.Attribute; import net.minecraft.entity.ai.attributes.Attribute;
import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.Attributes; import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.inventory.container.SimpleNamedContainerProvider;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext; import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
@ -38,18 +39,14 @@ import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World; 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.ForgeHooks;
import net.minecraftforge.common.ToolType; import net.minecraftforge.common.ToolType;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class ItemDrill extends ItemEnergy { public class ItemDrill extends ItemEnergy {
@ -57,10 +54,7 @@ public class ItemDrill extends ItemEnergy {
private static final int ENERGY_USE = 100; private static final int ENERGY_USE = 100;
public ItemDrill() { public ItemDrill() {
super(ActuallyItems.defaultProps().defaultDurability(0).stacksTo(1), 250000, 1000); super(ActuallyItems.defaultProps().defaultDurability(0).stacksTo(1).addToolType(ToolType.SHOVEL, HARVEST_LEVEL).addToolType(ToolType.PICKAXE, HARVEST_LEVEL), 250000, 1000);
this.setHasSubtypes(true);
this.setHarvestLevel("shovel", HARVEST_LEVEL);
this.setHarvestLevel("pickaxe", HARVEST_LEVEL);
} }
/** /**
@ -153,25 +147,21 @@ public class ItemDrill extends ItemEnergy {
@Override @Override
public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) { public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
if (!world.isClientSide && player.isShiftKeyDown() && hand == Hand.MAIN_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)); return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand));
} }
@Override @Override
public int getMetadata(int damage) { public ActionResultType interactLivingEntity(ItemStack stack, PlayerEntity player, LivingEntity entityHit, Hand hand) {
return damage;
}
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase entity1, EntityLivingBase entity2) {
int use = this.getEnergyUsePerBlock(stack); int use = this.getEnergyUsePerBlock(stack);
if (!(entity2 instanceof PlayerEntity) || !((PlayerEntity) entity2).isCreative()) { if (!(entityHit instanceof PlayerEntity) || !((PlayerEntity) entityHit).isCreative()) {
if (this.getEnergyStored(stack) >= use) { if (this.getEnergyStored(stack) >= use) {
this.extractEnergyInternal(stack, use, false); this.extractEnergyInternal(stack, use, false);
} }
} }
return true; return ActionResultType.SUCCESS;
} }
@Override @Override
@ -192,7 +182,7 @@ public class ItemDrill extends ItemEnergy {
@Override @Override
public float getDestroySpeed(ItemStack stack, BlockState state) { public float getDestroySpeed(ItemStack stack, BlockState state) {
return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) 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) ? this.getEfficiencyFromUpgrade(stack)
: 1.0F : 1.0F
: 0.1F; : 0.1F;
@ -240,7 +230,7 @@ public class ItemDrill extends ItemEnergy {
@Override @Override
public boolean canHarvestBlock(ItemStack stack, BlockState state) { public boolean canHarvestBlock(ItemStack stack, BlockState state) {
Block block = state.getBlock(); 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 ? HARVEST_LEVEL >= 3
: block != Blocks.DIAMOND_BLOCK && block != Blocks.DIAMOND_ORE : block != Blocks.DIAMOND_BLOCK && block != Blocks.DIAMOND_ORE
? block != Blocks.EMERALD_ORE && block != Blocks.EMERALD_BLOCK ? block != Blocks.EMERALD_ORE && block != Blocks.EMERALD_BLOCK
@ -257,14 +247,6 @@ public class ItemDrill extends ItemEnergy {
: HARVEST_LEVEL >= 2)); : HARVEST_LEVEL >= 2));
} }
@Override
public Set<String> getToolClasses(ItemStack stack) {
HashSet<String> hashSet = new HashSet<>();
hashSet.add("pickaxe");
hashSet.add("shovel");
return hashSet;
}
@Override @Override
public int getHarvestLevel(ItemStack stack, ToolType p_getHarvestLevel_2_, @Nullable PlayerEntity p_getHarvestLevel_3_, @Nullable BlockState p_getHarvestLevel_4_) { public int getHarvestLevel(ItemStack stack, ToolType p_getHarvestLevel_2_, @Nullable PlayerEntity p_getHarvestLevel_3_, @Nullable BlockState p_getHarvestLevel_4_) {
return HARVEST_LEVEL; return HARVEST_LEVEL;
@ -325,25 +307,25 @@ public class ItemDrill extends ItemEnergy {
return StackUtil.isValid(this.getHasUpgradeAsStack(stack, upgrade)); return StackUtil.isValid(this.getHasUpgradeAsStack(stack, upgrade));
} }
@Override // @Override
@OnlyIn(Dist.CLIENT) // @OnlyIn(Dist.CLIENT)
public void getSubItems(CreativeTabs tabs, NonNullList<ItemStack> list) { // public void getSubItems(CreativeTabs tabs, NonNullList<ItemStack> list) {
if (this.isInCreativeTab(tabs)) { // if (this.isInCreativeTab(tabs)) {
for (int i = 0; i < 16; i++) { // for (int i = 0; i < 16; i++) {
this.addDrillStack(list, i); // this.addDrillStack(list, i);
} // }
} // }
} // }
private void addDrillStack(List<ItemStack> list, int meta) { // private void addDrillStack(List<ItemStack> list, int meta) {
ItemStack stackFull = new ItemStack(this, 1, meta); // ItemStack stackFull = new ItemStack(this, 1, meta);
this.setEnergy(stackFull, this.getMaxEnergyStored(stackFull)); // this.setEnergy(stackFull, this.getMaxEnergyStored(stackFull));
list.add(stackFull); // list.add(stackFull);
//
ItemStack stackEmpty = new ItemStack(this, 1, meta); // ItemStack stackEmpty = new ItemStack(this, 1, meta);
this.setEnergy(stackEmpty, 0); // this.setEnergy(stackEmpty, 0);
list.add(stackEmpty); // list.add(stackEmpty);
} // }
/** /**
* Gets the Mining Speed of the Drill * Gets the Mining Speed of the Drill

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.items; 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.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.entity.EntityWorm; import de.ellpeck.actuallyadditions.mod.entity.EntityWorm;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; 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)); 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 (worms.isEmpty()) {
if (!context.getLevel().isClientSide) { 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.setPos(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
worm.setCustomName(stack.getHoverName()); // TODO: WHAT DOES THIS EVEN DO? worm.setCustomName(stack.getHoverName()); // TODO: WHAT DOES THIS EVEN DO?
context.getLevel().addFreshEntity(worm); context.getLevel().addFreshEntity(worm);

View file

@ -11,12 +11,13 @@
package de.ellpeck.actuallyadditions.mod.items.base; package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.api.misc.IDisableableItem; 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.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block; 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 net.minecraft.tags.ITag;
import java.util.Set; import java.util.Set;
@ -28,23 +29,32 @@ public class ItemToolAA extends ToolItem implements IDisableableItem {
private final ITag<Item> repairTag; private final ITag<Item> repairTag;
private final boolean disabled; private final boolean disabled;
public ItemToolAA(float attack, float speed, IItemTier toolMat, String repairItem, String unlocalizedName, Rarity rarity, Set<Block> 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) {
this(attack, speed, toolMat, ItemStack.EMPTY, unlocalizedName, rarity, effectiveStuff); super(p_i48512_1_, p_i48512_2_, p_i48512_3_, p_i48512_4_, p_i48512_5_);
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);
this.name = name;
this.repairItem = repairItem; this.repairItem = repairItem;
this.name = unlocalizedName; this.repairTag = repairTag;
this.rarity = rarity; this.disabled = false;
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();
}
} }
// 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() { private void register() {
} }

View file

@ -20,12 +20,6 @@ import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
import de.ellpeck.actuallyadditions.mod.blocks.BlockLaserRelay; 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.config.values.ConfigStringListValues;
import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler; import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler;
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry; 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.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance; import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Potion;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -112,7 +106,7 @@ public class MethodHandler implements IMethodHandler {
public void addEffectToStack(ItemStack stack, EffectInstance effect) { public void addEffectToStack(ItemStack stack, EffectInstance effect) {
CompoundNBT tag = stack.getOrCreateTag(); CompoundNBT tag = stack.getOrCreateTag();
int prevCounter = tag.putInt("Counter"); int prevCounter = tag.getInt("Counter");
CompoundNBT compound = new CompoundNBT(); CompoundNBT compound = new CompoundNBT();
//compound.putInt("ID", Potion.getIdFromPotion(effect.getEffect())); //TODO ?! //compound.putInt("ID", Potion.getIdFromPotion(effect.getEffect())); //TODO ?!
compound.putInt("Duration", effect.getDuration()); compound.putInt("Duration", effect.getDuration());
@ -132,7 +126,7 @@ public class MethodHandler implements IMethodHandler {
int counter = tag.getInt("Counter"); int counter = tag.getInt("Counter");
while (counter > 0) { while (counter > 0) {
CompoundNBT compound = (CompoundNBT) tag.get(counter + ""); 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); effects.add(effect);
counter--; counter--;
} }

View file

@ -1,56 +1,56 @@
package de.ellpeck.actuallyadditions.mod.recipe; //package de.ellpeck.actuallyadditions.mod.recipe;
//
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; //import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger; //import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger;
import net.minecraft.block.BlockState; //import net.minecraft.block.BlockState;
import net.minecraft.item.DyeColor; //import net.minecraft.item.DyeColor;
import net.minecraft.item.ItemStack; //import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos; //import net.minecraft.util.math.BlockPos;
//
import java.util.HashMap; //import java.util.HashMap;
import java.util.List; //import java.util.List;
import java.util.Map; //import java.util.Map;
//
public class ColorLensRotator implements IColorLensChanger { //public class ColorLensRotator implements IColorLensChanger {
//
public static final Map<String, DyeColor> STRING_TO_ENUM = new HashMap<>(); // public static final Map<String, DyeColor> STRING_TO_ENUM = new HashMap<>();
//
static { // static {
String[] dyes = {"White", "Orange", "Magenta", "LightBlue", "Yellow", "Lime", "Pink", "Gray", "LightGray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black"}; // 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++) { // for (int i = 0; i < dyes.length; i++) {
STRING_TO_ENUM.put("dye" + dyes[i], DyeColor.byMetadata(i)); // STRING_TO_ENUM.put("dye" + dyes[i], DyeColor.byMetadata(i));
} // }
} // }
//
final List<ItemStack> rotations; // final List<ItemStack> rotations;
//
public ColorLensRotator(List<ItemStack> rotations) { // public ColorLensRotator(List<ItemStack> rotations) {
this.rotations = rotations; // this.rotations = rotations;
} // }
//
@Override // @Override
public ItemStack modifyItem(ItemStack stack, BlockState hitBlockState, BlockPos hitBlock, IAtomicReconstructor tile) { // public ItemStack modifyItem(ItemStack stack, BlockState hitBlockState, BlockPos hitBlock, IAtomicReconstructor tile) {
//
int idx = -1; // int idx = -1;
//
for (int i : OreDictionary.getOreIDs(stack)) { // for (int i : OreDictionary.getOreIDs(stack)) {
String s = OreDictionary.getOreName(i); // String s = OreDictionary.getOreName(i);
if (s.startsWith("dye")) { // if (s.startsWith("dye")) {
DyeColor color = STRING_TO_ENUM.get(s); // DyeColor color = STRING_TO_ENUM.get(s);
if (color != null) { // if (color != null) {
idx = color.getMetadata(); // idx = color.getMetadata();
break; // break;
} // }
} // }
} // }
//
if (idx == -1) { // if (idx == -1) {
return ItemStack.EMPTY; // return ItemStack.EMPTY;
} // }
//
ItemStack s = this.rotations.get((idx + 1) % this.rotations.size()).copy(); // ItemStack s = this.rotations.get((idx + 1) % this.rotations.size()).copy();
s.setCount(stack.getCount()); // s.setCount(stack.getCount());
return s; // return s;
} // }
//
} //}