Misc fixes, including closing #70

This commit is contained in:
Ellpeck 2020-01-25 16:56:04 +01:00
parent ad59eac0cf
commit c59d7e610e
10 changed files with 109 additions and 64 deletions

View file

@ -61,10 +61,6 @@ public final class NaturesAura {
}
};
public static ResourceLocation createRes(String resource) {
return new ResourceLocation(MOD_ID, resource);
}
public void setup(FMLCommonSetupEvent event) {
ModConfig.instance.apply();

View file

@ -9,17 +9,16 @@ import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.registries.ForgeRegistries;
public class AnimalSpawnerRecipe {
public final ResourceLocation name;
public final Ingredient[] ingredients;
public final ResourceLocation entity;
public final EntityType entity;
public final int aura;
public final int time;
public AnimalSpawnerRecipe(ResourceLocation name, ResourceLocation entity, int aura, int time, Ingredient... ingredients) {
public AnimalSpawnerRecipe(ResourceLocation name, EntityType entity, int aura, int time, Ingredient... ingredients) {
this.name = name;
this.ingredients = ingredients;
this.entity = entity;
@ -28,10 +27,7 @@ public class AnimalSpawnerRecipe {
}
public Entity makeEntity(World world, double x, double y, double z) {
EntityType entry = ForgeRegistries.ENTITIES.getValue(this.entity);
if (entry == null)
return null;
Entity entity = entry.create(world);
Entity entity = this.entity.create(world);
if (x == 0 && y == 0 && z == 0)
return entity;
entity.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(world.rand.nextFloat() * 360F), 0F);

View file

@ -126,8 +126,8 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick
this.toRelease -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, this.toRelease);
}
/* PacketHandler.sendToAllLoaded(this.world, this.pos,
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 8));*/
PacketHandler.sendToAllLoaded(this.world, this.pos,
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 8));
}
}
}

View file

@ -1,8 +1,10 @@
package de.ellpeck.naturesaura.blocks.tiles.render;
import com.mojang.blaze3d.platform.GLX;
import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityProjectileGenerator;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.model.RendererModel;
import net.minecraft.client.renderer.model.Model;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
@ -19,6 +21,10 @@ public class RenderProjectileGenerator extends TileEntityRenderer<TileEntityProj
@Override
public void render(TileEntityProjectileGenerator te, double x, double y, double z, float partialTicks, int destroyStage) {
GlStateManager.pushMatrix();
GlStateManager.enableAlphaTest();
GlStateManager.enableBlend();
GlStateManager.alphaFunc(516, 0.003921569F);
GlStateManager.depthMask(false);
GlStateManager.translated(x, y, z);
if (te.nextSide == Direction.NORTH) {
GlStateManager.rotatef(270, 0, 1, 0);
@ -33,7 +39,15 @@ public class RenderProjectileGenerator extends TileEntityRenderer<TileEntityProj
GlStateManager.translatef(-0.001F, 0, 0);
}
this.bindTexture(RES);
int brightness = 15 << 20 | 15 << 4;
int j = brightness % 65536;
int k = brightness / 65536;
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, (float) j, (float) k);
this.model.render();
GlStateManager.depthMask(true);
GlStateManager.alphaFunc(516, 0.1F);
GlStateManager.disableAlphaTest();
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}

View file

