mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 04:09:40 +00:00
Merge 1.14
This commit is contained in:
commit
42ee5d0d8d
106 files changed
+2230
-1042
No files matched your search
@@ -45,6 +45,10 @@ import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public final class BotaniaAPI {
|
||||
public static int apiVersion() {
|
||||
return 94;
|
||||
}
|
||||
|
||||
@CapabilityInject(IFloatingFlower.class)
|
||||
public static Capability<IFloatingFlower> FLOATING_FLOWER_CAP;
|
||||
|
||||
|
||||
@@ -20,8 +20,11 @@ import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.ModContainer;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
import org.lwjgl.opengl.GL;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
@@ -42,9 +45,11 @@ public final class DebugHandler {
|
||||
World world = Minecraft.getInstance().world;
|
||||
if(ConfigHandler.CLIENT.debugInfo.get() && Minecraft.getInstance().gameSettings.showDebugInfo) {
|
||||
event.getLeft().add("");
|
||||
String version = LibMisc.VERSION;
|
||||
if(version.contains("GRADLE"))
|
||||
version = "N/A";
|
||||
String version = ModList.get().getModContainerById(LibMisc.MOD_ID)
|
||||
.map(ModContainer::getModInfo)
|
||||
.map(IModInfo::getVersion)
|
||||
.map(Object::toString)
|
||||
.orElse("N/A");
|
||||
|
||||
event.getLeft().add(PREFIX + "(CLIENT) netColl: " + ManaNetworkHandler.instance.getAllCollectorsInWorld(world).size() + ", netPool: " + ManaNetworkHandler.instance.getAllPoolsInWorld(world).size() + ", rv: " + version);
|
||||
|
||||
|
||||
@@ -80,32 +80,6 @@ public final class HUDHandler {
|
||||
|
||||
public static final ResourceLocation manaBar = new ResourceLocation(LibResources.GUI_MANA_HUD);
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
public static void onDrawScreenPre(RenderGameOverlayEvent.Pre event) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
IProfiler profiler = mc.getProfiler();
|
||||
|
||||
if(event.getType() == ElementType.HEALTH) {
|
||||
profiler.startSection("botania-hud");
|
||||
|
||||
ItemStack tiara = EquipmentHandler.findOrEmpty(ModItems.flightTiara, mc.player);
|
||||
if(!tiara.isEmpty()) {
|
||||
profiler.startSection("flugelTiara");
|
||||
ItemFlightTiara.renderHUD(mc.player, tiara);
|
||||
profiler.endSection();
|
||||
}
|
||||
|
||||
ItemStack dodgeRing = EquipmentHandler.findOrEmpty(ModItems.dodgeRing, mc.player);
|
||||
if(!dodgeRing.isEmpty()) {
|
||||
profiler.startSection("dodgeRing");
|
||||
ItemDodgeRing.renderHUD(mc.player, dodgeRing, event.getPartialTicks());
|
||||
profiler.endSection();
|
||||
}
|
||||
|
||||
profiler.endSection();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onDrawScreenPost(RenderGameOverlayEvent.Post event) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
@@ -115,6 +89,23 @@ public final class HUDHandler {
|
||||
|
||||
if(event.getType() == ElementType.ALL) {
|
||||
profiler.startSection("botania-hud");
|
||||
|
||||
if (Minecraft.getInstance().playerController.shouldDrawHUD()) {
|
||||
ItemStack tiara = EquipmentHandler.findOrEmpty(ModItems.flightTiara, mc.player);
|
||||
if(!tiara.isEmpty()) {
|
||||
profiler.startSection("flugelTiara");
|
||||
ItemFlightTiara.renderHUD(mc.player, tiara);
|
||||
profiler.endSection();
|
||||
}
|
||||
|
||||
ItemStack dodgeRing = EquipmentHandler.findOrEmpty(ModItems.dodgeRing, mc.player);
|
||||
if(!dodgeRing.isEmpty()) {
|
||||
profiler.startSection("dodgeRing");
|
||||
ItemDodgeRing.renderHUD(mc.player, dodgeRing, event.getPartialTicks());
|
||||
profiler.endSection();
|
||||
}
|
||||
}
|
||||
|
||||
RayTraceResult pos = mc.objectMouseOver;
|
||||
|
||||
if(pos != null) {
|
||||
|
||||
@@ -24,31 +24,16 @@ public final class PersistentVariableHelper {
|
||||
|
||||
private static final String TAG_FIRST_LOAD = "firstLoad";
|
||||
private static final String TAG_DOG = "dog";
|
||||
private static final String TAG_LEXICON_NOTES = "lexiconNotes";
|
||||
private static final String TAG_LAST_BOTANIA_VERSION = "lastBotaniaVersion";
|
||||
|
||||
private static File cacheFile;
|
||||
|
||||
public static boolean firstLoad = true;
|
||||
public static boolean dog = true;
|
||||
public static String lastBotaniaVersion = "";
|
||||
|
||||
public static void save() throws IOException {
|
||||
CompoundNBT cmp = new CompoundNBT();
|
||||
|
||||
/*
|
||||
CompoundNBT notesCmp = new CompoundNBT();
|
||||
for(String s : GuiLexicon.notes.keySet()) {
|
||||
String note = GuiLexicon.notes.get(s);
|
||||
if(note != null && !note.trim().isEmpty())
|
||||
notesCmp.putString(s, note);
|
||||
}
|
||||
cmp.put(TAG_LEXICON_NOTES, notesCmp);
|
||||
*/
|
||||
|
||||
cmp.putBoolean(TAG_FIRST_LOAD, firstLoad);
|
||||
cmp.putBoolean(TAG_DOG, dog);
|
||||
cmp.putString(TAG_LAST_BOTANIA_VERSION, lastBotaniaVersion);
|
||||
|
||||
injectNBTToFile(cmp, getCacheFile());
|
||||
}
|
||||
@@ -56,31 +41,10 @@ public final class PersistentVariableHelper {
|
||||
public static void load() throws IOException {
|
||||
CompoundNBT cmp = getCacheCompound();
|
||||
|
||||
if(cmp.contains(TAG_LEXICON_NOTES)) {
|
||||
CompoundNBT notesCmp = cmp.getCompound(TAG_LEXICON_NOTES);
|
||||
Set<String> keys = notesCmp.keySet();
|
||||
// GuiLexicon.notes.clear();
|
||||
for(String key : keys)
|
||||
;// GuiLexicon.notes.put(key, notesCmp.getString(key));
|
||||
}
|
||||
|
||||
lastBotaniaVersion = cmp.contains(TAG_LAST_BOTANIA_VERSION) ? cmp.getString(TAG_LAST_BOTANIA_VERSION) : "(N/A)";
|
||||
|
||||
firstLoad = cmp.contains(TAG_FIRST_LOAD) ? cmp.getBoolean(TAG_FIRST_LOAD) : firstLoad;
|
||||
if(firstLoad)
|
||||
lastBotaniaVersion = LibMisc.VERSION;
|
||||
|
||||
dog = cmp.getBoolean(TAG_DOG);
|
||||
}
|
||||
|
||||
public static void saveSafe() {
|
||||
try {
|
||||
save();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setCacheFile(File f) {
|
||||
cacheFile = f;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* This class was created by <Hubry>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [2020-01-14, 01:26 (UTC+2)]
|
||||
*/
|
||||
package vazkii.botania.client.core.handler;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.ReloadListener;
|
||||
import net.minecraft.client.util.Splashes;
|
||||
import net.minecraft.profiler.IProfiler;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.resources.SimpleReloadableResourceManager;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = LibMisc.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class SplashHandler {
|
||||
// This is probably the best spot to add a splash listener. It's an event fired after splash reload listener
|
||||
// is registered, but before resource reload happens. Doing the initial load ourselves is not effective,
|
||||
// as we would do it before the splashes are added, and the list is cleared when adding.
|
||||
@SubscribeEvent
|
||||
public static void registerFactories(ParticleFactoryRegisterEvent event) {
|
||||
((SimpleReloadableResourceManager) Minecraft.getInstance().getResourceManager()).addReloadListener(new SplashResourceListener());
|
||||
}
|
||||
|
||||
private static class SplashResourceListener extends ReloadListener<List<String>> {
|
||||
@Override
|
||||
@Nonnull
|
||||
protected List<String> prepare(IResourceManager resourceManagerIn, IProfiler profilerIn) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void apply(List<String> list, IResourceManager resourceManagerIn, IProfiler profilerIn) {
|
||||
if (!ConfigHandler.CLIENT.splashesEnabled.get())
|
||||
return;
|
||||
|
||||
Splashes splashes = Minecraft.getInstance().getSplashes();
|
||||
List<String> splashList = ObfuscationReflectionHelper.getPrivateValue(Splashes.class, splashes, "field_215280_c"); //possibleSplashes
|
||||
splashList.add("Do not feed bread to elves!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -202,19 +202,6 @@ public class ClientProxy implements IProxy {
|
||||
return ItemMonocle.hasMonocle(Minecraft.getInstance().player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLastVersion() {
|
||||
String s = PersistentVariableHelper.lastBotaniaVersion;
|
||||
|
||||
if(s == null)
|
||||
return "N/A";
|
||||
|
||||
if(s.indexOf("-") > 0)
|
||||
return s.split("-")[1];
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getWorldElapsedTicks() {
|
||||
return ClientTickHandler.ticksInGame;
|
||||
|
||||
@@ -53,10 +53,12 @@ import vazkii.botania.common.crafting.recipe.CompositeLensRecipe;
|
||||
import vazkii.botania.common.crafting.recipe.TerraPickTippingRecipe;
|
||||
import vazkii.botania.common.item.ItemLaputaShard;
|
||||
import vazkii.botania.common.item.ItemLexicon;
|
||||
import vazkii.botania.common.item.ItemManaTablet;
|
||||
import vazkii.botania.common.item.ItemTwigWand;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.item.brew.ItemBrewBase;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara;
|
||||
import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -78,8 +80,11 @@ public class JEIBotaniaPlugin implements IModPlugin {
|
||||
registry.registerSubtypeInterpreter(ModItems.flightTiara, stack -> String.valueOf(ItemFlightTiara.getVariant(stack)));
|
||||
registry.registerSubtypeInterpreter(ModItems.lexicon, stack -> String.valueOf(ItemNBTHelper.getBoolean(stack, ItemLexicon.TAG_ELVEN_UNLOCK, false)));
|
||||
registry.registerSubtypeInterpreter(ModItems.laputaShard, stack -> String.valueOf(ItemLaputaShard.getShardLevel(stack)));
|
||||
|
||||
for(Item item : new Item[]{ModItems.manaTablet, ModItems.manaRing, ModItems.manaRingGreater, ModItems.terraPick}) {
|
||||
|
||||
registry.registerSubtypeInterpreter(ModItems.terraPick, stack -> String.valueOf(ItemTerraPick.getLevel(stack)) + ItemTerraPick.isTipped(stack));
|
||||
registry.registerSubtypeInterpreter(ModItems.manaTablet, stack -> String.valueOf(((IManaItem) ModItems.manaTablet).getMana(stack)) + ItemManaTablet.isStackCreative(stack));
|
||||
|
||||
for(Item item : new Item[]{ModItems.manaRing, ModItems.manaRingGreater}) {
|
||||
registry.registerSubtypeInterpreter(item, stack -> String.valueOf(((IManaItem) item).getMana(stack)));
|
||||
}
|
||||
}
|
||||
@@ -181,7 +186,7 @@ public class JEIBotaniaPlugin implements IModPlugin {
|
||||
for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes.values()) {
|
||||
List<Ingredient> inputs = recipe.getInputs();
|
||||
List<ItemStack> outputs = recipe.getOutputs();
|
||||
if(inputs.size() == 1 && outputs.size() == 1 && recipe.containsItem(outputs.get(0))) {
|
||||
if(inputs.size() == 1 && outputs.size() == 1 && recipe.containsItem(outputs.get(0)) && outputs.get(0).getItem() != ModItems.lexicon) {
|
||||
recipeRegistry.hideRecipe(recipe, ElvenTradeRecipeCategory.UID);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-63
@@ -8,38 +8,25 @@
|
||||
*/
|
||||
package vazkii.botania.client.integration.jei.orechid;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.gui.drawable.IDrawableStatic;
|
||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.common.block.ModSubtiles;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Map;
|
||||
|
||||
public class OrechidIgnemRecipeCategory implements IRecipeCategory<OrechidIgnemRecipeWrapper> {
|
||||
public class OrechidIgnemRecipeCategory extends OrechidRecipeCategoryBase<OrechidIgnemRecipeWrapper> {
|
||||
|
||||
public static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "orechid_ignem");
|
||||
private final IDrawableStatic background;
|
||||
private final String localizedName;
|
||||
private final IDrawableStatic overlay;
|
||||
private final IDrawable icon;
|
||||
|
||||
public OrechidIgnemRecipeCategory(IGuiHelper guiHelper) {
|
||||
background = guiHelper.createBlankDrawable(168, 64);
|
||||
localizedName = I18n.format("botania.nei.orechidIgnem");
|
||||
overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pure_daisy_overlay.png"),
|
||||
0, 0, 64, 46);
|
||||
icon = guiHelper.createDrawableIngredient(new ItemStack(ModSubtiles.orechidIgnem));
|
||||
super(guiHelper, new ItemStack(ModSubtiles.orechidIgnem), new ItemStack(Blocks.NETHERRACK, 64),
|
||||
I18n.format("botania.nei.orechidIgnem"));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -54,50 +41,8 @@ public class OrechidIgnemRecipeCategory implements IRecipeCategory<OrechidIgnemR
|
||||
return OrechidIgnemRecipeWrapper.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return localizedName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(OrechidIgnemRecipeWrapper recipe, IIngredients ingredients) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull OrechidIgnemRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
|
||||
final IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
itemStacks.init(0, true, 40, 12);
|
||||
itemStacks.set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0));
|
||||
|
||||
itemStacks.init(1, true, 70, 12);
|
||||
itemStacks.set(1, new ItemStack(ModSubtiles.orechidIgnem));
|
||||
|
||||
itemStacks.init(2, true, 99, 12);
|
||||
itemStacks.set(2, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(OrechidIgnemRecipeWrapper recipe, double mouseX, double mouseY) {
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.enableBlend();
|
||||
overlay.draw(48, 0);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.disableAlphaTest();
|
||||
protected Map<ResourceLocation, Integer> getOreWeights() {
|
||||
return BotaniaAPI.oreWeightsNether;
|
||||
}
|
||||
}
|
||||
+6
-92
@@ -8,47 +8,24 @@
|
||||
*/
|
||||
package vazkii.botania.client.integration.jei.orechid;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.gui.drawable.IDrawableStatic;
|
||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.client.integration.jei.JEIBotaniaPlugin;
|
||||
import vazkii.botania.common.block.ModSubtiles;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class OrechidRecipeCategory implements IRecipeCategory<OrechidRecipeWrapper> {
|
||||
|
||||
public class OrechidRecipeCategory extends OrechidRecipeCategoryBase<OrechidRecipeWrapper> {
|
||||
public static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "orechid");
|
||||
private final IDrawableStatic background;
|
||||
private final String localizedName;
|
||||
private final IDrawableStatic overlay;
|
||||
private final IDrawable icon;
|
||||
|
||||
|
||||
public OrechidRecipeCategory(IGuiHelper guiHelper) {
|
||||
background = guiHelper.createBlankDrawable(168, 64);
|
||||
localizedName = I18n.format("botania.nei.orechid");
|
||||
overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pure_daisy_overlay.png"),
|
||||
0, 0, 64, 46);
|
||||
icon = guiHelper.createDrawableIngredient(new ItemStack(ModSubtiles.orechid));
|
||||
super(guiHelper, new ItemStack(ModSubtiles.orechid), new ItemStack(Blocks.STONE, 64),
|
||||
I18n.format("botania.nei.orechid"));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -63,72 +40,9 @@ public class OrechidRecipeCategory implements IRecipeCategory<OrechidRecipeWrapp
|
||||
return OrechidRecipeWrapper.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return localizedName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(OrechidRecipeWrapper recipe, IIngredients ingredients) {
|
||||
ingredients.setInput(VanillaTypes.ITEM, new ItemStack(Blocks.STONE, 64));
|
||||
|
||||
final int myWeight = recipe.entry.getValue();
|
||||
final int amount = Math.max(1, Math.round((float) myWeight * 64 / getTotalOreWeight(BotaniaAPI.oreWeights, myWeight)));
|
||||
|
||||
// Shouldn't ever return an empty list since the ore weight
|
||||
// list is filtered to only have ores with ItemBlocks
|
||||
List<ItemStack> stackList = BlockTags.getCollection().getOrCreate(recipe.entry.getKey())
|
||||
.getAllElements()
|
||||
.stream()
|
||||
.filter(s -> s.asItem() != Items.AIR)
|
||||
.map(ItemStack::new)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
stackList.forEach(s -> s.setCount(amount));
|
||||
ingredients.setOutputLists(VanillaTypes.ITEM, Collections.singletonList(stackList));
|
||||
}
|
||||
|
||||
public static float getTotalOreWeight(Map<ResourceLocation, Integer> weights, int myWeight) {
|
||||
return (weights.entrySet().stream()
|
||||
.filter(e -> JEIBotaniaPlugin.doesOreExist(e.getKey()))
|
||||
.map(Map.Entry::getValue)
|
||||
.reduce(Integer::sum)).orElse(myWeight * 64 * 64);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull OrechidRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
|
||||
final IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
itemStacks.init(0, true, 40, 12);
|
||||
itemStacks.set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0));
|
||||
|
||||
itemStacks.init(1, true, 70, 12);
|
||||
itemStacks.set(1, new ItemStack(ModSubtiles.orechid));
|
||||
|
||||
itemStacks.init(2, true, 99, 12);
|
||||
itemStacks.set(2, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(OrechidRecipeWrapper recipe, double mouseX, double mouseY) {
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.enableBlend();
|
||||
overlay.draw(48, 0);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.disableAlphaTest();
|
||||
protected Map<ResourceLocation, Integer> getOreWeights() {
|
||||
return BotaniaAPI.oreWeights;
|
||||
}
|
||||
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* This class was created by <codewarrior0>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
* <p/>
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*/
|
||||
package vazkii.botania.client.integration.jei.orechid;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.gui.drawable.IDrawableStatic;
|
||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import vazkii.botania.client.integration.jei.JEIBotaniaPlugin;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class OrechidRecipeCategoryBase<T extends OrechidRecipeWrapper> implements IRecipeCategory<T> {
|
||||
|
||||
private final IDrawableStatic background;
|
||||
private final String localizedName;
|
||||
private final IDrawableStatic overlay;
|
||||
private final IDrawable icon;
|
||||
private final ItemStack iconStack;
|
||||
private final ItemStack inputStack;
|
||||
|
||||
public OrechidRecipeCategoryBase(IGuiHelper guiHelper, ItemStack iconStack, ItemStack inputStack, String localizedName) {
|
||||
overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pure_daisy_overlay.png"),
|
||||
0, 0, 64, 46);
|
||||
background = guiHelper.createBlankDrawable(168, 64);
|
||||
this.localizedName = localizedName;
|
||||
this.icon = guiHelper.createDrawableIngredient(iconStack);
|
||||
this.iconStack = iconStack;
|
||||
this.inputStack = inputStack;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public abstract Class<? extends T> getRecipeClass();
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return localizedName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(T recipe, IIngredients ingredients) {
|
||||
ingredients.setInput(VanillaTypes.ITEM, inputStack);
|
||||
|
||||
final int myWeight = recipe.entry.getValue();
|
||||
final int amount = Math.max(1, Math.round((float) myWeight * 64 / getTotalOreWeight(getOreWeights(), myWeight)));
|
||||
|
||||
// Shouldn't ever return an empty list since the ore weight
|
||||
// list is filtered to only have ores with ItemBlocks
|
||||
List<ItemStack> stackList = BlockTags.getCollection().getOrCreate(recipe.entry.getKey())
|
||||
.getAllElements()
|
||||
.stream()
|
||||
.filter(s -> s.asItem() != Items.AIR)
|
||||
.map(ItemStack::new)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
stackList.forEach(s -> s.setCount(amount));
|
||||
ingredients.setOutputLists(VanillaTypes.ITEM, Collections.singletonList(stackList));
|
||||
}
|
||||
|
||||
public static float getTotalOreWeight(Map<ResourceLocation, Integer> weights, int myWeight) {
|
||||
return (weights.entrySet().stream()
|
||||
.filter(e -> JEIBotaniaPlugin.doesOreExist(e.getKey()))
|
||||
.map(Map.Entry::getValue)
|
||||
.reduce(Integer::sum)).orElse(myWeight * 64 * 64);
|
||||
}
|
||||
|
||||
protected abstract Map<ResourceLocation, Integer> getOreWeights();
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull T recipeWrapper, @Nonnull IIngredients ingredients) {
|
||||
final IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
itemStacks.init(0, true, 40, 12);
|
||||
itemStacks.set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0));
|
||||
|
||||
itemStacks.init(1, true, 70, 12);
|
||||
itemStacks.set(1, iconStack);
|
||||
|
||||
itemStacks.init(2, true, 99, 12);
|
||||
itemStacks.set(2, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(T recipe, double mouseX, double mouseY) {
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.enableBlend();
|
||||
overlay.draw(48, 0);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.disableAlphaTest();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.subtile.functional;
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
@@ -33,8 +34,8 @@ public class SubTileJiyuulia extends SubTileTangleberrie {
|
||||
}
|
||||
|
||||
@Override
|
||||
float getMotionVelocity() {
|
||||
return -super.getMotionVelocity() * 2;
|
||||
float getMotionVelocity(LivingEntity entity) {
|
||||
return -super.getMotionVelocity(entity) * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,6 +35,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class SubTileOrechid extends TileEntityFunctionalFlower {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":orechid")
|
||||
@@ -46,7 +47,6 @@ public class SubTileOrechid extends TileEntityFunctionalFlower {
|
||||
private static final int DELAY_GOG = 2;
|
||||
private static final int RANGE = 5;
|
||||
private static final int RANGE_Y = 3;
|
||||
private static final int TRIES = 20;
|
||||
|
||||
public SubTileOrechid(TileEntityType<?> type) {
|
||||
super(type);
|
||||
@@ -84,23 +84,23 @@ public class SubTileOrechid extends TileEntityFunctionalFlower {
|
||||
@Nullable
|
||||
private BlockState getOreToPut() {
|
||||
Map<ResourceLocation, Integer> map = getOreMap();
|
||||
List<WeightedRandom.Item> values = map.entrySet().stream()
|
||||
.map(e -> new TagRandomItem(e.getValue(), e.getKey()))
|
||||
List<TagRandomItem> values = map.entrySet().stream()
|
||||
.flatMap(e -> {
|
||||
Tag<Block> tag = BlockTags.getCollection().get(e.getKey());
|
||||
if (tag != null && !tag.getAllElements().isEmpty()) {
|
||||
return Stream.of(new TagRandomItem(e.getValue(), tag));
|
||||
} else {
|
||||
return Stream.empty();
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (WeightedRandom.getTotalWeight(values) == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < TRIES; i++) {
|
||||
ResourceLocation ore = ((TagRandomItem) WeightedRandom.getRandomItem(getWorld().rand, values)).s;
|
||||
Tag<Block> tag = BlockTags.getCollection().get(ore);
|
||||
if(tag != null && !tag.getAllElements().isEmpty()) {
|
||||
return tag.getRandomElement(getWorld().getRandom()).getDefaultState();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
Tag<Block> ore = WeightedRandom.getRandomItem(getWorld().rand, values).tag;
|
||||
return ore.getRandomElement(getWorld().getRandom()).getDefaultState();
|
||||
}
|
||||
|
||||
private BlockPos getCoordsToPut() {
|
||||
@@ -160,11 +160,11 @@ public class SubTileOrechid extends TileEntityFunctionalFlower {
|
||||
|
||||
private static class TagRandomItem extends WeightedRandom.Item {
|
||||
|
||||
public final ResourceLocation s;
|
||||
public final Tag<Block> tag;
|
||||
|
||||
public TagRandomItem(int weight, ResourceLocation s) {
|
||||
public TagRandomItem(int weight, Tag<Block> tag) {
|
||||
super(weight);
|
||||
this.s = s;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -63,7 +63,7 @@ public class SubTileTangleberrie extends TileEntityFunctionalFlower {
|
||||
float distance = MathHelper.pointDistanceSpace(x1, y1, z1, x2, y2, z2);
|
||||
|
||||
if(distance > maxDist && distance < range) {
|
||||
MathHelper.setEntityMotionFromVector(entity, new Vector3(x1, y1, z1), getMotionVelocity());
|
||||
MathHelper.setEntityMotionFromVector(entity, new Vector3(x1, y1, z1), getMotionVelocity(entity));
|
||||
if(getWorld().rand.nextInt(3) == 0) {
|
||||
world.addParticle(data, x2 + Math.random() * entity.getWidth(), y2 + Math.random() * entity.getHeight(), z2 + Math.random() * entity.getWidth(), 0, 0, 0);
|
||||
}
|
||||
@@ -85,8 +85,8 @@ public class SubTileTangleberrie extends TileEntityFunctionalFlower {
|
||||
return 7;
|
||||
}
|
||||
|
||||
float getMotionVelocity() {
|
||||
return 0.05F;
|
||||
float getMotionVelocity(LivingEntity entity) {
|
||||
return Math.max(entity.getAIMoveSpeed() / 2F, 0.05F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-2
@@ -62,7 +62,6 @@ public class SubTileDandelifeon extends TileEntityGeneratingFlower {
|
||||
private void runSimulation() {
|
||||
int[][] table = getCellTable();
|
||||
List<int[]> changes = new ArrayList<>();
|
||||
new ArrayList();
|
||||
boolean wipe = false;
|
||||
|
||||
for(int i = 0; i < table.length; i++)
|
||||
@@ -178,7 +177,7 @@ public class SubTileDandelifeon extends TileEntityGeneratingFlower {
|
||||
if(gen < 0)
|
||||
world.removeBlock(pos, false);
|
||||
else ((TileCell) tile).setGeneration(this, gen);
|
||||
} else if(gen >= 0 && blockAt.isAir(stateAt, getWorld(), pos)) {
|
||||
} else if(gen >= 0 && stateAt.isAir(getWorld(), pos)) {
|
||||
world.setBlockState(pos, ModBlocks.cellBlock.getDefaultState());
|
||||
tile = world.getTileEntity(pos);
|
||||
((TileCell) tile).setGeneration(this, gen);
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.block.subtile.generating.SubTileDandelifeon;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
@@ -40,22 +41,18 @@ public class TileCell extends TileMod {
|
||||
super(TYPE);
|
||||
}
|
||||
|
||||
public void setGeneration(TileEntity flower, int gen) {
|
||||
public void setGeneration(SubTileDandelifeon flower, int gen) {
|
||||
generation = gen;
|
||||
if(!ticked) {
|
||||
flowerCoords = flower.getPos();
|
||||
flowerCoords = flower.getEffectivePos();
|
||||
validCoords = getPos();
|
||||
ticked = true;
|
||||
} else if(!matchCoords(validCoords, this) || !matchCoords(flowerCoords, flower))
|
||||
} else if(!validCoords.equals(getPos()) || !flowerCoords.equals(flower.getEffectivePos()))
|
||||
world.removeBlock(pos, false);
|
||||
}
|
||||
|
||||
public boolean isSameFlower(TileEntity flower) {
|
||||
return matchCoords(validCoords, this) && matchCoords(flowerCoords, flower);
|
||||
}
|
||||
|
||||
private boolean matchCoords(BlockPos coords, TileEntity tile) {
|
||||
return coords.equals(tile.getPos());
|
||||
public boolean isSameFlower(SubTileDandelifeon flower) {
|
||||
return validCoords.equals(getPos()) && flowerCoords.equals(flower.getEffectivePos());
|
||||
}
|
||||
|
||||
public int getGeneration() {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package vazkii.botania.common.block.tile;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.AgeableEntity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
@@ -20,10 +21,13 @@ import net.minecraft.entity.villager.IVillagerType;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TileCocoon extends TileMod implements ITickableTileEntity{
|
||||
@@ -34,20 +38,22 @@ public class TileCocoon extends TileMod implements ITickableTileEntity{
|
||||
private static final String TAG_TIME_PASSED = "timePassed";
|
||||
private static final String TAG_EMERALDS_GIVEN = "emeraldsGiven";
|
||||
private static final String TAG_CHORUS_FRUIT_GIVEN = "chorusFruitGiven";
|
||||
private static final List<EntityType<?>> SPECIALS = ImmutableList.of(
|
||||
EntityType.HORSE, EntityType.MULE, EntityType.DONKEY,
|
||||
EntityType.WOLF, EntityType.OCELOT, EntityType.CAT,
|
||||
EntityType.PARROT, EntityType.LLAMA, EntityType.FOX, EntityType.PANDA,
|
||||
EntityType.TURTLE
|
||||
private static final List<EntityType<? extends MobEntity>> SPECIALS = ImmutableList.of(
|
||||
EntityType.HORSE, EntityType.DONKEY, EntityType.WOLF, EntityType.OCELOT,
|
||||
EntityType.CAT, EntityType.PARROT, EntityType.LLAMA, EntityType.FOX,
|
||||
EntityType.PANDA, EntityType.TURTLE
|
||||
);
|
||||
private static final List<EntityType<?>> NORMALS = ImmutableList.of(
|
||||
EntityType.PIG, EntityType.COW, EntityType.CHICKEN, EntityType.RABBIT,
|
||||
EntityType.SHEEP, EntityType.COD, EntityType.SALMON, EntityType.TROPICAL_FISH
|
||||
private static final List<EntityType<? extends MobEntity>> NORMALS = ImmutableList.of(
|
||||
EntityType.PIG, EntityType.COW, EntityType.CHICKEN, EntityType.RABBIT, EntityType.SHEEP
|
||||
);
|
||||
private static final List<EntityType<? extends MobEntity>> AQUATIC = ImmutableList.of(
|
||||
EntityType.COD, EntityType.SALMON, EntityType.TROPICAL_FISH, EntityType.PUFFERFISH, EntityType.SQUID
|
||||
);
|
||||
|
||||
public static final int TOTAL_TIME = 2400;
|
||||
public static final int MAX_EMERALDS = 20;
|
||||
public static final int MAX_CHORUS_FRUITS = 20;
|
||||
private static final float SPECIAL_CHANCE = 0.075F;
|
||||
|
||||
public int timePassed;
|
||||
public int emeraldsGiven;
|
||||
@@ -70,10 +76,21 @@ public class TileCocoon extends TileMod implements ITickableTileEntity{
|
||||
world.destroyBlock(pos, false);
|
||||
|
||||
MobEntity entity = null;
|
||||
BlockPos placePos = pos;
|
||||
|
||||
float villagerChance = Math.min(1F, (float) emeraldsGiven / (float) MAX_EMERALDS);
|
||||
float shulkerChance = Math.min(1F, (float) chorusFruitGiven / (float) MAX_CHORUS_FRUITS);
|
||||
|
||||
List<BlockPos> validWater = new ArrayList<>();
|
||||
for (Direction d : Direction.values()) {
|
||||
if (d != Direction.UP) {
|
||||
BlockPos blockPos = pos.offset(d);
|
||||
if (world.getBlockState(blockPos).getBlock() == Blocks.WATER) {
|
||||
validWater.add(blockPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Math.random() < shulkerChance) {
|
||||
entity = EntityType.SHULKER.create(world);
|
||||
} else if(Math.random() < villagerChance) {
|
||||
@@ -83,20 +100,26 @@ public class TileCocoon extends TileMod implements ITickableTileEntity{
|
||||
villager.setVillagerData(villager.getVillagerData().withType(type));
|
||||
}
|
||||
entity = villager;
|
||||
} else {
|
||||
float specialChance = 0.075F;
|
||||
if(Math.random() < specialChance) {
|
||||
entity = (MobEntity) SPECIALS.get(world.rand.nextInt(SPECIALS.size())).create(world);
|
||||
} else if (!validWater.isEmpty()) {
|
||||
placePos = validWater.get(world.rand.nextInt(validWater.size()));
|
||||
if (Math.random() < SPECIAL_CHANCE) {
|
||||
entity = EntityType.DOLPHIN.create(world);
|
||||
} else {
|
||||
EntityType<?> type = NORMALS.get(world.rand.nextInt(NORMALS.size()));
|
||||
entity = AQUATIC.get(world.rand.nextInt(AQUATIC.size())).create(world);
|
||||
}
|
||||
} else {
|
||||
if(Math.random() < SPECIAL_CHANCE) {
|
||||
entity = SPECIALS.get(world.rand.nextInt(SPECIALS.size())).create(world);
|
||||
} else {
|
||||
EntityType<? extends MobEntity> type = NORMALS.get(world.rand.nextInt(NORMALS.size()));
|
||||
if (type == EntityType.COW && Math.random() < 0.01)
|
||||
type = EntityType.MOOSHROOM;
|
||||
entity = (MobEntity) type.create(world);
|
||||
entity = type.create(world);
|
||||
}
|
||||
}
|
||||
|
||||
if(entity != null) {
|
||||
entity.setPosition(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
||||
entity.setPosition(placePos.getX() + 0.5, placePos.getY() + 0.5, placePos.getZ() + 0.5);
|
||||
if(entity instanceof AgeableEntity)
|
||||
((AgeableEntity) entity).setGrowingAge(-24000);
|
||||
entity.onInitialSpawn(world, world.getDifficultyForLocation(getPos()), SpawnReason.EVENT, null, null);
|
||||
|
||||
@@ -32,13 +32,12 @@ public final class ConfigHandler {
|
||||
public final ForgeConfigSpec.BooleanValue enableFancySkyboxInNormalWorlds;
|
||||
|
||||
public final ForgeConfigSpec.IntValue manaBarHeight;
|
||||
public final ForgeConfigSpec.IntValue flightBarHeight;
|
||||
public final ForgeConfigSpec.IntValue flightBarBreathHeight;
|
||||
public final ForgeConfigSpec.IntValue glSecondaryTextureUnit;
|
||||
|
||||
public final ForgeConfigSpec.BooleanValue staticFloaters;
|
||||
public final ForgeConfigSpec.BooleanValue debugInfo;
|
||||
public final ForgeConfigSpec.BooleanValue referencesEnabled;
|
||||
public final ForgeConfigSpec.BooleanValue splashesEnabled;
|
||||
|
||||
public Client(ForgeConfigSpec.Builder builder) {
|
||||
useShaders = builder
|
||||
@@ -86,12 +85,6 @@ public final class ConfigHandler {
|
||||
manaBarHeight = builder
|
||||
.comment("The height of the mana display bar in above the XP bar. You can change this if you have a mod that changes where the XP bar is.")
|
||||
.defineInRange("hud.mana_bar.height", 29, 0, Integer.MAX_VALUE);
|
||||
flightBarHeight = builder
|
||||
.comment("The height of the Flugel Tiara flight bar. You can change this if you have a mod that adds a bar in that spot.")
|
||||
.defineInRange("hud.flight_bar.height", 49, 0, Integer.MAX_VALUE);
|
||||
flightBarBreathHeight = builder
|
||||
.comment("The height of the Flugel Tiara flight bar if your breath bar is shown. You can change this if you have a mod that adds a bar in that spot.")
|
||||
.defineInRange("hud.flight_bar_breath.height", 59, 0, Integer.MAX_VALUE);
|
||||
glSecondaryTextureUnit = builder
|
||||
.comment("The GL Texture Unit to use for the secondary sampler passed in to the Lexica Botania's category button shader. DO NOT TOUCH THIS IF YOU DON'T KNOW WHAT YOU'RE DOING")
|
||||
.defineInRange("shaders.secondary_unit", 7, 0, Integer.MAX_VALUE);
|
||||
@@ -104,6 +97,9 @@ public final class ConfigHandler {
|
||||
referencesEnabled = builder
|
||||
.comment("Set this to false to disable the references in the flower tooltips. (You monster D:)")
|
||||
.define("references", true);
|
||||
splashesEnabled = builder
|
||||
.comment("Set this to false to disable Botania's splashes in the main menu.")
|
||||
.define("splashes", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +146,7 @@ public final class ConfigHandler {
|
||||
.comment("Set this to false to remove the block breaking particles from the flowers and other items in the mod.")
|
||||
.define("blockBreakingParticles.enabled", true);
|
||||
blockBreakParticlesTool = builder
|
||||
.comment("Set this to false to remove the block breaking particles from the Mana Shatterer, as there can be a good amount in higher levels.")
|
||||
.comment("Set this to false to remove the block breaking particles from the Terra Shatterer, as there can be a good amount in higher levels.")
|
||||
.define("blockBreakingParticlesTool.enabled", true);
|
||||
chargingAnimationEnabled = builder
|
||||
.comment("Set this to false to disable the animation when an item is charging on top of a mana pool")
|
||||
|
||||
@@ -2,7 +2,7 @@ package vazkii.botania.common.core.handler;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraftforge.common.Tags;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.InterModComms;
|
||||
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
|
||||
import vazkii.botania.api.ColorHelper;
|
||||
@@ -13,77 +13,97 @@ import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class IMCSender {
|
||||
public static void enqueue(InterModEnqueueEvent evt) {
|
||||
send(IMC.REGISTER_ORE_WEIGHT, new OreWeightMessage(Tags.Blocks.ORES_COAL.getId(), 46525));
|
||||
send(IMC.REGISTER_ORE_WEIGHT, new OreWeightMessage(Tags.Blocks.ORES_DIAMOND.getId(), 1265));
|
||||
send(IMC.REGISTER_ORE_WEIGHT, new OreWeightMessage(Tags.Blocks.ORES_EMERALD.getId(), 780));
|
||||
send(IMC.REGISTER_ORE_WEIGHT, new OreWeightMessage(Tags.Blocks.ORES_GOLD.getId(), 2970));
|
||||
send(IMC.REGISTER_ORE_WEIGHT, new OreWeightMessage(Tags.Blocks.ORES_IRON.getId(), 20665));
|
||||
send(IMC.REGISTER_ORE_WEIGHT, new OreWeightMessage(Tags.Blocks.ORES_LAPIS.getId(), 1285));
|
||||
send(IMC.REGISTER_ORE_WEIGHT, new OreWeightMessage(Tags.Blocks.ORES_REDSTONE.getId(), 6885));
|
||||
send(IMC.REGISTER_NETHER_ORE_WEIGHT, new OreWeightMessage(Tags.Blocks.ORES_QUARTZ.getId(), 19600));
|
||||
/* Ore weights todo 1.13
|
||||
addOreWeight("oreAluminum", 3940); // Tinkers' Construct
|
||||
addOreWeight("oreAmber", 2075); // Thaumcraft
|
||||
addOreWeight("oreApatite", 1595); // Forestry
|
||||
addOreWeight("oreBlueTopaz", 3195); // Ars Magica
|
||||
addOreWeight("oreCertusQuartz", 3975); // Applied Energistics
|
||||
addOreWeight("oreChimerite", 3970); // Ars Magica
|
||||
addOreWeight("oreCinnabar", 2585); // Thaumcraft
|
||||
addOreWeight("oreCopper", 8325); // IC2, Thermal Expansion, Tinkers' Construct, etc.
|
||||
addOreWeight("oreDark", 1350); // EvilCraft
|
||||
addOreWeight("oreDarkIron", 1700); // Factorization (older versions)
|
||||
addOreWeight("oreFzDarkIron", 1700); // Factorization (newer versions)
|
||||
addOreWeight("oreGalena", 1000); // Factorization
|
||||
addOreWeight("oreInfusedAir", 925); // Thaumcraft
|
||||
addOreWeight("oreInfusedEarth", 925); // Thaumcraft
|
||||
addOreWeight("oreInfusedEntropy", 925); // Thaumcraft
|
||||
addOreWeight("oreInfusedFire", 925); // Thaumcraft
|
||||
addOreWeight("oreInfusedOrder", 925); // Thaumcraft
|
||||
addOreWeight("oreInfusedWater", 925); // Thaumcraft
|
||||
addOreWeight("oreLead", 7985); // IC2, Thermal Expansion, Factorization, etc.
|
||||
addOreWeight("oreMCropsEssence", 3085); // Magical Crops
|
||||
addOreWeight("oreMithril", 8); // Thermal Expansion
|
||||
addOreWeight("oreNickel", 2275); // Thermal Expansion
|
||||
addOreWeight("oreOlivine", 1100); // Project RED
|
||||
addOreWeight("orePlatinum", 365); // Thermal Expansion
|
||||
addOreWeight("oreRuby", 1100); // Project RED
|
||||
addOreWeight("oreSapphire", 1100); // Project RED
|
||||
addOreWeight("oreSilver", 6300); // Thermal Expansion, Factorization, etc.
|
||||
addOreWeight("oreSulfur", 1105); // Railcraft
|
||||
addOreWeight("oreTin", 9450); // IC2, Thermal Expansion, etc.
|
||||
addOreWeight("oreUranium", 1337); // IC2
|
||||
addOreWeight("oreVinteum", 5925); // Ars Magica
|
||||
addOreWeight("oreYellorite", 3520); // Big Reactors
|
||||
addOreWeight("oreZinc", 6485); // Flaxbeard's Steam Power
|
||||
addOreWeight("oreMythril", 6485); // Simple Ores2
|
||||
addOreWeight("oreAdamantium", 2275); // Simple Ores2
|
||||
addOreWeight("oreTungsten", 3520); // Simple Tungsten
|
||||
addOreWeight("oreOsmium", 6915); // Mekanism
|
||||
addOreWeight("oreQuartzBlack", 5535); // Actually Additions
|
||||
// Vanilla
|
||||
addOreWeight("coal", 67415);
|
||||
addOreWeight("diamond", 883);
|
||||
addOreWeight("emerald", 1239);
|
||||
addOreWeight("gold", 2647);
|
||||
addOreWeight("iron", 29371);
|
||||
addOreWeight("lapis", 1079);
|
||||
addOreWeight("redstone", 7654);
|
||||
// Common Metals
|
||||
addOreWeight("aluminium", 13762);
|
||||
addOreWeight("aluminum", 13762);
|
||||
addOreWeight("copper", 5567);
|
||||
addOreWeight("ferrous", 558);
|
||||
addOreWeight("galena", 4096);
|
||||
addOreWeight("lead", 4093);
|
||||
addOreWeight("mithril", 6485);
|
||||
addOreWeight("mythril", 6485);
|
||||
addOreWeight("nickel", 2275);
|
||||
addOreWeight("osmium", 6915);
|
||||
addOreWeight("platinum", 956);
|
||||
addOreWeight("silver", 4315);
|
||||
addOreWeight("tin", 8251);
|
||||
addOreWeight("tungsten", 140);
|
||||
addOreWeight("uranium", 230);
|
||||
addOreWeight("zinc", 838);
|
||||
// Common Gems
|
||||
addOreWeight("amber", 902);
|
||||
addOreWeight("ruby", 1384);
|
||||
addOreWeight("sapphire", 1287);
|
||||
addOreWeight("topaz", 6436);
|
||||
addOreWeight("amethyst", 1307);
|
||||
addOreWeight("malachite", 160);
|
||||
// Extreme Reactors
|
||||
addOreWeight("yellorite", 3520);
|
||||
// Blue Power
|
||||
addOreWeight("teslatite", 4312);
|
||||
// EvilCraft
|
||||
addOreWeight("dark", 1350);
|
||||
// Forestry
|
||||
addOreWeight("apatite", 250);
|
||||
// Mystical Agriculture
|
||||
addOreWeight("inferium", 10000);
|
||||
addOreWeight("prosperity", 7420);
|
||||
// Project RED
|
||||
addOreWeight("olivine", 1100);
|
||||
// Railcraft
|
||||
addOreWeight("sulfur", 1105);
|
||||
addOreWeight("sulphur", 1105);
|
||||
// Simple Ores 2
|
||||
addOreWeight("adamantium", 1469);
|
||||
// Silent Mechanisms
|
||||
addOreWeight("bismuth", 2407);
|
||||
// Thaumcraft
|
||||
addOreWeight("cinnabar", 2585);
|
||||
|
||||
addOreWeightNether("oreCobalt", 500); // Tinker's Construct
|
||||
addOreWeightNether("oreArdite", 500); // Tinker's Construct
|
||||
addOreWeightNether("oreFirestone", 5); // Railcraft
|
||||
addOreWeightNether("oreNetherCoal", 17000); // Nether Ores
|
||||
addOreWeightNether("oreNetherCopper", 4700); // Nether Ores
|
||||
addOreWeightNether("oreNetherDiamond", 175); // Nether Ores
|
||||
addOreWeightNether("oreNetherEssence", 2460); // Magical Crops
|
||||
addOreWeightNether("oreNetherGold", 3635); // Nether Ores
|
||||
addOreWeightNether("oreNetherIron", 5790); // Nether Ores
|
||||
addOreWeightNether("oreNetherLapis", 3250); // Nether Ores
|
||||
addOreWeightNether("oreNetherLead", 2790); // Nether Ores
|
||||
addOreWeightNether("oreNetherNickel", 1790); // Nether Ores
|
||||
addOreWeightNether("oreNetherPlatinum", 170); // Nether Ores
|
||||
addOreWeightNether("oreNetherRedstone", 5600); // Nether Ores
|
||||
addOreWeightNether("oreNetherSilver", 1550); // Nether Ores
|
||||
addOreWeightNether("oreNetherSteel", 1690); // Nether Ores
|
||||
addOreWeightNether("oreNetherTin", 3750); // Nether Ores
|
||||
addOreWeightNether("oreFyrite", 1000); // Netherrocks
|
||||
addOreWeightNether("oreAshstone", 1000); // Netherrocks
|
||||
addOreWeightNether("oreDragonstone", 175); // Netherrocks
|
||||
addOreWeightNether("oreArgonite", 1000); // Netherrocks
|
||||
addOreWeightNether("oreOnyx", 500); // SimpleOres 2
|
||||
addOreWeightNether("oreHaditeCoal", 500); // Hadite
|
||||
// Vanilla
|
||||
addOreWeightNether("quartz", 19600);
|
||||
// Mystical Agriculture
|
||||
addOreWeight("nether/inferium", 10000);
|
||||
addOreWeight("nether/prosperity", 7420);
|
||||
// Nether Ores
|
||||
addOreWeightNether("nether/coal", 17000);
|
||||
addOreWeightNether("nether/copper", 4700);
|
||||
addOreWeightNether("nether/diamond", 175);
|
||||
addOreWeightNether("nether/gold", 3635);
|
||||
addOreWeightNether("nether/iron", 5790);
|
||||
addOreWeightNether("nether/lapis", 3250);
|
||||
addOreWeightNether("nether/lead", 2790);
|
||||
addOreWeightNether("nether/nickel", 1790);
|
||||
addOreWeightNether("nether/platinum", 170);
|
||||
addOreWeightNether("nether/redstone", 5600);
|
||||
addOreWeightNether("nether/silver", 1550);
|
||||
addOreWeightNether("nether/steel", 1690);
|
||||
addOreWeightNether("nether/tin", 3750);
|
||||
// Netherrocks
|
||||
addOreWeightNether("argonite", 1000);
|
||||
addOreWeightNether("ashstone", 1000);
|
||||
addOreWeightNether("dragonstone", 175);
|
||||
addOreWeightNether("fyrite", 1000);
|
||||
// Railcraft
|
||||
addOreWeightNether("firestone", 5);
|
||||
// Simple Ores 2
|
||||
addOreWeightNether("onyx", 500);
|
||||
// Tinkers Construct
|
||||
addOreWeightNether("ardite", 500);
|
||||
addOreWeightNether("cobalt", 500);
|
||||
|
||||
/* Ore weights TODO 1.14 / 1.15
|
||||
addOreWeight("oreCertusQuartz", 3975); // Applied Energistics certusQuartz, certus/quartz or quartz/certus?
|
||||
addOreWeight("oreQuartzBlack", 5535); // Actually Additions quartzBlock, quartz/black or black/quartz?
|
||||
addOreWeightNether("oreHaditeCoal", 500); // Hadite haditeCoal, hadite/coal or coal/hadite?
|
||||
*/
|
||||
|
||||
// Can't iterate over ColorHelper map values yet since remap event hasn't fired yet -.-
|
||||
@@ -139,4 +159,12 @@ public class IMCSender {
|
||||
public static void send(String method, Object thing) {
|
||||
InterModComms.sendTo(LibMisc.MOD_ID, method, () -> thing);
|
||||
}
|
||||
|
||||
private static void addOreWeight(String oreTag, int weight) {
|
||||
send(IMC.REGISTER_ORE_WEIGHT, new OreWeightMessage(new ResourceLocation("forge", "ores/" + oreTag), weight));
|
||||
}
|
||||
|
||||
private static void addOreWeightNether(String oreTag, int weight) {
|
||||
send(IMC.REGISTER_NETHER_ORE_WEIGHT, new OreWeightMessage(new ResourceLocation("forge", "ores/" + oreTag), weight));
|
||||
}
|
||||
}
|
||||
@@ -11,18 +11,20 @@ import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID)
|
||||
public final class SleepingHandler {
|
||||
|
||||
|
||||
private SleepingHandler() {}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void trySleep(PlayerSleepInBedEvent event) {
|
||||
World world = event.getPlayer().world;
|
||||
boolean nearGuardian = ((ServerWorld) world).getEntities()
|
||||
.filter(e -> e instanceof EntityDoppleganger)
|
||||
.anyMatch(e -> ((EntityDoppleganger) e).getPlayersAround().contains(event.getPlayer()));
|
||||
if(!world.isRemote()) {
|
||||
boolean nearGuardian = ((ServerWorld) world).getEntities()
|
||||
.filter(e -> e instanceof EntityDoppleganger)
|
||||
.anyMatch(e -> ((EntityDoppleganger) e).getPlayersAround().contains(event.getPlayer()));
|
||||
|
||||
if(nearGuardian) {
|
||||
event.setResult(PlayerEntity.SleepResult.NOT_SAFE);
|
||||
if(nearGuardian) {
|
||||
event.setResult(PlayerEntity.SleepResult.NOT_SAFE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public final class LootHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private static LootPool getInjectPool(String entryName) {
|
||||
public static LootPool getInjectPool(String entryName) {
|
||||
return LootPool.builder()
|
||||
.addEntry(getInjectEntry(entryName, 1))
|
||||
.bonusRolls(0, 1)
|
||||
|
||||
@@ -19,8 +19,6 @@ public interface IProxy {
|
||||
|
||||
boolean isClientPlayerWearingMonocle();
|
||||
|
||||
String getLastVersion();
|
||||
|
||||
long getWorldElapsedTicks();
|
||||
|
||||
default void lightningFX(Vector3 vectorStart, Vector3 vectorEnd, float ticksPerMeter, int colorOuter, int colorInner) {
|
||||
|
||||
@@ -35,11 +35,6 @@ public class ServerProxy implements IProxy {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLastVersion() {
|
||||
return LibMisc.BUILD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getWorldElapsedTicks() {
|
||||
return ServerLifecycleHooks.getCurrentServer().getWorld(DimensionType.OVERWORLD).getGameTime();
|
||||
|
||||
@@ -29,7 +29,7 @@ public final class ModPureDaisyRecipes {
|
||||
evt.pureDaisy().accept(new RecipePureDaisy(prefix("livingrock"), Tags.Blocks.STONE, ModBlocks.livingrock.getDefaultState()));
|
||||
evt.pureDaisy().accept(new RecipePureDaisy(prefix("livingwood"), BlockTags.LOGS, ModBlocks.livingwood.getDefaultState()));
|
||||
|
||||
evt.pureDaisy().accept(new RecipePureDaisy(prefix("cobblestone"), Tags.Blocks.STONE, ModBlocks.livingrock.getDefaultState()));
|
||||
evt.pureDaisy().accept(new RecipePureDaisy(prefix("cobblestone"), Tags.Blocks.NETHERRACK, Blocks.COBBLESTONE.getDefaultState()));
|
||||
evt.pureDaisy().accept(new RecipePureDaisy(prefix("sand"), Blocks.SOUL_SAND, Blocks.SAND.getDefaultState()));
|
||||
evt.pureDaisy().accept(new RecipePureDaisy(prefix("packed_ice"), Blocks.ICE, Blocks.PACKED_ICE.getDefaultState()));
|
||||
evt.pureDaisy().accept(new RecipePureDaisy(prefix("blue_ice"), Blocks.PACKED_ICE, Blocks.BLUE_ICE.getDefaultState()));
|
||||
|
||||
@@ -78,12 +78,4 @@ public class SyncHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID)
|
||||
public static class CommonEvents {
|
||||
@SubscribeEvent
|
||||
public static void serverLogin(PlayerEvent.PlayerLoggedInEvent evt) {
|
||||
PacketHandler.sendNonLocal((ServerPlayerEntity) evt.getPlayer(), syncPacket());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -248,6 +248,6 @@ public class EntityThornChakram extends ThrowableEntity implements IRendersAsIte
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getItem() {
|
||||
return stack;
|
||||
return getItemStack();
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -38,8 +39,8 @@ public class ItemDodgeRing extends ItemBauble {
|
||||
public static final String TAG_DODGE_COOLDOWN = "dodgeCooldown";
|
||||
public static final int MAX_CD = 20;
|
||||
|
||||
private static boolean oldLeftDown, oldRightDown;
|
||||
private static int leftDown, rightDown;
|
||||
private static boolean oldLeftDown, oldRightDown, oldForwardDown, oldBackDown;
|
||||
private static int leftDown, rightDown, forwardDown, backDown;
|
||||
|
||||
public ItemDodgeRing(Properties props) {
|
||||
super(props);
|
||||
@@ -56,23 +57,37 @@ public class ItemDodgeRing extends ItemBauble {
|
||||
if(ringStack.isEmpty() || ItemNBTHelper.getInt(ringStack, TAG_DODGE_COOLDOWN, 0) > 0)
|
||||
return;
|
||||
|
||||
int threshold = 4;
|
||||
int threshold = 5;
|
||||
if(mc.gameSettings.keyBindLeft.isKeyDown() && !oldLeftDown) {
|
||||
int oldLeft = leftDown;
|
||||
leftDown = ClientTickHandler.ticksInGame;
|
||||
|
||||
if(leftDown - oldLeft < threshold)
|
||||
dodge(mc.player, true);
|
||||
dodge(mc.player, Direction.WEST);
|
||||
} else if(mc.gameSettings.keyBindRight.isKeyDown() && !oldRightDown) {
|
||||
int oldRight = rightDown;
|
||||
rightDown = ClientTickHandler.ticksInGame;
|
||||
|
||||
if(rightDown - oldRight < threshold)
|
||||
dodge(mc.player, false);
|
||||
dodge(mc.player, Direction.EAST);
|
||||
} else if(mc.gameSettings.keyBindForward.isKeyDown() && !oldForwardDown) {
|
||||
int oldForward = forwardDown;
|
||||
forwardDown = ClientTickHandler.ticksInGame;
|
||||
|
||||
if(forwardDown - oldForward < threshold)
|
||||
dodge(mc.player, Direction.NORTH);
|
||||
} else if(mc.gameSettings.keyBindBack.isKeyDown() && !oldBackDown) {
|
||||
int oldBack = backDown;
|
||||
backDown = ClientTickHandler.ticksInGame;
|
||||
|
||||
if(backDown - oldBack < threshold)
|
||||
dodge(mc.player, Direction.SOUTH);
|
||||
}
|
||||
|
||||
oldLeftDown = mc.gameSettings.keyBindLeft.isKeyDown();
|
||||
oldRightDown = mc.gameSettings.keyBindRight.isKeyDown();
|
||||
oldForwardDown = mc.gameSettings.keyBindForward.isKeyDown();
|
||||
oldBackDown = mc.gameSettings.keyBindBack.isKeyDown();
|
||||
}
|
||||
|
||||
|
||||
@@ -83,15 +98,20 @@ public class ItemDodgeRing extends ItemBauble {
|
||||
ItemNBTHelper.setInt(stack, TAG_DODGE_COOLDOWN, cd - 1);
|
||||
}
|
||||
|
||||
private static void dodge(PlayerEntity player, boolean left) {
|
||||
if(player.abilities.isFlying || !player.onGround || player.moveForward > 0.2 || player.moveForward < -0.2)
|
||||
private static void dodge(PlayerEntity player, Direction dir) {
|
||||
if(player.abilities.isFlying || !player.onGround || dir == Direction.UP || dir == Direction.DOWN)
|
||||
return;
|
||||
|
||||
float yaw = player.rotationYaw;
|
||||
float x = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI);
|
||||
float z = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
|
||||
if(dir == Direction.NORTH || dir == Direction.SOUTH) {
|
||||
x = MathHelper.cos(-yaw * 0.017453292F);
|
||||
z = MathHelper.sin(yaw * 0.017453292F);
|
||||
}
|
||||
Vector3 lookVec = new Vector3(x, 0, z);
|
||||
Vector3 sideVec = lookVec.crossProduct(new Vector3(0, left ? 1 : -1, 0)).multiply(1.25);
|
||||
Vector3 sideVec = lookVec.crossProduct(new Vector3(0, dir == Direction.WEST || dir == Direction.NORTH? 1 :
|
||||
(dir == Direction.EAST || dir == Direction.SOUTH? -1 : 0), 0)).multiply(1.25);
|
||||
|
||||
player.setMotion(sideVec.toVec3D());
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.gui.ForgeIngameGui;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
@@ -77,10 +78,12 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem {
|
||||
|
||||
private static final String TAG_VARIANT = "variant";
|
||||
private static final String TAG_FLYING = "flying";
|
||||
private static final String TAG_GLIDING = "gliding";
|
||||
private static final String TAG_TIME_LEFT = "timeLeft";
|
||||
private static final String TAG_INFINITE_FLIGHT = "infiniteFlight";
|
||||
private static final String TAG_DASH_COOLDOWN = "dashCooldown";
|
||||
private static final String TAG_IS_SPRINTING = "isSprinting";
|
||||
private static final String TAG_BOOST_PENDING = "boostPending";
|
||||
|
||||
private static final List<String> playersWithFlight = Collections.synchronizedList(new ArrayList<>());
|
||||
private static final int COST = 35;
|
||||
@@ -272,15 +275,17 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem {
|
||||
p.setMotion(p.getMotion().add(look.x, 0, look.z));
|
||||
p.world.playSound(null, p.getX(), p.getY(), p.getZ(), ModSounds.dash, SoundCategory.PLAYERS, 1F, 1F);
|
||||
ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, maxCd);
|
||||
ItemNBTHelper.setBoolean(stack, TAG_BOOST_PENDING, true);
|
||||
} else if(cooldown > 0) {
|
||||
if(maxCd - cooldown < 2)
|
||||
if(ItemNBTHelper.getBoolean(stack, TAG_BOOST_PENDING, false)) {
|
||||
player.moveRelative(5F, new Vec3d(0F, 0F, 1F));
|
||||
else if(maxCd - cooldown < 10)
|
||||
player.setSprinting(false);
|
||||
ItemNBTHelper.removeEntry(stack, TAG_BOOST_PENDING);
|
||||
}
|
||||
ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, cooldown - 2);
|
||||
}
|
||||
} else {
|
||||
boolean doGlide = player.isSneaking() && !player.onGround && player.fallDistance >= 2F;
|
||||
boolean wasGliding = ItemNBTHelper.getBoolean(stack, TAG_GLIDING, false);
|
||||
boolean doGlide = player.isSneaking() && !player.onGround && (player.getMotion().getY() < -.7F || wasGliding);
|
||||
if(time < MAX_FLY_TIME && player.ticksExisted % (doGlide ? 6 : 2) == 0)
|
||||
newTime++;
|
||||
|
||||
@@ -289,6 +294,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem {
|
||||
player.setMotion(look.x * mul, Math.max(-0.15F, player.getMotion().getY()), look.z * mul);
|
||||
player.fallDistance = 2F;
|
||||
}
|
||||
ItemNBTHelper.setBoolean(stack, TAG_GLIDING, doGlide);
|
||||
}
|
||||
|
||||
ItemNBTHelper.setBoolean(stack, TAG_FLYING, flying);
|
||||
@@ -449,9 +455,8 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem {
|
||||
mc.textureManager.bindTexture(textureHud);
|
||||
int xo = mc.getWindow().getScaledWidth() / 2 + 10;
|
||||
int x = xo;
|
||||
int y = mc.getWindow().getScaledHeight() - ConfigHandler.CLIENT.flightBarHeight.get();
|
||||
if(player.areEyesInFluid(FluidTags.WATER))
|
||||
y = mc.getWindow().getScaledHeight() - ConfigHandler.CLIENT.flightBarBreathHeight.get();
|
||||
int y = mc.getWindow().getScaledHeight() - ForgeIngameGui.right_height;
|
||||
ForgeIngameGui.right_height += 10;
|
||||
|
||||
int left = ItemNBTHelper.getInt(stack, TAG_TIME_LEFT, MAX_FLY_TIME);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelSword;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ItemEnderDagger extends ItemManasteelSword {
|
||||
|
||||
@@ -45,6 +46,11 @@ public class ItemEnderDagger extends ItemManasteelSword {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends LivingEntity> int damageItem(ItemStack stack, int amount, T entity, Consumer<T> onBroken) {
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World world, Entity player, int par4, boolean par5) {}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.item.equipment.tool.ToolCommons;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ItemLivingwoodBow extends BowItem implements IManaUsingItem {
|
||||
public static final int MANA_PER_DAMAGE = 40;
|
||||
@@ -166,4 +167,9 @@ public class ItemLivingwoodBow extends BowItem implements IManaUsingItem {
|
||||
public boolean usesMana(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends LivingEntity> int damageItem(ItemStack stack, int amount, T entity, Consumer<T> onBroken) {
|
||||
return ToolCommons.damageItemIfPossible(stack, amount, entity, MANA_PER_DAMAGE);
|
||||
}
|
||||
}
|
||||
+8
-17
@@ -10,7 +10,6 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.equipment.tool.manasteel;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -19,7 +18,6 @@ import net.minecraft.item.IItemTier;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.item.ISortableTool;
|
||||
@@ -30,6 +28,7 @@ import vazkii.botania.common.core.helper.PlayerHelper;
|
||||
import vazkii.botania.common.item.equipment.tool.ToolCommons;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ItemManasteelAxe extends AxeItem implements IManaUsingItem, ISortableTool {
|
||||
@@ -47,17 +46,8 @@ public class ItemManasteelAxe extends AxeItem implements IManaUsingItem, ISortab
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack par1ItemStack, LivingEntity par2EntityLivingBase, @Nonnull LivingEntity par3EntityLivingBase) {
|
||||
ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, getManaPerDamage());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(@Nonnull ItemStack stack, @Nonnull World world, @Nonnull BlockState state, @Nonnull BlockPos pos, @Nonnull LivingEntity entity) {
|
||||
if (state.getBlockHardness(world, pos) != 0F)
|
||||
ToolCommons.damageItem(stack, 1, entity, getManaPerDamage());
|
||||
|
||||
return true;
|
||||
public <T extends LivingEntity> int damageItem(ItemStack stack, int amount, T entity, Consumer<T> onBroken) {
|
||||
return ToolCommons.damageItemIfPossible(stack, amount, entity, getManaPerDamage());
|
||||
}
|
||||
|
||||
public int getManaPerDamage() {
|
||||
@@ -73,14 +63,15 @@ public class ItemManasteelAxe extends AxeItem implements IManaUsingItem, ISortab
|
||||
ItemStack stackAt = player.inventory.getStackInSlot(i);
|
||||
if(!stackAt.isEmpty() && SAPLING_PATTERN.matcher(stackAt.getItem().getTranslationKey()).find()) {
|
||||
ItemStack displayStack = stackAt.copy();
|
||||
ActionResultType did = PlayerHelper.substituteUse(ctx, stackAt);
|
||||
ItemsRemainingRenderHandler.set(player, displayStack, SAPLING_PATTERN);
|
||||
return did;
|
||||
if (PlayerHelper.substituteUse(ctx, stackAt) == ActionResultType.SUCCESS) {
|
||||
ItemsRemainingRenderHandler.set(player, displayStack, SAPLING_PATTERN);
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ActionResultType.PASS;
|
||||
return super.onItemUse(ctx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -30,6 +30,7 @@ import vazkii.botania.common.core.helper.PlayerHelper;
|
||||
import vazkii.botania.common.item.equipment.tool.ToolCommons;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ItemManasteelPick extends PickaxeItem implements IManaUsingItem, ISortableTool {
|
||||
@@ -47,9 +48,8 @@ public class ItemManasteelPick extends PickaxeItem implements IManaUsingItem, IS
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack par1ItemStack, LivingEntity par2EntityLivingBase, @Nonnull LivingEntity par3EntityLivingBase) {
|
||||
ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, getManaPerDamage());
|
||||
return true;
|
||||
public <T extends LivingEntity> int damageItem(ItemStack stack, int amount, T entity, Consumer<T> onBroken) {
|
||||
return ToolCommons.damageItemIfPossible(stack, amount, entity, getManaPerDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
@@ -33,6 +33,7 @@ import vazkii.botania.common.item.equipment.tool.ToolCommons;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ItemManasteelShears extends ShearsItem implements IManaUsingItem {
|
||||
|
||||
@@ -98,6 +99,11 @@ public class ItemManasteelShears extends ShearsItem implements IManaUsingItem {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends LivingEntity> int damageItem(ItemStack stack, int amount, T entity, Consumer<T> onBroken) {
|
||||
return ToolCommons.damageItemIfPossible(stack, amount, entity, MANA_PER_DAMAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World world, Entity player, int par4, boolean par5) {
|
||||
if(!world.isRemote && player instanceof PlayerEntity && stack.getDamage() > 0 && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) player, MANA_PER_DAMAGE * 2, true))
|
||||
|
||||
+15
-18
@@ -38,6 +38,7 @@ import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ItemManasteelShovel extends ShovelItem implements IManaUsingItem, ISortableTool {
|
||||
|
||||
@@ -59,11 +60,8 @@ public class ItemManasteelShovel extends ShovelItem implements IManaUsingItem, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(@Nonnull ItemStack stack, @Nonnull World world, @Nonnull BlockState state, @Nonnull BlockPos pos, @Nonnull LivingEntity entity) {
|
||||
if (state.getBlockHardness(world, pos) != 0F)
|
||||
ToolCommons.damageItem(stack, 1, entity, getManaPerDamage());
|
||||
|
||||
return true;
|
||||
public <T extends LivingEntity> int damageItem(ItemStack stack, int amount, T entity, Consumer<T> onBroken) {
|
||||
return ToolCommons.damageItemIfPossible(stack, amount, entity, getManaPerDamage());
|
||||
}
|
||||
|
||||
public int getManaPerDamage() {
|
||||
@@ -73,6 +71,9 @@ public class ItemManasteelShovel extends ShovelItem implements IManaUsingItem, I
|
||||
@Nonnull
|
||||
@Override
|
||||
public ActionResultType onItemUse(ItemUseContext ctx) {
|
||||
if (super.onItemUse(ctx) == ActionResultType.SUCCESS)
|
||||
return ActionResultType.SUCCESS;
|
||||
|
||||
ItemStack stack = ctx.getItem();
|
||||
PlayerEntity player = ctx.getPlayer();
|
||||
World world = ctx.getWorld();
|
||||
@@ -81,21 +82,17 @@ public class ItemManasteelShovel extends ShovelItem implements IManaUsingItem, I
|
||||
if (player == null || !player.canPlayerEdit(pos, ctx.getFace(), stack))
|
||||
return ActionResultType.PASS;
|
||||
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
BlockState converted = SHOVEL_LOOKUP.get(block);
|
||||
UseHoeEvent event = new UseHoeEvent(ctx);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return ActionResultType.FAIL;
|
||||
|
||||
if (converted == null) {
|
||||
UseHoeEvent event = new UseHoeEvent(ctx);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return ActionResultType.FAIL;
|
||||
|
||||
if (event.getResult() == Event.Result.ALLOW) {
|
||||
ToolCommons.damageItem(stack, 1, player, getManaPerDamage());
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
converted = HOE_LOOKUP.get(block);
|
||||
if (event.getResult() == Event.Result.ALLOW) {
|
||||
ToolCommons.damageItem(stack, 1, player, getManaPerDamage());
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
BlockState converted = HOE_LOOKUP.get(block);
|
||||
if (converted == null)
|
||||
return ActionResultType.PASS;
|
||||
|
||||
|
||||
+3
-15
@@ -10,7 +10,6 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.equipment.tool.manasteel;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -18,14 +17,13 @@ import net.minecraft.item.IItemTier;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.SwordItem;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.mana.IManaUsingItem;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.common.item.equipment.tool.ToolCommons;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ItemManasteelSword extends SwordItem implements IManaUsingItem {
|
||||
|
||||
@@ -42,18 +40,8 @@ public class ItemManasteelSword extends SwordItem implements IManaUsingItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack par1ItemStack, LivingEntity par2EntityLivingBase, @Nonnull LivingEntity par3EntityLivingBase) {
|
||||
if(usesMana(par1ItemStack))
|
||||
ToolCommons.damageItem(par1ItemStack, 1, par3EntityLivingBase, getManaPerDamage());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(@Nonnull ItemStack stack, @Nonnull World world, BlockState state, @Nonnull BlockPos pos, @Nonnull LivingEntity entity) {
|
||||
if(usesMana(stack) && state.getBlockHardness(world, pos) != 0F)
|
||||
ToolCommons.damageItem(stack, 1, entity, getManaPerDamage());
|
||||
|
||||
return true;
|
||||
public <T extends LivingEntity> int damageItem(ItemStack stack, int amount, T entity, Consumer<T> onBroken) {
|
||||
return ToolCommons.damageItemIfPossible(stack, amount, entity, getManaPerDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -92,6 +92,10 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ
|
||||
setMana(stack, mana);
|
||||
list.add(stack);
|
||||
}
|
||||
ItemStack stack = new ItemStack(this);
|
||||
setMana(stack, CREATIVE_MANA[1]);
|
||||
setTipped(stack);
|
||||
list.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -21,7 +21,6 @@ import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.api.mana.BurstProperties;
|
||||
@@ -108,8 +107,8 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
|
||||
LivingEntity thrower = entity.getThrower();
|
||||
|
||||
for(LivingEntity living : entities) {
|
||||
if(living == thrower
|
||||
|| ServerLifecycleHooks.getCurrentServer() != null && !ServerLifecycleHooks.getCurrentServer().isPVPEnabled())
|
||||
if(living == thrower || living instanceof PlayerEntity && thrower instanceof PlayerEntity
|
||||
&& ((PlayerEntity) thrower).canAttackPlayer(((PlayerEntity) living)))
|
||||
continue;
|
||||
|
||||
if(living.hurtTime == 0) {
|
||||
|
||||
@@ -75,7 +75,8 @@ public class ItemGravityRod extends Item implements IManaUsingItem {
|
||||
if(ticksCooldown > 0)
|
||||
ticksCooldown--;
|
||||
|
||||
ticksTillExpire--;
|
||||
if (ticksTillExpire >= 0)
|
||||
ticksTillExpire--;
|
||||
ItemNBTHelper.setInt(stack, TAG_TICKS_TILL_EXPIRE, ticksTillExpire);
|
||||
ItemNBTHelper.setInt(stack, TAG_TICKS_COOLDOWN, ticksCooldown);
|
||||
|
||||
@@ -220,7 +221,7 @@ public class ItemGravityRod extends Item implements IManaUsingItem {
|
||||
}
|
||||
item.remove();
|
||||
} else {
|
||||
item.setMotion(item.getMotion().mul(3, 1.5, 3));
|
||||
item.setMotion(moveVector.multiply(3, 1.5, 3).toVec3D());
|
||||
}
|
||||
ItemNBTHelper.setInt(stack, TAG_TICKS_COOLDOWN, 10);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* This class was created by <Hubry>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [2020-01-13, 17:34 (UTC+2)]
|
||||
*/
|
||||
package vazkii.botania.common.network;
|
||||
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
public interface ILoginPacket extends IntSupplier {
|
||||
|
||||
void setLoginIndex(int index);
|
||||
|
||||
int getLoginIndex();
|
||||
|
||||
@Override
|
||||
default int getAsInt() {
|
||||
return getLoginIndex();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* This class was created by <Hubry>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [2020-01-13, 17:43 (UTC+2)]
|
||||
*/
|
||||
package vazkii.botania.common.network;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PacketAck implements ILoginPacket {
|
||||
private int loginIndex;
|
||||
|
||||
public static PacketAck decode(PacketBuffer buf) {
|
||||
return new PacketAck();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoginIndex(int index) {
|
||||
this.loginIndex = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLoginIndex() {
|
||||
return loginIndex;
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,10 @@ public class PacketBotaniaEffect {
|
||||
|
||||
public static class Handler {
|
||||
public static void handle(final PacketBotaniaEffect message, final Supplier<NetworkEvent.Context> ctx) {
|
||||
if (ctx.get().getDirection().getReceptionSide().isServer()) {
|
||||
ctx.get().setPacketHandled(true);
|
||||
return;
|
||||
}
|
||||
ctx.get().enqueueWork(new Runnable() {
|
||||
// Use anon - lambda causes classloading issues
|
||||
@Override
|
||||
@@ -76,13 +80,13 @@ public class PacketBotaniaEffect {
|
||||
int hex = placeColor.colorValue;
|
||||
int r = (hex & 0xFF0000) >> 16;
|
||||
int g = (hex & 0xFF00) >> 8;
|
||||
int b = hex & 0xFF;
|
||||
for(int i = 0; i < 10; i++) {
|
||||
BlockPos pos = new BlockPos(message.x, message.y, message.z).offset(Direction.random(world.rand));
|
||||
SparkleParticleData data = SparkleParticleData.sparkle(0.6F + (float) Math.random() * 0.5F, r / 255F, g / 255F, b / 255F, 5);
|
||||
world.addParticle(data, pos.getX() + (float) Math.random(), pos.getY() + (float) Math.random(), pos.getZ() + (float) Math.random(), 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
int b = hex & 0xFF;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
BlockPos pos = new BlockPos(message.x, message.y, message.z).offset(Direction.random(world.rand));
|
||||
SparkleParticleData data = SparkleParticleData.sparkle(0.6F + (float) Math.random() * 0.5F, r / 255F, g / 255F, b / 255F, 5);
|
||||
world.addParticle(data, pos.getX() + (float) Math.random(), pos.getY() + (float) Math.random(), pos.getZ() + (float) Math.random(), 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ARENA_INDICATOR: {
|
||||
SparkleParticleData data = SparkleParticleData.sparkle(5F, 1, 0, 1, 120);
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
import vazkii.botania.common.core.handler.EquipmentHandler;
|
||||
import vazkii.botania.common.core.handler.ModSounds;
|
||||
@@ -32,19 +33,20 @@ public class PacketDodge {
|
||||
}
|
||||
|
||||
public static void handle(PacketDodge msg, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
ServerPlayerEntity player = ctx.get().getSender();
|
||||
player.world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.dash, SoundCategory.PLAYERS, 1F, 1F);
|
||||
if (ctx.get().getDirection().getReceptionSide().isServer())
|
||||
ctx.get().enqueueWork(() -> {
|
||||
ServerPlayerEntity player = ctx.get().getSender();
|
||||
player.world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.dash, SoundCategory.PLAYERS, 1F, 1F);
|
||||
|
||||
ItemStack ringStack = EquipmentHandler.findOrEmpty(ModItems.dodgeRing, player);
|
||||
if(ringStack.isEmpty()) {
|
||||
player.connection.disconnect(new TranslationTextComponent("botaniamisc.invalidDodge"));
|
||||
return;
|
||||
}
|
||||
ItemStack ringStack = EquipmentHandler.findOrEmpty(ModItems.dodgeRing, player);
|
||||
if (ringStack.isEmpty()) {
|
||||
player.connection.disconnect(new TranslationTextComponent("botaniamisc.invalidDodge"));
|
||||
return;
|
||||
}
|
||||
|
||||
player.addExhaustion(0.3F);
|
||||
ItemNBTHelper.setInt(ringStack, ItemDodgeRing.TAG_DODGE_COOLDOWN, ItemDodgeRing.MAX_CD);
|
||||
});
|
||||
player.addExhaustion(0.3F);
|
||||
ItemNBTHelper.setInt(ringStack, ItemDodgeRing.TAG_DODGE_COOLDOWN, ItemDodgeRing.MAX_CD);
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.fml.network.FMLHandshakeHandler;
|
||||
import net.minecraftforge.fml.network.NetworkDirection;
|
||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
@@ -14,7 +15,7 @@ import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public final class PacketHandler {
|
||||
private static final String PROTOCOL = "2";
|
||||
private static final String PROTOCOL = "3";
|
||||
public static final SimpleChannel HANDLER = NetworkRegistry.newSimpleChannel(
|
||||
new ResourceLocation(LibMisc.MOD_ID, "chan"),
|
||||
() -> PROTOCOL,
|
||||
@@ -31,6 +32,18 @@ public final class PacketHandler {
|
||||
HANDLER.registerMessage(id++, PacketItemAge.class, PacketItemAge::encode, PacketItemAge::decode, PacketItemAge::handle);
|
||||
HANDLER.registerMessage(id++, PacketSyncRecipes.class, PacketSyncRecipes::encode, PacketSyncRecipes::decode, PacketSyncRecipes::handle);
|
||||
HANDLER.registerMessage(id++, PacketIndexKeybindRequest.class, PacketIndexKeybindRequest::encode, PacketIndexKeybindRequest::decode, PacketIndexKeybindRequest::handle);
|
||||
|
||||
HANDLER.messageBuilder(PacketSyncRecipes.Login.class, id++)
|
||||
.loginIndex(ILoginPacket::getLoginIndex, ILoginPacket::setLoginIndex)
|
||||
.encoder(PacketSyncRecipes.Login::encode).decoder(PacketSyncRecipes.Login::decode)
|
||||
.consumer(FMLHandshakeHandler.biConsumerFor((hh, msg, ctx) -> msg.handle(ctx)))
|
||||
.markAsLoginPacket().add();
|
||||
|
||||
HANDLER.messageBuilder(PacketAck.class, id++)
|
||||
.loginIndex(ILoginPacket::getLoginIndex, ILoginPacket::setLoginIndex)
|
||||
.encoder((packet, buf) -> {}).decoder(PacketAck::decode)
|
||||
.consumer(FMLHandshakeHandler.indexFirst((hh, msg, ctx) -> msg.handle(ctx)))
|
||||
.add();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,18 +35,19 @@ public class PacketIndexKeybindRequest {
|
||||
}
|
||||
|
||||
public static void handle(PacketIndexKeybindRequest message, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
ServerPlayerEntity player = ctx.get().getSender();
|
||||
if (player.isSpectator())
|
||||
return;
|
||||
if (ctx.get().getDirection().getReceptionSide().isServer())
|
||||
ctx.get().enqueueWork(() -> {
|
||||
ServerPlayerEntity player = ctx.get().getSender();
|
||||
if (player.isSpectator())
|
||||
return;
|
||||
|
||||
boolean checkNBT = message.stack.getTag() != null && !message.stack.getTag().isEmpty();
|
||||
for (TileCorporeaIndex index : TileCorporeaIndex.InputHandler.getNearbyIndexes(player)) {
|
||||
if (index.getSpark() != null) {
|
||||
index.performPlayerRequest(player, CorporeaHelper.createMatcher(message.stack, checkNBT), message.stack.getCount());
|
||||
boolean checkNBT = message.stack.getTag() != null && !message.stack.getTag().isEmpty();
|
||||
for (TileCorporeaIndex index : TileCorporeaIndex.InputHandler.getNearbyIndexes(player)) {
|
||||
if (index.getSpark() != null) {
|
||||
index.performPlayerRequest(player, CorporeaHelper.createMatcher(message.stack, checkNBT), message.stack.getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -27,12 +27,13 @@ public class PacketItemAge {
|
||||
}
|
||||
|
||||
public static void handle(PacketItemAge message, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
Entity e = Minecraft.getInstance().world.getEntityByID(message.entityId);
|
||||
if(e instanceof ItemEntity) {
|
||||
((ItemEntity) e).age = message.age;
|
||||
}
|
||||
});
|
||||
if (ctx.get().getDirection().getReceptionSide().isClient())
|
||||
ctx.get().enqueueWork(() -> {
|
||||
Entity e = Minecraft.getInstance().world.getEntityByID(message.entityId);
|
||||
if (e instanceof ItemEntity) {
|
||||
((ItemEntity) e).age = message.age;
|
||||
}
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
*
|
||||
* File Created @ [22/10/2016, 18:18:19 (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.network;
|
||||
@@ -28,19 +28,20 @@ public class PacketJump {
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
ServerPlayerEntity player = ctx.get().getSender();
|
||||
if (ctx.get().getDirection().getReceptionSide().isServer())
|
||||
ctx.get().enqueueWork(() -> {
|
||||
ServerPlayerEntity player = ctx.get().getSender();
|
||||
|
||||
ItemStack amuletStack = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemCloudPendant, player);
|
||||
if(!amuletStack.isEmpty()) {
|
||||
player.addExhaustion(0.3F);
|
||||
player.fallDistance = 0;
|
||||
ItemStack amuletStack = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemCloudPendant, player);
|
||||
if (!amuletStack.isEmpty()) {
|
||||
player.addExhaustion(0.3F);
|
||||
player.fallDistance = 0;
|
||||
|
||||
ItemStack belt = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player);
|
||||
if(!belt.isEmpty())
|
||||
player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer * ((ItemCloudPendant) amuletStack.getItem()).getMaxAllowedJumps();
|
||||
}
|
||||
});
|
||||
ItemStack belt = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player);
|
||||
if (!belt.isEmpty())
|
||||
player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer * ((ItemCloudPendant) amuletStack.getItem()).getMaxAllowedJumps();
|
||||
}
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -15,9 +15,8 @@ public class PacketLeftClick {
|
||||
}
|
||||
|
||||
public static void handle(PacketLeftClick msg, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
((ItemTerraSword) ModItems.terraSword).trySpawnBurst(ctx.get().getSender());
|
||||
});
|
||||
if (ctx.get().getDirection().getReceptionSide().isServer())
|
||||
ctx.get().enqueueWork(() -> ((ItemTerraSword) ModItems.terraSword).trySpawnBurst(ctx.get().getSender()));
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package vazkii.botania.common.network;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
@@ -10,6 +12,7 @@ import vazkii.botania.api.recipe.RecipeManaInfusion;
|
||||
import vazkii.botania.api.recipe.RecipePetals;
|
||||
import vazkii.botania.api.recipe.RecipePureDaisy;
|
||||
import vazkii.botania.api.recipe.RecipeRuneAltar;
|
||||
import vazkii.botania.common.Botania;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
@@ -89,14 +92,56 @@ public class PacketSyncRecipes {
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
BotaniaAPI.brewRecipes = brew;
|
||||
BotaniaAPI.elvenTradeRecipes = elven;
|
||||
BotaniaAPI.manaInfusionRecipes = manaInfusion;
|
||||
BotaniaAPI.petalRecipes = petal;
|
||||
BotaniaAPI.pureDaisyRecipes = pureDaisy;
|
||||
BotaniaAPI.runeAltarRecipes = runeAltar;
|
||||
});
|
||||
if(ctx.get().getDirection().getReceptionSide().isClient())
|
||||
ctx.get().enqueueWork(() -> {
|
||||
if(Minecraft.getInstance().isSingleplayer())
|
||||
return;
|
||||
BotaniaAPI.brewRecipes = brew;
|
||||
BotaniaAPI.elvenTradeRecipes = elven;
|
||||
BotaniaAPI.manaInfusionRecipes = manaInfusion;
|
||||
BotaniaAPI.petalRecipes = petal;
|
||||
BotaniaAPI.pureDaisyRecipes = pureDaisy;
|
||||
BotaniaAPI.runeAltarRecipes = runeAltar;
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
|
||||
// The login packet wraps the proper one because directly extending it will cause a freeze on the handshake.
|
||||
public static class Login implements ILoginPacket {
|
||||
private final PacketSyncRecipes wrapped;
|
||||
private int loginIndex;
|
||||
|
||||
public Login() {
|
||||
this(new PacketSyncRecipes(BotaniaAPI.brewRecipes, BotaniaAPI.elvenTradeRecipes,
|
||||
BotaniaAPI.manaInfusionRecipes, BotaniaAPI.petalRecipes,
|
||||
BotaniaAPI.pureDaisyRecipes, BotaniaAPI.runeAltarRecipes));
|
||||
}
|
||||
|
||||
public Login(PacketSyncRecipes packet) {
|
||||
this.wrapped = packet;
|
||||
}
|
||||
|
||||
public static Login decode(PacketBuffer buf) {
|
||||
return new Login(PacketSyncRecipes.decode(buf));
|
||||
}
|
||||
|
||||
public void encode(PacketBuffer buf) {
|
||||
wrapped.encode(buf);
|
||||
}
|
||||
|
||||
public void handle(Supplier<NetworkEvent.Context> ctx) {
|
||||
wrapped.handle(ctx);
|
||||
PacketHandler.HANDLER.reply(new PacketAck(), ctx.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoginIndex(int index) {
|
||||
this.loginIndex = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLoginIndex() {
|
||||
return loginIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,15 +21,16 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.event.LootTableLoadEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
@@ -37,11 +38,12 @@ import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.TileManaFlame;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.core.loot.LootHandler;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.item.equipment.tool.ToolCommons;
|
||||
import vazkii.botania.common.lib.ModTags;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Color;
|
||||
|
||||
public final class SkyblockWorldEvents {
|
||||
|
||||
@@ -125,20 +127,12 @@ public final class SkyblockWorldEvents {
|
||||
}
|
||||
}
|
||||
|
||||
private static final ResourceLocation TARGET_LOOT_TABLE = new ResourceLocation("blocks/grass");
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onDrops(BlockEvent.HarvestDropsEvent event) {
|
||||
if(Botania.gardenOfGlassLoaded && event.getState().getBlock() == Blocks.GRASS) {
|
||||
ItemStack stackToRemove = ItemStack.EMPTY;
|
||||
for(ItemStack stack : event.getDrops())
|
||||
if(stack.getItem() == Items.WHEAT_SEEDS && event.getWorld().getRandom().nextInt(4) == 0) {
|
||||
stackToRemove = stack;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!stackToRemove.isEmpty()) {
|
||||
event.getDrops().remove(stackToRemove);
|
||||
event.getDrops().add(new ItemStack(event.getWorld().getRandom().nextBoolean() ? Items.PUMPKIN_SEEDS : Items.MELON_SEEDS));
|
||||
}
|
||||
public static void loadLoot(LootTableLoadEvent event) {
|
||||
if (Botania.gardenOfGlassLoaded && event.getName().equals(TARGET_LOOT_TABLE)) {
|
||||
event.getTable().addPool(LootHandler.getInjectPool("gog_grass"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,14 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.ModFluffBlocks;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import vazkii.botania.common.lib.ResourceLocationHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static vazkii.botania.common.lib.ResourceLocationHelper.prefix;
|
||||
|
||||
@@ -53,6 +57,13 @@ public class StonecuttingProvider extends RecipeProvider {
|
||||
consumer.accept(stonecutting(ModBlocks.livingrockBrick, ModFluffBlocks.livingrockBrickSlab, 2));
|
||||
consumer.accept(stonecutting(ModBlocks.livingrockBrick, ModFluffBlocks.livingrockBrickStairs));
|
||||
consumer.accept(stonecutting(ModBlocks.livingrockBrick, ModBlocks.livingrockBrickChiseled));
|
||||
|
||||
List<Item> allAzulejos = IntStream.range(0, 16).mapToObj(i -> "azulejo_" + i)
|
||||
.map(ResourceLocationHelper::prefix)
|
||||
.map(ForgeRegistries.ITEMS::getValue).collect(Collectors.toList());
|
||||
for (Item azulejo : allAzulejos) {
|
||||
consumer.accept(azulejoStonecutting(allAzulejos, azulejo));
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerForQuartz(String variant, Consumer<IFinishedRecipe> consumer) {
|
||||
@@ -122,6 +133,11 @@ public class StonecuttingProvider extends RecipeProvider {
|
||||
return new Result(idFor(input, output), IRecipeSerializer.STONECUTTING, Ingredient.fromItems(input), output.asItem(), count);
|
||||
}
|
||||
|
||||
private static IFinishedRecipe azulejoStonecutting(List<? extends IItemProvider> inputs, IItemProvider output) {
|
||||
Ingredient input = Ingredient.fromItems(inputs.stream().filter(obj -> output != obj).toArray(IItemProvider[]::new));
|
||||
return new Result(prefix("stonecutting/" + output.asItem().getRegistryName().getPath()), IRecipeSerializer.STONECUTTING, input, output.asItem(), 1);
|
||||
}
|
||||
|
||||
// Wrapper without advancements
|
||||
public static class Result extends SingleItemRecipeBuilder.Result {
|
||||
public Result(ResourceLocation id, IRecipeSerializer<?> serializer, Ingredient input, Item result, int count) {
|
||||
|
||||
Reference in new issue
Block a user