mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-13 16:54:06 +00:00
Sleevable spreaders!
This commit is contained in:
1 parent
e2c240cf78
commit
bd227a4867
5 files changed
+62
-10
No files matched your search
@@ -13,9 +13,12 @@ package vazkii.botania.client.render.tile;
|
||||
import java.awt.Color;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -39,7 +42,7 @@ public class RenderTileSpreader extends TileEntitySpecialRenderer {
|
||||
private static final ModelSpreader model = new ModelSpreader();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) {
|
||||
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float ticks) {
|
||||
TileSpreader spreader = (TileSpreader) tileentity;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
@@ -55,7 +58,7 @@ public class RenderTileSpreader extends TileEntitySpecialRenderer {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(spreader.isRedstone() ? textureRs : spreader.isDreamwood() ? textureDw : texture);
|
||||
GL11.glScalef(1F, -1F, -1F);
|
||||
|
||||
double time = ClientTickHandler.ticksInGame + f;
|
||||
double time = ClientTickHandler.ticksInGame + ticks;
|
||||
|
||||
if(spreader.isULTRA_SPREADER()) {
|
||||
Color color = Color.getHSBColor((float) ((time * 5 + new Random(spreader.xCoord ^ spreader.yCoord ^ spreader.zCoord).nextInt(10000)) % 360) / 360F, 0.4F, 0.9F);
|
||||
@@ -82,6 +85,34 @@ public class RenderTileSpreader extends TileEntitySpecialRenderer {
|
||||
RenderLens.render(stack, lens.getLensColor(stack));
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
if(spreader.paddingColor != -1) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
||||
|
||||
Block block = Blocks.carpet;
|
||||
int color = spreader.paddingColor;
|
||||
RenderBlocks render = RenderBlocks.getInstance();
|
||||
float f = 1F / 16F;
|
||||
GL11.glTranslatef(0F, -f, 0F);
|
||||
render.renderBlockAsItem(block, color, 1F);
|
||||
GL11.glTranslatef(0F, -f * 15, 0F);
|
||||
render.renderBlockAsItem(block, color, 1F);
|
||||
GL11.glRotatef(90F, 1F, 0F, 0F);
|
||||
GL11.glRotatef(90F, 0F, 1F, 0F);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(f * 14F, 1F, 1F);
|
||||
render.renderBlockAsItem(block, color, 1F);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glRotatef(90F, 1F, 0F, 0F);
|
||||
GL11.glTranslatef(0F, 0F, -f / 2);
|
||||
GL11.glScalef(f * 14F, 1F, f * 15F);
|
||||
render.renderBlockAsItem(block, color, 1F);
|
||||
GL11.glTranslatef(0F, f * 15F, 0F);
|
||||
render.renderBlockAsItem(block, color, 1F);
|
||||
}
|
||||
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -144,6 +145,7 @@ public class BlockSpreader extends BlockModContainer implements IWandable, IWand
|
||||
ItemStack lens = spreader.getStackInSlot(0);
|
||||
ItemStack heldItem = par5EntityPlayer.getCurrentEquippedItem();
|
||||
boolean isHeldItemLens = heldItem != null && heldItem.getItem() instanceof ILens;
|
||||
boolean wool = heldItem != null && heldItem.getItem() == Item.getItemFromBlock(Blocks.wool);
|
||||
|
||||
if(heldItem != null)
|
||||
if(heldItem.getItem() == ModItems.twigWand)
|
||||
@@ -153,7 +155,7 @@ public class BlockSpreader extends BlockModContainer implements IWandable, IWand
|
||||
par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null);
|
||||
spreader.setInventorySlotContents(0, heldItem.copy());
|
||||
spreader.markDirty();
|
||||
} else if(lens != null) {
|
||||
} else if(lens != null && !wool) {
|
||||
ItemStack add = lens.copy();
|
||||
if(!par5EntityPlayer.inventory.addItemStackToInventory(add))
|
||||
par5EntityPlayer.dropPlayerItemWithRandomChoice(add, false);
|
||||
@@ -161,22 +163,35 @@ public class BlockSpreader extends BlockModContainer implements IWandable, IWand
|
||||
spreader.markDirty();
|
||||
}
|
||||
|
||||
if(wool && spreader.paddingColor == -1) {
|
||||
spreader.paddingColor = heldItem.getItemDamage();
|
||||
heldItem.stackSize--;
|
||||
if(heldItem.stackSize == 0)
|
||||
par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null);
|
||||
} else if(heldItem == null && spreader.paddingColor != -1 && lens == null) {
|
||||
ItemStack pad = new ItemStack(Blocks.wool, 1, spreader.paddingColor);
|
||||
if(!par5EntityPlayer.inventory.addItemStackToInventory(pad))
|
||||
par5EntityPlayer.dropPlayerItemWithRandomChoice(pad, false);
|
||||
spreader.paddingColor = -1;
|
||||
spreader.markDirty();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
|
||||
TileEntity tile = par1World.getTileEntity(par2, par3, par4);
|
||||
if(!(tile instanceof TileSimpleInventory))
|
||||
if(!(tile instanceof TileSpreader))
|
||||
return;
|
||||
|
||||
TileSimpleInventory inv = (TileSimpleInventory) tile;
|
||||
TileSpreader inv = (TileSpreader) tile;
|
||||
|
||||
if (inv != null) {
|
||||
for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) {
|
||||
ItemStack itemstack = inv.getStackInSlot(j1);
|
||||
for (int j1 = 0; j1 < inv.getSizeInventory() + 1; ++j1) {
|
||||
ItemStack itemstack = j1 >= inv.getSizeInventory() ? new ItemStack(Blocks.wool, 1, inv.paddingColor) : inv.getStackInSlot(j1);
|
||||
|
||||
if (itemstack != null) {
|
||||
if (itemstack != null && itemstack.getItemDamage() == -1) {
|
||||
float f = random.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = random.nextFloat() * 0.8F + 0.1F;
|
||||
EntityItem entityitem;
|
||||
|
||||
@@ -65,6 +65,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
private static final String TAG_REQUEST_UPDATE = "requestUpdate";
|
||||
private static final String TAG_ROTATION_X = "rotationX";
|
||||
private static final String TAG_ROTATION_Y = "rotationY";
|
||||
private static final String TAG_PADDING_COLOR = "paddingColor";
|
||||
|
||||
private static final String TAG_FORCE_CLIENT_BINDING_X = "forceClientBindingX";
|
||||
private static final String TAG_FORCE_CLIENT_BINDING_Y = "forceClientBindingY";
|
||||
@@ -103,6 +104,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
int mana;
|
||||
int knownMana = -1;
|
||||
public float rotationX, rotationY;
|
||||
public int paddingColor = -1;
|
||||
|
||||
boolean requestsClientUpdate = false;
|
||||
boolean hasReceivedInitialPacket = false;
|
||||
@@ -199,6 +201,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
cmp.setFloat(TAG_ROTATION_X, rotationX);
|
||||
cmp.setFloat(TAG_ROTATION_Y, rotationY);
|
||||
cmp.setBoolean(TAG_REQUEST_UPDATE, requestsClientUpdate);
|
||||
cmp.setInteger(TAG_PADDING_COLOR, paddingColor);
|
||||
|
||||
cmp.setString(TAG_INPUT_KEY, inputKey);
|
||||
cmp.setString(TAG_OUTPUT_KEY, outputKey);
|
||||
@@ -241,6 +244,8 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
|
||||
if(cmp.hasKey(TAG_KNOWN_MANA))
|
||||
knownMana = cmp.getInteger(TAG_KNOWN_MANA);
|
||||
if(cmp.hasKey(TAG_PADDING_COLOR))
|
||||
paddingColor = cmp.getInteger(TAG_PADDING_COLOR);
|
||||
|
||||
if(requestsClientUpdate && worldObj != null) {
|
||||
int x = cmp.getInteger(TAG_FORCE_CLIENT_BINDING_X);
|
||||
@@ -331,7 +336,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
mana -= burst.getStartingMana();
|
||||
worldObj.spawnEntityInWorld(burst);
|
||||
if(!ConfigHandler.silentSpreaders)
|
||||
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:spreaderFire", 0.2F, 0.7F + 0.3F * (float) Math.random());
|
||||
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "botania:spreaderFire", 0.05F * (paddingColor != -1 ? 0.2F : 1F), 0.7F + 0.3F * (float) Math.random());
|
||||
}
|
||||
|
||||
canShootBurst = false;
|
||||
|
||||
@@ -297,7 +297,7 @@ public final class LexiconData {
|
||||
manaIntro.setPriority().setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"));
|
||||
|
||||
spreader = new BLexiconEntry(LibLexicon.MANA_SPREADER, categoryMana);
|
||||
spreader.setPriority().setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_SPREADER), new PageText("2"), new PageText("3"), new PageText("4"), new PageText("11"), new PageCraftingRecipe("5", ModCraftingRecipes.recipesSpreader));
|
||||
spreader.setPriority().setLexiconPages(new PageText("0"), new PageImage("1", LibResources.ENTRY_SPREADER), new PageText("2"), new PageText("3"), new PageText("4"), new PageText("11"), new PageCraftingRecipe("5", ModCraftingRecipes.recipesSpreader), new PageText("10"));
|
||||
|
||||
pool = new BLexiconEntry(LibLexicon.MANA_POOL, categoryMana);
|
||||
pool.setPriority().setLexiconPages(new PageText("0"), new PageText("9"), new PageCraftingRecipe("1", ModCraftingRecipes.recipePool), new PageManaInfusionRecipe("10", ModManaInfusionRecipes.poolRecipe), new PageText("2"), new PageText("8"), new PageManaInfusionRecipe("3", ModManaInfusionRecipes.manasteelRecipes), new PageManaInfusionRecipe("4", ModManaInfusionRecipes.manaPearlRecipe), new PageManaInfusionRecipe("5", ModManaInfusionRecipes.manaDiamondRecipes), new PageManaInfusionRecipe("6", ModManaInfusionRecipes.manaPetalRecipes), new PageManaInfusionRecipe("11", ModManaInfusionRecipes.managlassRecipe), new PageManaInfusionRecipe("12", ModManaInfusionRecipes.manaStringRecipe), new PageManaInfusionRecipe("7", ModManaInfusionRecipes.manaCookieRecipe)).setIcon(new ItemStack(ModBlocks.pool));
|
||||
|
||||
Reference in new issue
Block a user