@ -1,6 +1,8 @@
package de.ellpeck.naturesaura.compat.jei;
import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.platform.GLX;
import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
import mezz.jei.api.constants.VanillaTypes;
@ -10,19 +12,24 @@ 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.client.Minecraft;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SpawnEggItem;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecipe> {
private final IDrawable background;
private final Map<EntityType, Entity> entityCache = new HashMap<>();
public AnimalSpawnerCategory(IGuiHelper helper) {
this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/jei/animal_spawner.png"), 0, 0, 72, 86);
@ -59,9 +66,7 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecip
for (Ingredient ing : animalSpawnerRecipe.ingredients)
builder.add(ing.getMatchingStacks());
iIngredients.setInputs(VanillaTypes.ITEM, builder.build());
EntityType entry = ForgeRegistries.ENTITIES.getValue(animalSpawnerRecipe.entity);
iIngredients.setOutput(VanillaTypes.ITEM, new ItemStack(SpawnEggItem.getEgg(entry)));
iIngredients.setOutput(VanillaTypes.ITEM, new ItemStack(SpawnEggItem.getEgg(animalSpawnerRecipe.entity)));
}
@Override
@ -72,4 +77,41 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecip
group.set(i, Arrays.asList(recipe.ingredients[i].getMatchingStacks()));
}
}
@Override
public void draw(AnimalSpawnerRecipe recipe, double mouseX, double mouseY) {
Minecraft minecraft = Minecraft.getInstance();
Entity entity = this.entityCache.get(recipe.entity);
if(entity == null){
entity = recipe.makeEntity(minecraft.world,0,0,0);
this.entityCache.put(recipe.entity,entity);
}
float size = Math.max(1F, Math.max(recipe.entity.getWidth(), recipe.entity.getHeight()));
float rot = (minecraft.world.getGameTime() + minecraft.getRenderPartialTicks()) % 360F;
renderEntity(entity, 35, 28, rot, 100F / size * 0.4F, size * 0.5F);
String name = recipe.entity.getName().getFormattedText();
minecraft.fontRenderer.drawStringWithShadow(name, 36 - minecraft.fontRenderer.getStringWidth(name) / 2F, 55, 0xFFFFFF);
}
private static void renderEntity(Entity entity, float x, float y, float rotation, float renderScale, float offset) {
GlStateManager.enableColorMaterial();
GlStateManager.pushMatrix();
GlStateManager.color3f(1F, 1F, 1F);
GlStateManager.translatef(x, y, 50.0F);
GlStateManager.scalef(-renderScale, renderScale, renderScale);
GlStateManager.translatef(0F, offset, 0F);
GlStateManager.rotatef(180.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotatef(rotation, 0.0F, 1.0F, 0.0F);
RenderHelper.enableStandardItemLighting();
Minecraft.getInstance().getRenderManager().playerViewY = 180.0F;
Minecraft.getInstance().getRenderManager().renderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
GlStateManager.popMatrix();
RenderHelper.disableStandardItemLighting();
GlStateManager.disableRescaleNormal();
GlStateManager.activeTexture(GLX.GL_TEXTURE1);
GlStateManager.disableTexture();
GlStateManager.activeTexture(GLX.GL_TEXTURE0);
}
}

View file

