generated from tilera/1710mod
feat: growing crystals
This commit is contained in:
parent
05dfb876ce
commit
22af5cf660
|
@ -7,7 +7,6 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
|||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
|
@ -75,6 +74,8 @@ public class AuraCore {
|
|||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent ev) {
|
||||
ConfigBlocks.blockCrystal.setTickRandomly(true);
|
||||
Recipes.initRecipes();
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(this, proxy);
|
||||
}
|
||||
|
||||
|
|
25
src/main/java/dev/tilera/auracore/Recipes.java
Normal file
25
src/main/java/dev/tilera/auracore/Recipes.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package dev.tilera.auracore;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
import thaumcraft.common.config.ConfigItems;
|
||||
import thaumcraft.common.config.ConfigResearch;
|
||||
|
||||
public class Recipes {
|
||||
|
||||
public static void initRecipes() {
|
||||
ConfigResearch.recipes.put("Clusters8", shapelessOreDictRecipe(new ItemStack(ConfigBlocks.blockCrystal, 1, 8), new Object[] { new ItemStack(ConfigItems.itemShard, 1, 7), new ItemStack(ConfigItems.itemShard, 1, 7), new ItemStack(ConfigItems.itemShard, 1, 7), new ItemStack(ConfigItems.itemShard, 1, 7), new ItemStack(ConfigItems.itemShard, 1, 7), new ItemStack(ConfigItems.itemShard, 1, 7) }));
|
||||
ConfigResearch.recipes.put("Clusters10", shapelessOreDictRecipe(new ItemStack(ConfigBlocks.blockCrystal, 1, 10), new Object[] { new ItemStack(ConfigItems.itemShard, 1, 9), new ItemStack(ConfigItems.itemShard, 1, 9), new ItemStack(ConfigItems.itemShard, 1, 9), new ItemStack(ConfigItems.itemShard, 1, 9), new ItemStack(ConfigItems.itemShard, 1, 9), new ItemStack(ConfigItems.itemShard, 1, 9) }));
|
||||
ConfigResearch.recipes.put("Clusters9", shapelessOreDictRecipe(new ItemStack(ConfigBlocks.blockCrystal, 1, 9), new Object[] { new ItemStack(ConfigItems.itemShard, 1, 0), new ItemStack(ConfigItems.itemShard, 1, 1), new ItemStack(ConfigItems.itemShard, 1, 2), new ItemStack(ConfigItems.itemShard, 1, 3), new ItemStack(ConfigItems.itemShard, 1, 7) }));
|
||||
}
|
||||
|
||||
static IRecipe shapelessOreDictRecipe(final ItemStack res, final Object[] params) {
|
||||
final IRecipe rec = (IRecipe)new ShapelessOreRecipe(res, params);
|
||||
CraftingManager.getInstance().getRecipeList().add(rec);
|
||||
return rec;
|
||||
}
|
||||
|
||||
}
|
|
@ -24,4 +24,14 @@ public class CrystalColors {
|
|||
}
|
||||
}
|
||||
|
||||
public static int getColorForCrystal(int meta) {
|
||||
if (meta > 10 || meta < 0) {
|
||||
return 0xFFFFFF;
|
||||
} else if (meta > 7) {
|
||||
return colors[meta - 1];
|
||||
} else {
|
||||
return colors[meta + 1];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
30
src/main/java/dev/tilera/auracore/api/ICrystal.java
Normal file
30
src/main/java/dev/tilera/auracore/api/ICrystal.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
package dev.tilera.auracore.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
|
||||
public interface ICrystal {
|
||||
|
||||
public static Map<ChunkCoordinates, Integer> crystalCounts = new HashMap<>();
|
||||
|
||||
/**
|
||||
* @return The amount of crystals in this cluster
|
||||
*/
|
||||
int getCrystalCount(int meta);
|
||||
|
||||
/**
|
||||
* Set the amount of crystals in this cluster.
|
||||
* @param count The new amount of crystals
|
||||
* @return true, if the crystal count was changed
|
||||
*/
|
||||
boolean setCrystalCount(int count);
|
||||
|
||||
/**
|
||||
* Harvest a single shard with a specific tool
|
||||
*/
|
||||
void harvestShard(EntityPlayer player);
|
||||
|
||||
}
|
112
src/main/java/dev/tilera/auracore/mixins/MixinBlockCrystal.java
Normal file
112
src/main/java/dev/tilera/auracore/mixins/MixinBlockCrystal.java
Normal file
|
@ -0,0 +1,112 @@
|
|||
package dev.tilera.auracore.mixins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
import dev.tilera.auracore.api.AuraNode;
|
||||
import dev.tilera.auracore.api.ICrystal;
|
||||
import dev.tilera.auracore.aura.AuraManager;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.common.blocks.BlockCrystal;
|
||||
import thaumcraft.common.config.ConfigItems;
|
||||
import thaumcraft.common.tiles.TileCrystal;
|
||||
import thaumcraft.common.tiles.TileEldritchCrystal;
|
||||
|
||||
@Mixin(BlockCrystal.class)
|
||||
public abstract class MixinBlockCrystal extends BlockContainer {
|
||||
|
||||
protected MixinBlockCrystal(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author tilera
|
||||
* @reason Old crystals
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@Overwrite
|
||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
for(int var4 = 0; var4 <= 6; ++var4) {
|
||||
par3List.add(new ItemStack(par1, 1, var4));
|
||||
}
|
||||
par3List.add(new ItemStack(par1, 1, 8));
|
||||
par3List.add(new ItemStack(par1, 1, 9));
|
||||
par3List.add(new ItemStack(par1, 1, 10));
|
||||
}
|
||||
|
||||
/**
|
||||
* @author tilera
|
||||
* @reason Old crystals
|
||||
*/
|
||||
@Overwrite(remap = false)
|
||||
public TileEntity createTileEntity(World world, int metadata) {
|
||||
if (metadata == 7) {
|
||||
return new TileEldritchCrystal();
|
||||
} else {
|
||||
return new TileCrystal();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author tilera
|
||||
* @reason Drop old crystals
|
||||
*/
|
||||
@Overwrite(remap = false)
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int md, int fortune) {
|
||||
ArrayList<ItemStack> ret = new ArrayList<>();
|
||||
Integer count = ICrystal.crystalCounts.get(new ChunkCoordinates(x, y, z));
|
||||
if (md < 6 && count != null) {
|
||||
for(int t = 0; t < count.intValue(); ++t) {
|
||||
ret.add(new ItemStack(ConfigItems.itemShard, 1, md));
|
||||
}
|
||||
} else if ((md == 8 || md == 10) && count != null) {
|
||||
for(int t = 0; t < count.intValue(); ++t) {
|
||||
ret.add(new ItemStack(ConfigItems.itemShard, 1, md - 1));
|
||||
}
|
||||
} else if (md == 6) {
|
||||
for(int t = 0; t < 6; ++t) {
|
||||
ret.add(new ItemStack(ConfigItems.itemShard, 1, t));
|
||||
}
|
||||
} else if (md == 7) {
|
||||
ret.add(new ItemStack(ConfigItems.itemShard, 1, 6));
|
||||
} else if (md == 9) {
|
||||
for(int t = 0; t < 4; ++t) {
|
||||
ret.add(new ItemStack(ConfigItems.itemShard, 1, t));
|
||||
}
|
||||
ret.add(new ItemStack(ConfigItems.itemShard, 1, 7));
|
||||
} else {
|
||||
return super.getDrops(world, x, y, z, md, fortune);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, int x, int y, int z, Random rand) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (tile instanceof ICrystal) {
|
||||
ICrystal crystal = (ICrystal) tile;
|
||||
if (rand.nextInt(crystal.getCrystalCount(meta) * 75) == 0) {
|
||||
int nodeKey = AuraManager.getClosestAuraWithinRange(world, x, y, z, 64);
|
||||
if (nodeKey < 0) return;
|
||||
AuraNode node = AuraManager.getNode(nodeKey);
|
||||
if (node.level > node.baseLevel - 10) {
|
||||
int crystals = crystal.getCrystalCount(meta);
|
||||
crystal.setCrystalCount(crystals + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package dev.tilera.auracore.mixins;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.common.blocks.BlockCrystalItem;
|
||||
import thaumcraft.common.tiles.TileCrystal;
|
||||
|
||||
@Mixin(BlockCrystalItem.class)
|
||||
public abstract class MixinBlockCrystalItem extends ItemBlock {
|
||||
|
||||
public MixinBlockCrystalItem(Block p_i45328_1_) {
|
||||
super(p_i45328_1_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author tilera
|
||||
* @reason Place old crystals
|
||||
*/
|
||||
@Overwrite(remap = false)
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) {
|
||||
boolean placed = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata);
|
||||
if (placed) {
|
||||
try {
|
||||
TileCrystal ts = (TileCrystal)world.getTileEntity(x, y, z);
|
||||
ts.orientation = (short)side;
|
||||
} catch (Exception var14) {
|
||||
}
|
||||
}
|
||||
|
||||
return placed;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package dev.tilera.auracore.mixins;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import thaumcraft.client.renderers.block.BlockCrystalRenderer;
|
||||
import thaumcraft.client.renderers.block.BlockRenderer;
|
||||
import thaumcraft.common.tiles.TileCrystal;
|
||||
import thaumcraft.common.tiles.TileEldritchCrystal;
|
||||
|
||||
@Mixin(BlockCrystalRenderer.class)
|
||||
public abstract class MixinBlockCrystalRenderer extends BlockRenderer {
|
||||
|
||||
/**
|
||||
* @author tilera
|
||||
* @reason Render old crystals
|
||||
*/
|
||||
@Overwrite(remap = false)
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
||||
if (metadata == 7) {
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileEldritchCrystal(), 0.0D, 0.0D, 0.0D, 0.0F);
|
||||
GL11.glEnable(32826);
|
||||
} else {
|
||||
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
TileCrystal tc = new TileCrystal();
|
||||
tc.blockMetadata = metadata;
|
||||
TileEntityRendererDispatcher.instance.renderTileEntityAt(tc, 0.0D, 0.0D, 0.0D, 0.0F);
|
||||
GL11.glEnable(32826);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -3,15 +3,29 @@ package dev.tilera.auracore.mixins;
|
|||
import java.util.Random;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import dev.tilera.auracore.api.ICrystal;
|
||||
import dev.tilera.auracore.aura.AuraManager;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import thaumcraft.api.TileThaumcraft;
|
||||
import thaumcraft.common.config.ConfigItems;
|
||||
import thaumcraft.common.tiles.TileCrystal;
|
||||
|
||||
@Mixin(TileCrystal.class)
|
||||
public abstract class MixinTileCrystal extends TileThaumcraft {
|
||||
public abstract class MixinTileCrystal extends TileThaumcraft implements ICrystal {
|
||||
|
||||
private long count = System.currentTimeMillis() + (long)new Random().nextInt(300000);
|
||||
@Shadow(remap = false)
|
||||
public short orientation;
|
||||
public int crystals = 6;
|
||||
public int ticks = 0;
|
||||
public boolean isLoaded = false;
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
|
@ -24,8 +38,18 @@ public abstract class MixinTileCrystal extends TileThaumcraft {
|
|||
if (this.worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
if (!isLoaded) {
|
||||
isLoaded = true;
|
||||
ICrystal.crystalCounts.put(new ChunkCoordinates(xCoord, yCoord, zCoord), crystals);
|
||||
}
|
||||
ticks++;
|
||||
int md = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
|
||||
if (md == 7) {
|
||||
if (md == 6) {
|
||||
crystals = 6;
|
||||
} else if (md == 9) {
|
||||
crystals = 5;
|
||||
}
|
||||
if (md == 7 || md == 10 || crystals < 6) {
|
||||
return;
|
||||
}
|
||||
if (this.count <= System.currentTimeMillis()) {
|
||||
|
@ -39,4 +63,60 @@ public abstract class MixinTileCrystal extends TileThaumcraft {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author tilera
|
||||
* @reason Crystal count
|
||||
*/
|
||||
@Overwrite(remap = false)
|
||||
public void readCustomNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readCustomNBT(nbttagcompound);
|
||||
this.orientation = nbttagcompound.getShort("orientation");
|
||||
if (nbttagcompound.hasKey("crystals"));
|
||||
this.crystals = nbttagcompound.getInteger("crystals");
|
||||
ICrystal.crystalCounts.put(new ChunkCoordinates(xCoord, yCoord, zCoord), crystals);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author tilera
|
||||
* @reason Crystal count
|
||||
*/
|
||||
@Overwrite(remap = false)
|
||||
public void writeCustomNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeCustomNBT(nbttagcompound);
|
||||
nbttagcompound.setShort("orientation", this.orientation);
|
||||
nbttagcompound.setInteger("crystals", this.crystals);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCrystalCount(int meta) {
|
||||
if (meta == 6) return 6;
|
||||
if (meta == 9) return 5;
|
||||
return crystals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setCrystalCount(int count) {
|
||||
int md = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
|
||||
if(md == 6 || md == 9 || count > 6 || count < 1) return false;
|
||||
crystals = count;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
ICrystal.crystalCounts.put(new ChunkCoordinates(xCoord, yCoord, zCoord), crystals);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestShard(EntityPlayer player) {
|
||||
if(worldObj.isRemote || !setCrystalCount(crystals - 1)) return;
|
||||
int meta = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
|
||||
if (meta > 7) {
|
||||
meta--;
|
||||
}
|
||||
ItemStack stack = new ItemStack(ConfigItems.itemShard, 1, meta);
|
||||
EntityItem entity = new EntityItem(worldObj, xCoord, yCoord, zCoord, stack);
|
||||
entity.motionX = (player.posX - entity.posX) * 0.1;
|
||||
entity.motionY = (player.posY - entity.posY) * 0.1;
|
||||
entity.motionZ = (player.posZ - entity.posZ) * 0.1;
|
||||
worldObj.spawnEntityInWorld(entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package dev.tilera.auracore.mixins;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import dev.tilera.auracore.api.CrystalColors;
|
||||
import dev.tilera.auracore.api.ICrystal;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import thaumcraft.client.lib.UtilsFX;
|
||||
import thaumcraft.client.renderers.tile.TileCrystalRenderer;
|
||||
import thaumcraft.common.tiles.TileCrystal;
|
||||
|
||||
@Mixin(TileCrystalRenderer.class)
|
||||
public abstract class MixinTileCrystalRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
@Shadow(remap = false)
|
||||
abstract void drawCrystal(int ori, float x, float y, float z, float a1, float a2, Random rand, int color, float size);
|
||||
|
||||
/**
|
||||
* @author tilera
|
||||
* @reason Old crystals
|
||||
*/
|
||||
@Overwrite(remap = false)
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {
|
||||
GL11.glPushMatrix();
|
||||
TileCrystal tco = (TileCrystal)te;
|
||||
int md = tco.getBlockMetadata();
|
||||
int color = CrystalColors.colors[5];
|
||||
if (md != 6) {
|
||||
color = CrystalColors.getColorForCrystal(md);
|
||||
}
|
||||
if (md == 9) {
|
||||
color = CrystalColors.colors[7];
|
||||
}
|
||||
|
||||
UtilsFX.bindTexture("textures/models/crystal.png");
|
||||
Random rand = new Random((long)(tco.getBlockMetadata() + tco.xCoord + tco.yCoord * tco.zCoord));
|
||||
this.drawCrystal(tco.orientation, (float)x, (float)y, (float)z, (rand.nextFloat() - rand.nextFloat()) * 5.0F, (rand.nextFloat() - rand.nextFloat()) * 5.0F, rand, color, 1.1F);
|
||||
|
||||
ICrystal ic = (ICrystal) tco;
|
||||
for(int a = 1; a < ic.getCrystalCount(md); ++a) {
|
||||
if (md == 6 || md == 9) {
|
||||
color = CrystalColors.colors[a == 5 ? 6 : a];
|
||||
}
|
||||
|
||||
int angle1 = rand.nextInt(36) + 72 * a;
|
||||
int angle2 = 15 + rand.nextInt(15);
|
||||
this.drawCrystal(tco.orientation, (float)x, (float)y, (float)z, (float)angle1, (float)angle2, rand, color, 1.0F);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glDisable(3042);
|
||||
}
|
||||
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
"mixins": [
|
||||
"MixinItemShard",
|
||||
"MixinItemEssence",
|
||||
"MixinBlockCrystalItem",
|
||||
"MixinTileCrystal",
|
||||
"MixinTileCrucible",
|
||||
"MixinTileArcaneFurnace",
|
||||
|
@ -14,12 +15,15 @@
|
|||
"MixinBlockCustomPlant",
|
||||
"MixinBlockCustomOre",
|
||||
"MixinBlockTable",
|
||||
"MixinBlockCrystal",
|
||||
"MixinEventHandlerEntity",
|
||||
"MixinThaumcraftWorldGenerator"
|
||||
],
|
||||
"client": [
|
||||
"MixinBlockCustomOreRenderer",
|
||||
"MixinTileArcaneWorkbenchRenderer"
|
||||
"MixinTileArcaneWorkbenchRenderer",
|
||||
"MixinTileCrystalRenderer",
|
||||
"MixinBlockCrystalRenderer"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Reference in a new issue