@ -2,11 +2,8 @@ package de.ellpeck.naturesaura.compat.patchouli;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.EntityType;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SpawnEggItem;
import net.minecraftforge.registries.ForgeRegistries;
import vazkii.patchouli.api.IComponentProcessor;
import vazkii.patchouli.api.IVariableProvider;
import vazkii.patchouli.api.PatchouliAPI;
@ -31,14 +28,13 @@ public class ProcessorAnimalSpawner implements IComponentProcessor {
else
return null;
} else {
EntityType entry = ForgeRegistries.ENTITIES.getValue(this.recipe.entity);
switch (key) {
case "name":
return I18n.format("entity." + entry.getName() + ".name");
return this.recipe.entity.getName().getFormattedText();
case "entity":
return this.recipe.entity.toString();
return this.recipe.entity.getRegistryName().toString();
case "egg":
ItemStack egg = new ItemStack(SpawnEggItem.getEgg(entry));
ItemStack egg = new ItemStack(SpawnEggItem.getEgg(this.recipe.entity));
return PatchouliAPI.instance.serializeItemStack(egg);
default:
return null;

View file

@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.packet;
import de.ellpeck.naturesaura.NaturesAura;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
@ -16,7 +17,7 @@ public final class PacketHandler {
private static SimpleChannel network;
public static void init() {
network = NetworkRegistry.newSimpleChannel(NaturesAura.createRes("network"), () -> VERSION, VERSION::equals, VERSION::equals);
network = NetworkRegistry.newSimpleChannel(new ResourceLocation(NaturesAura.MOD_ID, "network"), () -> VERSION, VERSION::equals, VERSION::equals);
network.registerMessage(0, PacketParticleStream.class, PacketParticleStream::toBytes, PacketParticleStream::fromBytes, PacketParticleStream::onMessage);
network.registerMessage(1, PacketParticles.class, PacketParticles::toBytes, PacketParticles::fromBytes, PacketParticles::onMessage);
network.registerMessage(2, PacketAuraChunk.class, PacketAuraChunk::toBytes, PacketAuraChunk::fromBytes, PacketAuraChunk::onMessage);

View file

@ -223,9 +223,8 @@ public final class ModRecipes {
if (block instanceof FlowerBlock)
NaturesAuraAPI.FLOWERS.addAll(block.getStateContainer().getValidStates());
spawner("cow", "minecraft:cow", 50000, 60, ing(Items.BEEF), ing(Items.LEATHER));
for (DyeColor color : DyeColor.values())
new AnimalSpawnerRecipe(res("sheep_" + color.getName()), new ResourceLocation("minecraft:sheep"),
new AnimalSpawnerRecipe(res("sheep_" + color.getName()), EntityType.SHEEP,
500, 60, ing(ModItems.BIRTH_SPIRIT), ing(Items.MUTTON),
ing(Helper.getWool(color))) {
@Override
@ -235,39 +234,40 @@ public final class ModRecipes {
return sheep;
}
}.register();
spawner("chicken", "minecraft:chicken", 30000, 40, ing(Items.FEATHER), ing(Items.EGG));
spawner("pig", "minecraft:pig", 50000, 60, ing(Items.PORKCHOP));
spawner("blaze", "minecraft:blaze", 150000, 120, ing(Items.BLAZE_ROD), ing(Items.BLAZE_POWDER));
spawner("ghast", "minecraft:ghast", 120000, 150, ing(Items.GUNPOWDER), ing(Items.GHAST_TEAR));
spawner("ocelot", "minecraft:ocelot", 80000, 60, ing(Items.COD), ing(ItemTags.WOOL));
spawner("mule", "minecraft:mule", 100000, 100, ing(Items.LEATHER), ing(Blocks.CHEST), ing(Items.APPLE));
spawner("bat", "minecraft:bat", 30000, 40, ing(Items.FEATHER));
spawner("endermite", "minecraft:endermite", 30000, 40, ing(Items.ENDER_PEARL), ing(Blocks.STONE));
spawner("parrot", "minecraft:parrot", 50000, 60, ing(Items.FEATHER), ing(Items.COOKIE));
spawner("slime", "minecraft:slime", 30000, 40, ing(Items.SLIME_BALL));
spawner("spider", "minecraft:spider", 100000, 120, ing(Items.STRING), ing(Items.SPIDER_EYE));
spawner("skeleton", "minecraft:skeleton", 100000, 120, ing(Items.BONE), ing(Items.ARROW));
spawner("enderman", "minecraft:enderman", 120000, 120, ing(Items.ENDER_PEARL));
spawner("silverfish", "minecraft:silverfish", 30000, 40, ing(Blocks.STONE));
spawner("squid", "minecraft:squid", 50000, 40, ing(Items.INK_SAC));
spawner("stray", "minecraft:stray", 100000, 120, ing(Items.BONE), ing(Blocks.ICE));
spawner("shulker", "minecraft:shulker", 150000, 100, ing(Items.SHULKER_SHELL));
spawner("husk", "minecraft:husk", 100000, 120, ing(Items.ROTTEN_FLESH), ing(Blocks.SAND));
spawner("llama", "minecraft:llama", 60000, 80, ing(ItemTags.WOOL));
spawner("rabbit", "minecraft:rabbit", 30000, 40, ing(Items.RABBIT_HIDE));
spawner("magma_cube", "minecraft:magma_cube", 100000, 100, ing(Items.MAGMA_CREAM));
spawner("zombie_pigman", "minecraft:zombie_pigman", 120000, 150, ing(Items.ROTTEN_FLESH), ing(Items.GOLD_NUGGET));
spawner("polar_bear", "minecraft:polar_bear", 50000, 60, ing(Items.COD), ing(Blocks.ICE));
spawner("mooshroom", "minecraft:mooshroom", 40000, 60, ing(Items.LEATHER), ing(Blocks.RED_MUSHROOM));
spawner("guardian", "minecraft:guardian", 150000, 150, ing(Items.PRISMARINE_SHARD), ing(Items.PRISMARINE_CRYSTALS));
spawner("horse", "minecraft:horse", 100000, 100, ing(Items.LEATHER));
spawner("donkey", "minecraft:donkey", 100000, 100, ing(Items.LEATHER), ing(Blocks.CHEST));
spawner("cave_spider", "minecraft:cave_spider", 100000, 120, ing(Items.STRING), ing(Items.FERMENTED_SPIDER_EYE));
spawner("creeper", "minecraft:creeper", 100000, 120, ing(Items.GUNPOWDER));
spawner("witch", "minecraft:witch", 150000, 150, ing(Items.GLASS_BOTTLE), ing(Items.GLOWSTONE_DUST));
spawner("wither_skeleton", "minecraft:wither_skeleton", 150000, 150, ing(Items.BONE), ing(Blocks.OBSIDIAN));
spawner("wolf", "minecraft:wolf", 50000, 60, ing(Items.LEATHER), ing(Items.BONE));
spawner("zombie", "minecraft:zombie", 100000, 100, ing(Items.ROTTEN_FLESH));
spawner("cow", EntityType.COW, 50000, 60, ing(Items.BEEF), ing(Items.LEATHER));
spawner("chicken", EntityType.CHICKEN, 30000, 40, ing(Items.FEATHER), ing(Items.EGG));
spawner("pig", EntityType.PIG, 50000, 60, ing(Items.PORKCHOP));
spawner("blaze", EntityType.BLAZE, 150000, 120, ing(Items.BLAZE_ROD), ing(Items.BLAZE_POWDER));
spawner("ghast", EntityType.GHAST, 120000, 150, ing(Items.GUNPOWDER), ing(Items.GHAST_TEAR));
spawner("ocelot", EntityType.OCELOT, 80000, 60, ing(Items.COD), ing(ItemTags.WOOL));
spawner("mule", EntityType.MULE, 100000, 100, ing(Items.LEATHER), ing(Blocks.CHEST), ing(Items.APPLE));
spawner("bat", EntityType.BAT, 30000, 40, ing(Items.FEATHER));
spawner("endermite", EntityType.ENDERMITE, 30000, 40, ing(Items.ENDER_PEARL), ing(Blocks.STONE));
spawner("parrot", EntityType.PARROT, 50000, 60, ing(Items.FEATHER), ing(Items.COOKIE));
spawner("slime", EntityType.SLIME, 30000, 40, ing(Items.SLIME_BALL));
spawner("spider", EntityType.SPIDER, 100000, 120, ing(Items.STRING), ing(Items.SPIDER_EYE));
spawner("skeleton", EntityType.SKELETON, 100000, 120, ing(Items.BONE), ing(Items.ARROW));
spawner("enderman", EntityType.ENDERMAN, 120000, 120, ing(Items.ENDER_PEARL));
spawner("silverfish", EntityType.SILVERFISH, 30000, 40, ing(Blocks.STONE));
spawner("squid", EntityType.SQUID, 50000, 40, ing(Items.INK_SAC));
spawner("stray", EntityType.STRAY, 100000, 120, ing(Items.BONE), ing(Blocks.ICE));
spawner("shulker", EntityType.SHULKER, 150000, 100, ing(Items.SHULKER_SHELL));
spawner("husk", EntityType.HUSK, 100000, 120, ing(Items.ROTTEN_FLESH), ing(Blocks.SAND));
spawner("llama", EntityType.LLAMA, 60000, 80, ing(ItemTags.WOOL));
spawner("rabbit", EntityType.RABBIT, 30000, 40, ing(Items.RABBIT_HIDE));
spawner("magma_cube", EntityType.MAGMA_CUBE, 100000, 100, ing(Items.MAGMA_CREAM));
spawner("zombie_pigman", EntityType.ZOMBIE_PIGMAN, 120000, 150, ing(Items.ROTTEN_FLESH), ing(Items.GOLD_NUGGET));
spawner("polar_bear", EntityType.POLAR_BEAR, 50000, 60, ing(Items.COD), ing(Blocks.ICE));
spawner("mooshroom", EntityType.MOOSHROOM, 40000, 60, ing(Items.LEATHER), ing(Blocks.RED_MUSHROOM));
spawner("guardian", EntityType.GUARDIAN, 150000, 150, ing(Items.PRISMARINE_SHARD), ing(Items.PRISMARINE_CRYSTALS));
spawner("horse", EntityType.HORSE, 100000, 100, ing(Items.LEATHER));
spawner("donkey", EntityType.DONKEY, 100000, 100, ing(Items.LEATHER), ing(Blocks.CHEST));
spawner("cave_spider", EntityType.CAVE_SPIDER, 100000, 120, ing(Items.STRING), ing(Items.FERMENTED_SPIDER_EYE));
spawner("creeper", EntityType.CREEPER, 100000, 120, ing(Items.GUNPOWDER));
spawner("witch", EntityType.WITCH, 150000, 150, ing(Items.GLASS_BOTTLE), ing(Items.GLOWSTONE_DUST));
spawner("wither_skeleton", EntityType.WITHER_SKELETON, 150000, 150, ing(Items.BONE), ing(Blocks.OBSIDIAN));
spawner("wolf", EntityType.WOLF, 50000, 60, ing(Items.LEATHER), ing(Items.BONE));
spawner("zombie", EntityType.ZOMBIE, 100000, 100, ing(Items.ROTTEN_FLESH));
NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre(Tags.Blocks.ORES_COAL, 5000));
NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre(Tags.Blocks.ORES_IRON, 3000));
@ -336,11 +336,11 @@ public final class ModRecipes {
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(EntityType.TRIDENT, 3000000);
}
private static void spawner(String name, String entity, int aura, int time, Ingredient... ings) {
private static void spawner(String name, EntityType entity, int aura, int time, Ingredient... ings) {
Ingredient[] actualIngs = new Ingredient[ings.length + 1];
actualIngs[0] = ing(ModItems.BIRTH_SPIRIT);
System.arraycopy(ings, 0, actualIngs, 1, ings.length);
new AnimalSpawnerRecipe(res(name), new ResourceLocation(entity), aura, time, actualIngs).register();
new AnimalSpawnerRecipe(res(name), entity, aura, time, actualIngs).register();
}
private static Ingredient ing(Block... blocks) {

View file

@ -1,6 +1,6 @@
{
"name": "Breathlessness",
"icon": "minecraft:wool",
"icon": "minecraft:white_wool",
"category": "effects",
"advancement": "naturesaura:negative_imbalance",
"pages": [

View file

@ -1,6 +1,6 @@
{
"name": "Magical Botany",
"icon": "minecraft:sapling",
"icon": "minecraft:oak_sapling",
"category": "intro",
"pages": [
{