Merge branch 'master' into improvedfloaters

This commit is contained in:
Vincent Lee committed 2016-08-15 15:55:50 -05:00
commit 789832bdc1
126 files changed
+1147 -1171

No files matched your search

@@ -495,16 +495,26 @@ public final class BotaniaAPI {
/**
* Registers a Elven Trade recipe (throw an item in an Alfheim Portal).
* @param output The ItemStack to return.
* @param outputs The ItemStacks to return.
* @param inputs The items required, can be ItemStack or ore dictionary entry string.
* @return The recipe created.
*/
public static RecipeElvenTrade registerElvenTradeRecipe(ItemStack output, Object... inputs) {
RecipeElvenTrade recipe = new RecipeElvenTrade(output, inputs);
public static RecipeElvenTrade registerElvenTradeRecipe(ItemStack[] outputs, Object... inputs) {
RecipeElvenTrade recipe = new RecipeElvenTrade(outputs, inputs);
elvenTradeRecipes.add(recipe);
return recipe;
}
/**
* Registers a Elven Trade recipe (throw an item into an Alfeim Portal).
* @param output The ItemStack to return
* @param inputs The items required, can be an ItemStack or an Ore Dictionary entry string.
* @return The recipe created.
*/
public static RecipeElvenTrade registerElvenTradeRecipe(ItemStack output, Object... inputs) {
return registerElvenTradeRecipe(new ItemStack[]{ output }, inputs);
}
/**
* Registers a Brew Recipe (for the Botanical Brewery).
* @param brew The brew in to be set in this recipe.
@@ -10,6 +10,7 @@
*/
package vazkii.botania.api.internal;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
@@ -21,23 +22,8 @@ import net.minecraft.world.WorldServer;
public final class VanillaPacketDispatcher {
public static void dispatchTEToNearbyPlayers(TileEntity tile) {
if(tile.getWorld() instanceof WorldServer) {
WorldServer ws = ((WorldServer) tile.getWorld());
SPacketUpdateTileEntity packet = tile.getUpdatePacket();
if(packet == null)
return;
for (EntityPlayer player : ws.playerEntities) {
EntityPlayerMP playerMP = ((EntityPlayerMP) player);
if (playerMP.getDistanceSq(tile.getPos()) < 64 * 64
&& ws.getPlayerChunkMap().isPlayerWatchingChunk(playerMP, tile.getPos().getX() >> 4, tile.getPos().getZ() >> 4)) {
playerMP.connection.sendPacket(packet);
}
}
}
IBlockState state = tile.getWorld().getBlockState(tile.getPos());
tile.getWorld().notifyBlockUpdate(tile.getPos(), state, state, 8);
}
public static void dispatchTEToNearbyPlayers(World world, BlockPos pos) {
@@ -9,11 +9,11 @@ import java.util.List;
public class RecipeElvenTrade {
private final ItemStack output;
private final ImmutableList<ItemStack> outputs;
private final ImmutableList<Object> inputs;
public RecipeElvenTrade(ItemStack output, Object... inputs) {
this.output = output;
public RecipeElvenTrade(ItemStack[] outputs, Object... inputs) {
this.outputs = ImmutableList.copyOf(outputs);
ImmutableList.Builder<Object> inputsToSet = ImmutableList.builder();
for(Object obj : inputs) {
@@ -88,8 +88,8 @@ public class RecipeElvenTrade {
return inputs;
}
public ItemStack getOutput() {
return output;
public List<ItemStack> getOutputs() {
return outputs;
}
}
@@ -14,6 +14,8 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
/**
* Any block that implements this has a HUD rendered when being hovered
@@ -21,6 +23,7 @@ import net.minecraft.world.World;
*/
public interface IWandHUD {
@SideOnly(Side.CLIENT)
public void renderHUD(Minecraft mc, ScaledResolution res, World world, BlockPos pos);
}
@@ -50,7 +50,6 @@ public final class ClientTickHandler {
if(event.phase == Phase.START)
partialTicks = event.renderTickTime;
else {
TooltipAdditionDisplayHandler.render();
calcDelta();
}
}
@@ -84,8 +84,12 @@ public final class DebugHandler {
state = state.getActualState(world, pos);
state = state.getBlock().getExtendedState(state, world, pos);
if (state instanceof IExtendedBlockState) {
for (Map.Entry<IUnlistedProperty<?>, Optional<?>> e : ((IExtendedBlockState) state).getUnlistedProperties().entrySet()) {
event.getRight().add(e.getKey().getName() + ": " + e.getValue().orNull());
try {
for (Map.Entry<IUnlistedProperty<?>, Optional<?>> e : ((IExtendedBlockState) state).getUnlistedProperties().entrySet()) {
event.getRight().add(TextFormatting.LIGHT_PURPLE + e.getKey().getName() + ": " + TextFormatting.RESET + e.getValue().orNull());
}
} catch (Throwable t) {
event.getRight().add("Error getting extended state");
}
}
}
@@ -10,6 +10,7 @@ package vazkii.botania.client.core.handler;
import com.google.common.collect.Maps;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
@@ -24,6 +25,7 @@ import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.client.model.FloatingFlowerModel;
import vazkii.botania.client.model.GunModel;
import vazkii.botania.client.model.LexiconModel;
import vazkii.botania.client.model.PlatformModel;
import vazkii.botania.common.Botania;
@@ -97,6 +99,15 @@ public class MiscellaneousIcons {
// Lexicon
evt.getModelRegistry().putObject(new ModelResourceLocation("botania:lexicon", "inventory"), new LexiconModel());
// Mana Blaster
ModelResourceLocation key = new ModelResourceLocation("botania:manaGun", "inventory");
IBakedModel originalModel = evt.getModelRegistry().getObject(key);
evt.getModelRegistry().putObject(key, new GunModel(originalModel));
key = new ModelResourceLocation("botania:manaGunClip", "inventory");
originalModel = evt.getModelRegistry().getObject(key);
evt.getModelRegistry().putObject(key, new GunModel(originalModel));
}
@SubscribeEvent
@@ -25,6 +25,8 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.client.event.RenderTooltipEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -47,133 +49,105 @@ public final class TooltipAdditionDisplayHandler {
private static float lexiconLookupTime = 0F;
public static void render() {
@SubscribeEvent
public static void onToolTipRender(RenderTooltipEvent.PostText evt) {
if(evt.getStack() == null)
return;
ItemStack stack = evt.getStack();
Minecraft mc = Minecraft.getMinecraft();
GuiScreen gui = mc.currentScreen;
if(gui != null && gui instanceof GuiContainer && mc.thePlayer != null && mc.thePlayer.inventory.getItemStack() == null) {
GuiContainer container = (GuiContainer) gui;
Slot slot = container.getSlotUnderMouse();
if(slot != null && slot.getHasStack()) {
ItemStack stack = slot.getStack();
if(stack != null) {
ScaledResolution res = new ScaledResolution(mc);
FontRenderer font = mc.fontRendererObj;
int mouseX = Mouse.getX() * res.getScaledWidth() / mc.displayWidth;
int mouseY = res.getScaledHeight() - Mouse.getY() * res.getScaledHeight() / mc.displayHeight;
int width = evt.getWidth();
int height = 3;
int tooltipX = evt.getX();
int tooltipY = evt.getY() - 4;
FontRenderer font = evt.getFontRenderer();
List<String> tooltip;
try {
tooltip = stack.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips);
} catch(Exception e) {
tooltip = new ArrayList<>();
if(stack.getItem() instanceof ItemTerraPick)
drawTerraPick(stack, tooltipX, tooltipY, width, height, font);
else if(stack.getItem() instanceof IManaTooltipDisplay)
drawManaBar(stack, (IManaTooltipDisplay) stack.getItem(), tooltipX, tooltipY, width, height);
EntryData data = LexiconRecipeMappings.getDataForStack(stack);
if(data != null) {
int lexSlot = -1;
ItemStack lexiconStack = null;
for(int i = 0; i < InventoryPlayer.getHotbarSize(); i++) {
ItemStack stackAt = mc.thePlayer.inventory.getStackInSlot(i);
if(stackAt != null && stackAt.getItem() instanceof ILexicon && ((ILexicon) stackAt.getItem()).isKnowledgeUnlocked(stackAt, data.entry.getKnowledgeType())) {
lexiconStack = stackAt;
lexSlot = i;
break;
}
}
if(lexSlot > -1) {
int x = tooltipX - 34;
GlStateManager.disableDepth();
Gui.drawRect(x - 4, tooltipY - 4, x + 20, tooltipY + 26, 0x44000000);
Gui.drawRect(x - 6, tooltipY - 6, x + 22, tooltipY + 28, 0x44000000);
if(ConfigHandler.useShiftForQuickLookup ? GuiScreen.isShiftKeyDown() : GuiScreen.isCtrlKeyDown()) {
lexiconLookupTime += ClientTickHandler.delta;
int cx = x + 8;
int cy = tooltipY + 8;
float r = 12;
float time = 20F;
float angles = lexiconLookupTime / time * 360F;
GlStateManager.disableLighting();
GlStateManager.disableTexture2D();
GlStateManager.shadeModel(GL11.GL_SMOOTH);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
VertexBuffer buf = Tessellator.getInstance().getBuffer();
buf.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
float a = 0.5F + 0.2F * ((float) Math.cos((double) (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) / 10) * 0.5F + 0.5F);
buf.pos(cx, cy, 0).color(0F, 0.5F, 0F, a).endVertex();
for(float i = angles; i > 0; i--) {
double rad = (i - 90) / 180F * Math.PI;
buf.pos(cx + Math.cos(rad) * r, cy + Math.sin(rad) * r, 0).color(0F, 1F, 0F, 1F).endVertex();
}
int width = 0;
for(String s : tooltip)
width = Math.max(width, font.getStringWidth(s) + 2);
int tooltipHeight = (tooltip.size() - 1) * 10 + 5;
int height = 3;
int offx = 11;
int offy = 17;
buf.pos(cx, cy, 0).color(0F, 1F, 0F, 0F).endVertex();
Tessellator.getInstance().draw();
boolean offscreen = mouseX + width + 19 >= res.getScaledWidth();
GlStateManager.disableBlend();
GlStateManager.enableTexture2D();
GlStateManager.shadeModel(GL11.GL_FLAT);
int fixY = res.getScaledHeight() - (mouseY + tooltipHeight);
if(fixY < 0)
offy -= fixY;
if(offscreen)
offx = -13 - width;
if(lexiconLookupTime >= time) {
mc.thePlayer.inventory.currentItem = lexSlot;
Botania.proxy.setEntryToOpen(data.entry);
Botania.proxy.setLexiconStack(lexiconStack);
mc.thePlayer.closeScreen();
ItemLexicon.openBook(mc.thePlayer, lexiconStack, mc.theWorld, false);
if(stack.getItem() instanceof ItemTerraPick)
drawTerraPick(stack, mouseX, mouseY, offx, offy, width, height, font);
else if(stack.getItem() instanceof IManaTooltipDisplay)
drawManaBar(stack, (IManaTooltipDisplay) stack.getItem(), mouseX, mouseY, offx, offy, width, height);
EntryData data = LexiconRecipeMappings.getDataForStack(stack);
if(data != null) {
int lexSlot = -1;
ItemStack lexiconStack = null;
for(int i = 0; i < InventoryPlayer.getHotbarSize(); i++) {
ItemStack stackAt = mc.thePlayer.inventory.getStackInSlot(i);
if(stackAt != null && stackAt.getItem() instanceof ILexicon && ((ILexicon) stackAt.getItem()).isKnowledgeUnlocked(stackAt, data.entry.getKnowledgeType())) {
lexiconStack = stackAt;
lexSlot = i;
break;
}
}
if(lexSlot > -1) {
int x = mouseX + offx - 34;
int y = mouseY - offy;
GlStateManager.disableDepth();
Gui.drawRect(x - 4, y - 4, x + 20, y + 26, 0x44000000);
Gui.drawRect(x - 6, y - 6, x + 22, y + 28, 0x44000000);
if(ConfigHandler.useShiftForQuickLookup ? GuiScreen.isShiftKeyDown() : GuiScreen.isCtrlKeyDown()) {
lexiconLookupTime += ClientTickHandler.delta;
int cx = x + 8;
int cy = y + 8;
float r = 12;
float time = 20F;
float angles = lexiconLookupTime / time * 360F;
GlStateManager.disableLighting();
GlStateManager.disableTexture2D();
GlStateManager.shadeModel(GL11.GL_SMOOTH);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
VertexBuffer buf = Tessellator.getInstance().getBuffer();
buf.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
float a = 0.5F + 0.2F * ((float) Math.cos((double) (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) / 10) * 0.5F + 0.5F);
buf.pos(cx, cy, 0).color(0F, 0.5F, 0F, a).endVertex();
for(float i = angles; i > 0; i--) {
double rad = (i - 90) / 180F * Math.PI;
buf.pos(cx + Math.cos(rad) * r, cy + Math.sin(rad) * r, 0).color(0F, 1F, 0F, 1F).endVertex();
}
buf.pos(cx, cy, 0).color(0F, 1F, 0F, 0F).endVertex();
Tessellator.getInstance().draw();
GlStateManager.disableBlend();
GlStateManager.enableTexture2D();
GlStateManager.shadeModel(GL11.GL_FLAT);
if(lexiconLookupTime >= time) {
mc.thePlayer.inventory.currentItem = lexSlot;
Botania.proxy.setEntryToOpen(data.entry);
Botania.proxy.setLexiconStack(lexiconStack);
mc.thePlayer.closeScreen();
ItemLexicon.openBook(mc.thePlayer, lexiconStack, mc.theWorld, false);
}
} else lexiconLookupTime = 0F;
mc.getRenderItem().renderItemIntoGUI(new ItemStack(ModItems.lexicon), x, y);
GlStateManager.disableLighting();
font.drawStringWithShadow("?", x + 10, y + 8, 0xFFFFFFFF);
GlStateManager.scale(0.5F, 0.5F, 1F);
boolean mac = Minecraft.IS_RUNNING_ON_MAC;
mc.fontRendererObj.drawStringWithShadow(TextFormatting.BOLD + (ConfigHandler.useShiftForQuickLookup ? "Shift" : mac ? "Cmd" : "Ctrl"), (x + 10) * 2 - 16, (y + 8) * 2 + 20, 0xFFFFFFFF);
GlStateManager.scale(2F, 2F, 1F);
GlStateManager.enableDepth();
} else lexiconLookupTime = 0F;
} else lexiconLookupTime = 0F;
}
} else lexiconLookupTime = 0F;
mc.getRenderItem().renderItemIntoGUI(new ItemStack(ModItems.lexicon), x, tooltipY);
GlStateManager.disableLighting();
font.drawStringWithShadow("?", x + 10, tooltipY + 8, 0xFFFFFFFF);
GlStateManager.scale(0.5F, 0.5F, 1F);
boolean mac = Minecraft.IS_RUNNING_ON_MAC;
mc.fontRendererObj.drawStringWithShadow(TextFormatting.BOLD + (ConfigHandler.useShiftForQuickLookup ? "Shift" : mac ? "Cmd" : "Ctrl"), (x + 10) * 2 - 16, (tooltipY + 8) * 2 + 20, 0xFFFFFFFF);
GlStateManager.scale(2F, 2F, 1F);
GlStateManager.enableDepth();
} else lexiconLookupTime = 0F;
} else lexiconLookupTime = 0F;
}
private static void drawTerraPick(ItemStack stack, int mouseX, int mouseY, int offx, int offy, int width, int height, FontRenderer font) {
private static void drawTerraPick(ItemStack stack, int mouseX, int mouseY, int width, int height, FontRenderer font) {
int level = ItemTerraPick.getLevel(stack);
int max = ItemTerraPick.LEVELS[Math.min(ItemTerraPick.LEVELS.length - 1, level + 1)];
boolean ss = level >= ItemTerraPick.LEVELS.length - 1;
@@ -184,33 +158,33 @@ public final class TooltipAdditionDisplayHandler {
float hueOff = (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.01F;
GlStateManager.disableDepth();
Gui.drawRect(mouseX + offx - 1, mouseY - offy - height - 1, mouseX + offx + width + 1, mouseY - offy, 0xFF000000);
Gui.drawRect(mouseX - 1, mouseY - height - 1, mouseX + width + 1, mouseY, 0xFF000000);
for(int i = 0; i < rainbowWidth; i++)
Gui.drawRect(mouseX + offx + i, mouseY - offy - height, mouseX + offx + i + 1, mouseY - offy, Color.HSBtoRGB(hueOff + huePer * i, 1F, 1F));
Gui.drawRect(mouseX + offx + rainbowWidth, mouseY - offy - height, mouseX + offx + width, mouseY - offy, 0xFF555555);
Gui.drawRect(mouseX + i, mouseY - height, mouseX + i + 1, mouseY, Color.HSBtoRGB(hueOff + huePer * i, 1F, 1F));
Gui.drawRect(mouseX + rainbowWidth, mouseY - height, mouseX + width, mouseY, 0xFF555555);
String rank = I18n.format("botania.rank" + level).replaceAll("&", "\u00a7");
GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
GlStateManager.disableLighting();
font.drawStringWithShadow(rank, mouseX + offx, mouseY - offy - 12, 0xFFFFFF);
font.drawStringWithShadow(rank, mouseX, mouseY - 12, 0xFFFFFF);
if(!ss) {
rank = I18n.format("botania.rank" + (level + 1)).replaceAll("&", "\u00a7");
font.drawStringWithShadow(rank, mouseX + offx + width - font.getStringWidth(rank), mouseY - offy - 12, 0xFFFFFF);
font.drawStringWithShadow(rank, mouseX + width - font.getStringWidth(rank), mouseY - 12, 0xFFFFFF);
}
GlStateManager.enableLighting();
GlStateManager.enableDepth();
GL11.glPopAttrib();
}
private static void drawManaBar(ItemStack stack, IManaTooltipDisplay display, int mouseX, int mouseY, int offx, int offy, int width, int height) {
private static void drawManaBar(ItemStack stack, IManaTooltipDisplay display, int mouseX, int mouseY, int width, int height) {
float fraction = display.getManaFractionForDisplay(stack);
int manaBarWidth = (int) Math.ceil(width * fraction);
GlStateManager.disableDepth();
Gui.drawRect(mouseX + offx - 1, mouseY - offy - height - 1, mouseX + offx + width + 1, mouseY - offy, 0xFF000000);
Gui.drawRect(mouseX + offx, mouseY - offy - height, mouseX + offx + manaBarWidth, mouseY - offy, Color.HSBtoRGB(0.528F, ((float) Math.sin((ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.2) + 1F) * 0.3F + 0.4F, 1F));
Gui.drawRect(mouseX + offx + manaBarWidth, mouseY - offy - height, mouseX + offx + width, mouseY - offy, 0xFF555555);
Gui.drawRect(mouseX - 1, mouseY - height - 1, mouseX + width + 1, mouseY, 0xFF000000);
Gui.drawRect(mouseX, mouseY - height, mouseX + manaBarWidth, mouseY, Color.HSBtoRGB(0.528F, ((float) Math.sin((ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.2) + 1F) * 0.3F + 0.4F, 1F));
Gui.drawRect(mouseX + manaBarWidth, mouseY - height, mouseX + width, mouseY, 0xFF555555);
}
}
@@ -24,12 +24,6 @@ public final class TooltipHandler {
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void onTooltipEvent(ItemTooltipEvent event) {
if(event.getItemStack().getItem() == Item.getItemFromBlock(Blocks.DIRT) && event.getItemStack().getItemDamage() == 1) {
event.getToolTip().add(I18n.format("botaniamisc.coarseDirt0"));
event.getToolTip().add(I18n.format("botaniamisc.coarseDirt1"));
} else if(event.getItemStack().getItem() == Item.getItemFromBlock(Blocks.MOB_SPAWNER) && event.getEntityPlayer().capabilities.isCreativeMode)
event.getToolTip().add(I18n.format("botaniamisc.spawnerTip"));
if(ItemNBTHelper.detectNBT(event.getItemStack()) && ItemNBTHelper.getBoolean(event.getItemStack(), ItemRegenIvy.TAG_REGEN, false))
event.getToolTip().add(I18n.format("botaniamisc.hasIvy"));
if(ItemNBTHelper.detectNBT(event.getItemStack()) && ItemNBTHelper.getBoolean(event.getItemStack(), ItemKeepIvy.TAG_KEEP, false))
@@ -60,6 +60,7 @@ import vazkii.botania.client.core.handler.MultiblockRenderHandler;
import vazkii.botania.client.core.handler.PersistentVariableHelper;
import vazkii.botania.client.core.handler.RenderLexicon;
import vazkii.botania.client.core.handler.SubTileRadiusRenderHandler;
import vazkii.botania.client.core.handler.TooltipAdditionDisplayHandler;
import vazkii.botania.client.core.handler.TooltipHandler;
import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.client.fx.FXLightning;
@@ -205,6 +206,7 @@ public class ClientProxy extends CommonProxy {
if(ConfigHandler.boundBlockWireframe)
MinecraftForge.EVENT_BUS.register(BoundTileRenderer.class);
MinecraftForge.EVENT_BUS.register(TooltipHandler.class);
MinecraftForge.EVENT_BUS.register(TooltipAdditionDisplayHandler.class);
MinecraftForge.EVENT_BUS.register(DebugHandler.class);
MinecraftForge.EVENT_BUS.register(SubTileRadiusRenderHandler.class);
MinecraftForge.EVENT_BUS.register(MultiblockRenderHandler.class);
@@ -14,6 +14,7 @@ import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.JEIPlugin;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.state.enums.AltarVariant;
@@ -44,6 +45,9 @@ public class JEIBotaniaPlugin implements IModPlugin {
public void register(@Nonnull IModRegistry registry) {
IJeiHelpers jeiHelpers = registry.getJeiHelpers();
jeiHelpers.getSubtypeRegistry().registerNbtInterpreter(Item.getItemFromBlock(ModBlocks.specialFlower), ItemBlockSpecialFlower::getType);
jeiHelpers.getSubtypeRegistry().registerNbtInterpreter(Item.getItemFromBlock(ModBlocks.floatingSpecialFlower), ItemBlockSpecialFlower::getType);
registry.addRecipeCategories(
new BreweryRecipeCategory(jeiHelpers.getGuiHelper()),
new PureDaisyRecipeCategory(jeiHelpers.getGuiHelper()),
@@ -106,8 +106,11 @@ public class ElvenTradeRecipeCategory implements IRecipeCategory {
posX += 18;
}
recipeLayout.getItemStacks().init(index, false, 93, 41);
recipeLayout.getItemStacks().set(index, wrapper.getOutputs().get(0));
for (int i = 0; i < wrapper.getOutputs().size(); i++) {
ItemStack stack = wrapper.getOutputs().get(i);
recipeLayout.getItemStacks().init(index + i, false, 93 + (i % 2 * 20), 41 + (i / 2 * 20));
recipeLayout.getItemStacks().set(index + i, stack);
}
}
}
@@ -22,7 +22,7 @@ import java.util.List;
public class ElvenTradeRecipeWrapper implements IRecipeWrapper {
private final List input;
private final ItemStack output;
private final List<ItemStack> outputs;
@SuppressWarnings("unchecked")
public ElvenTradeRecipeWrapper(RecipeElvenTrade recipe) {
@@ -36,7 +36,7 @@ public class ElvenTradeRecipeWrapper implements IRecipeWrapper {
}
}
input = builder.build();
output = recipe.getOutput();
outputs = ImmutableList.copyOf(recipe.getOutputs());
}
@Override
@@ -46,7 +46,7 @@ public class ElvenTradeRecipeWrapper implements IRecipeWrapper {
@Override
public List<ItemStack> getOutputs() {
return ImmutableList.of(output);
return outputs;
}
@Override
@@ -0,0 +1,171 @@
package vazkii.botania.client.model;
import com.google.common.base.Preconditions;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.block.model.ModelManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormatElement;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.client.model.IPerspectiveAwareModel;
import net.minecraftforge.client.model.pipeline.IVertexConsumer;
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
import net.minecraftforge.client.model.pipeline.VertexTransformer;
import net.minecraftforge.common.model.TRSRTransformation;
import org.apache.commons.lang3.tuple.Pair;
import vazkii.botania.common.Botania;
import vazkii.botania.common.item.ItemManaGun;
import vazkii.botania.common.item.ModItems;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
import javax.vecmath.Vector3f;
import javax.vecmath.Vector4f;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class GunModel implements IBakedModel {
private final IBakedModel originalModel;
public GunModel(IBakedModel originalModel) {
this.originalModel = Preconditions.checkNotNull(originalModel);
}
private final ItemOverrideList itemHandler = new ItemOverrideList(ImmutableList.of()) {
@Nonnull
@Override
public IBakedModel handleItemState(@Nonnull IBakedModel model, ItemStack stack, @Nonnull World world, @Nonnull EntityLivingBase entity) {
ItemStack lens = ItemManaGun.getLens(stack);
if(lens != null) {
IBakedModel lensModel = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(lens);
return GunModel.this.getModel(lensModel);
}
else return GunModel.this;
}
};
@Nonnull
@Override
public ItemOverrideList getOverrides() {
return itemHandler;
}
@Nonnull @Override public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) { return originalModel.getQuads(state, side, rand); }
@Override public boolean isAmbientOcclusion() { return originalModel.isAmbientOcclusion(); }
@Override public boolean isGui3d() { return originalModel.isGui3d(); }
@Override public boolean isBuiltInRenderer() { return originalModel.isBuiltInRenderer(); }
@Nonnull @Override public TextureAtlasSprite getParticleTexture() { return originalModel.getParticleTexture(); }
@Nonnull @Override public ItemCameraTransforms getItemCameraTransforms() { return originalModel.getItemCameraTransforms(); }
private final IdentityHashMap<IBakedModel, CompositeBakedModel> cache = new IdentityHashMap<>();
private CompositeBakedModel getModel(IBakedModel lens) {
CompositeBakedModel model = cache.get(lens);
if(model == null) {
model = new CompositeBakedModel(lens, originalModel);
cache.put(lens, model);
}
return model;
}
protected static BakedQuad transform(BakedQuad quad, final TRSRTransformation transform) {
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(DefaultVertexFormats.ITEM);
final IVertexConsumer consumer = new VertexTransformer(builder) {
@Override
public void put(int element, float... data) {
VertexFormatElement formatElement = DefaultVertexFormats.ITEM.getElement(element);
switch(formatElement.getUsage()) {
case POSITION: {
float[] newData = new float[4];
Vector4f vec = new Vector4f(data);
transform.getMatrix().transform(vec);
vec.get(newData);
parent.put(element, newData);
break;
}
default: {
parent.put(element, data);
break;
}
}
}
};
quad.pipe(consumer);
return builder.build();
}
private static class CompositeBakedModel implements IPerspectiveAwareModel {
private final IBakedModel gun;
private final List<BakedQuad> genQuads;
private final Map<EnumFacing, List<BakedQuad>> faceQuads = new EnumMap<>(EnumFacing.class);
CompositeBakedModel(IBakedModel lens, IBakedModel gun) {
this.gun = gun;
ImmutableList.Builder<BakedQuad> genBuilder = ImmutableList.builder();
final TRSRTransformation transform = TRSRTransformation.blockCenterToCorner(new TRSRTransformation(new Vector3f(-0.4F, 0.25F, 0), null, new Vector3f(0.625F, 0.625F, 0.625F), TRSRTransformation.quatFromXYZ(0, (float) Math.PI / 2, 0)));
for(EnumFacing e : EnumFacing.VALUES)
faceQuads.put(e, new ArrayList<>());
// Add lens quads, scaled and translated
for(BakedQuad quad : lens.getQuads(null, null, 0)) {
genBuilder.add(transform(quad, transform));
}
for(EnumFacing e : EnumFacing.VALUES) {
faceQuads.get(e).addAll(lens.getQuads(null, e, 0).stream().map(input -> transform(input, transform)).collect(Collectors.toList()));
}
// Add gun quads
genBuilder.addAll(gun.getQuads(null, null, 0));
for(EnumFacing e : EnumFacing.VALUES) {
faceQuads.get(e).addAll(gun.getQuads(null, e, 0));
}
genQuads = genBuilder.build();
}
@Nonnull @Override public List<BakedQuad> getQuads(IBlockState state, EnumFacing face, long rand) { return face == null ? genQuads : faceQuads.get(face); }
// Forward all to gun model
@Override public boolean isAmbientOcclusion() { return gun.isAmbientOcclusion(); }
@Override public boolean isGui3d() { return gun.isGui3d(); }
@Override public boolean isBuiltInRenderer() { return gun.isBuiltInRenderer(); }
@Nonnull @Override public TextureAtlasSprite getParticleTexture() { return gun.getParticleTexture();}
@Nonnull @Override public ItemCameraTransforms getItemCameraTransforms() { return gun.getItemCameraTransforms(); }
@Nonnull @Override public ItemOverrideList getOverrides() { return ItemOverrideList.NONE; }
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) {
if(gun instanceof IPerspectiveAwareModel) {
Pair<? extends IBakedModel, Matrix4f> pair = ((IPerspectiveAwareModel) gun).handlePerspective(cameraTransformType);
if(pair != null && pair.getRight() != null)
return Pair.of(this, pair.getRight());
}
return Pair.of(this, TRSRTransformation.identity().getMatrix());
}
}
}
@@ -1,102 +0,0 @@
/**
* This class was created by <wiiv>. 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 @ [? (GMT)]
*/
package vazkii.botania.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
public class ModelBlackHoleCube extends ModelBase {
public final ModelRenderer shape1;
public final ModelRenderer shape1_1;
public final ModelRenderer shape1_2;
public final ModelRenderer shape1_3;
public final ModelRenderer shape1_4;
public final ModelRenderer shape1_5;
public final ModelRenderer shape1_6;
public final ModelRenderer shape1_7;
public final ModelRenderer shape1_8;
public final ModelRenderer shape1_9;
public final ModelRenderer shape1_10;
public final ModelRenderer shape1_11;
public ModelBlackHoleCube() {
textureWidth = 36;
textureHeight = 2;
shape1_3 = new ModelRenderer(this, 0, 0);
shape1_3.setRotationPoint(0.0F, 16.0F, 0.0F);
shape1_3.addBox(-7.0F, 7.0F, -8.0F, 14, 1, 1, 0.0F);
setRotateAngle(shape1_3, 0.0F, 1.5707963267948966F, 0.0F);
shape1_7 = new ModelRenderer(this, 0, 0);
shape1_7.setRotationPoint(0.0F, 16.0F, 0.0F);
shape1_7.addBox(-7.0F, -8.0F, -8.0F, 14, 1, 1, 0.0F);
setRotateAngle(shape1_7, 0.0F, 1.5707963267948966F, 0.0F);
shape1_9 = new ModelRenderer(this, 0, 0);
shape1_9.setRotationPoint(0.0F, 16.0F, 0.0F);
shape1_9.addBox(-7.0F, 7.0F, 7.0F, 14, 1, 1, 0.0F);
setRotateAngle(shape1_9, 0.0F, 3.141592653589793F, 1.5707963267948966F);
shape1_11 = new ModelRenderer(this, 0, 0);
shape1_11.setRotationPoint(0.0F, 16.0F, 0.0F);
shape1_11.addBox(-7.0F, 7.0F, -8.0F, 14, 1, 1, 0.0F);
setRotateAngle(shape1_11, 0.0F, 3.141592653589793F, 1.5707963267948966F);
shape1 = new ModelRenderer(this, 0, 0);
shape1.setRotationPoint(0.0F, 16.0F, 0.0F);
shape1.addBox(-8.0F, 7.0F, 7.0F, 16, 1, 1, 0.0F);
shape1_4 = new ModelRenderer(this, 0, 0);
shape1_4.setRotationPoint(0.0F, 16.0F, 0.0F);
shape1_4.addBox(-8.0F, 7.0F, -8.0F, 16, 1, 1, 0.0F);
shape1_8 = new ModelRenderer(this, 0, 0);
shape1_8.setRotationPoint(0.0F, 16.0F, 0.0F);
shape1_8.addBox(-7.0F, -8.0F, -8.0F, 14, 1, 1, 0.0F);
setRotateAngle(shape1_8, 0.0F, 3.141592653589793F, 1.5707963267948966F);
shape1_2 = new ModelRenderer(this, 0, 0);
shape1_2.setRotationPoint(0.0F, 16.0F, 0.0F);
shape1_2.addBox(-8.0F, -8.0F, -8.0F, 16, 1, 1, 0.0F);
shape1_1 = new ModelRenderer(this, 0, 0);
shape1_1.setRotationPoint(0.0F, 16.0F, 0.0F);
shape1_1.addBox(-8.0F, -8.0F, 7.0F, 16, 1, 1, 0.0F);
shape1_6 = new ModelRenderer(this, 0, 0);
shape1_6.setRotationPoint(0.0F, 16.0F, 0.0F);
shape1_6.addBox(-7.0F, -8.0F, -8.0F, 14, 1, 1, 0.0F);
setRotateAngle(shape1_6, 0.0F, -1.5707963267948966F, 0.0F);
shape1_10 = new ModelRenderer(this, 0, 0);
shape1_10.setRotationPoint(0.0F, 16.0F, 0.0F);
shape1_10.addBox(-7.0F, -8.0F, 7.0F, 14, 1, 1, 0.0F);
setRotateAngle(shape1_10, 0.0F, 3.141592653589793F, 1.5707963267948966F);
shape1_5 = new ModelRenderer(this, 0, 0);
shape1_5.setRotationPoint(0.0F, 16.0F, 0.0F);
shape1_5.addBox(-7.0F, 7.0F, -8.0F, 14, 1, 1, 0.0F);
setRotateAngle(shape1_5, 0.0F, -1.5707963267948966F, 0.0F);
}
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
shape1_3.render(f5);
shape1_7.render(f5);
shape1_9.render(f5);
shape1_11.render(f5);
shape1.render(f5);
shape1_4.render(f5);
shape1_8.render(f5);
shape1_2.render(f5);
shape1_1.render(f5);
shape1_6.render(f5);
shape1_10.render(f5);
shape1_5.render(f5);
}
public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
}
@@ -1,50 +0,0 @@
/**
* This class was created by <Kihira>. 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 @ [? (GMT)]
*/
package vazkii.botania.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
public class ModelSkullOverride extends ModelBase {
private final ModelRenderer bipedHead;
private final ModelRenderer bipedHeadwear;
public ModelSkullOverride() {
textureWidth = 64;
textureHeight = 32;
bipedHead = new ModelRenderer(this, 0, 0);
bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0F);
bipedHead.setRotationPoint(0.0F, 0.0F, 0.0F);
bipedHeadwear = new ModelRenderer(this, 32, 0);
bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.5F);
bipedHeadwear.setRotationPoint(0.0F, 0.0F, 0.0F);
}
public void renderWithoutRotation(float par1) {
bipedHead.render(par1);
bipedHeadwear.render(par1);
}
@Override
public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) {
setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity);
bipedHead.render(par7);
bipedHeadwear.render(par7);
}
@Override
public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) {
bipedHead.rotateAngleY = bipedHeadwear.rotateAngleY = par4 / (180F / (float)Math.PI);
bipedHead.rotateAngleX = bipedHeadwear.rotateAngleX = par5 / (180F / (float)Math.PI);
}
}
@@ -197,9 +197,11 @@ public class SpecialFlowerModel implements IModelCustomData {
ModelResourceLocation loc = loadFrom.get(Optional.of(key));
if(loc == null)
return Optional.empty();
IModel model = ModelLoaderRegistry.getModelOrMissing(loc);
if(model == ModelLoaderRegistry.getMissingModel())
return Optional.empty();
return Optional.of(model.bake(new SimpleModelState(transforms), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter()));
}
}
@@ -216,13 +218,9 @@ public class SpecialFlowerModel implements IModelCustomData {
String subtileId = extendedState.getValue(BotaniaStateProps.SUBTILE_ID);
IBakedModel ret = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getMissingModel();
if(subtileId != null) { // Todo remove - workaround for subtile ID being null?
Optional<IBakedModel> specialModel = bakedBlockModels.getUnchecked(extendedState.getValue(BotaniaStateProps.SUBTILE_ID));
if(specialModel.isPresent())
ret = specialModel.get();
} else {
Botania.LOGGER.fatal("NULL SUBTILE ID");
}
Optional<IBakedModel> specialModel = bakedBlockModels.getUnchecked(subtileId == null ? "" : subtileId);
if(specialModel.isPresent())
ret = specialModel.get();
return ret.getQuads(state, face, rand);
}
@@ -10,11 +10,18 @@
*/
package vazkii.botania.client.render.entity;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.datasync.DataParameter;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.entity.EntityCorporeaSpark;
public class RenderCorporeaSpark extends RenderSparkBase<EntityCorporeaSpark> {
@@ -48,13 +55,16 @@ public class RenderCorporeaSpark extends RenderSparkBase<EntityCorporeaSpark> {
@Override
public void renderCallback(EntityCorporeaSpark entity, float pticks) {
/*
int time = entity.getItemDisplayTicks();
if(time == 0)
return;
float absTime = Math.abs(time) - pticks;
ItemStack stack = entity.getDisplayedItem().orNull();
if(stack == null)
return;
GlStateManager.pushMatrix();
GlStateManager.rotate(90F, 1F, 0F, 0F);
float scalef = 1F / 6F;
@@ -64,14 +74,8 @@ public class RenderCorporeaSpark extends RenderSparkBase<EntityCorporeaSpark> {
GlStateManager.color(1F, 1F, 1F, absTime / 10);
GlStateManager.translate(0F, 0F, -2F + (time < 0 ? -absTime : absTime) / 6);
ItemStack stack = entity.getDisplayedItem();
if(stack == null)
return;
Item item = stack.getItem();
boolean block = item instanceof ItemBlock;
Minecraft.getMinecraft().renderEngine.bindTexture(block ? TextureMap.LOCATION_BLOCKS_TEXTURE : TextureMap.locationItemsTexture);
IIcon icon = block ? Block.getBlockFromItem(item).getBlockTextureFromSide(ForgeDirection.UP.ordinal()) : item.getIcon(stack, 0);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
TextureAtlasSprite icon = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(stack, entity.worldObj, null).getParticleTexture();
if(icon != null) {
float minU = icon.getMinU();
@@ -91,7 +95,7 @@ public class RenderCorporeaSpark extends RenderSparkBase<EntityCorporeaSpark> {
GlStateManager.translate(gap * i, 0F, 0F);
for(int j = -shift; j < shift; j++) {
GlStateManager.translate(0F, gap * j, 0F);
ItemRenderer.renderItemIn2D(Tessellator.getInstance(), minU + stepU * (i + shift), minV + stepV * (j + shift + 1), minU + stepU * (i + shift + 1), minV + stepV * (j + shift), icon.getIconWidth() / pieces, icon.getIconHeight() / pieces, 1F / 8F);
IconHelper.renderIconIn3D(Tessellator.getInstance(), minU + stepU * (i + shift), minV + stepV * (j + shift + 1), minU + stepU * (i + shift + 1), minV + stepV * (j + shift), icon.getIconWidth() / pieces, icon.getIconHeight() / pieces, 1F / 8F);
GlStateManager.translate(0F, -gap * j, 0F);
}
GlStateManager.translate(-gap * i, 0F, 0F);
@@ -100,7 +104,6 @@ public class RenderCorporeaSpark extends RenderSparkBase<EntityCorporeaSpark> {
GlStateManager.disableBlend();
GlStateManager.popMatrix();
*/
}
}
@@ -39,15 +39,27 @@ import vazkii.botania.client.model.ModelTinyPotato;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.TileTinyPotato;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.bauble.ItemBaubleCosmetic;
import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara;
import javax.annotation.Nonnull;
import java.util.Arrays;
public class RenderTileTinyPotato extends TileEntitySpecialRenderer<TileTinyPotato> {
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_TINY_POTATO);
private static final ResourceLocation textureGrayscale = new ResourceLocation(LibResources.MODEL_TINY_POTATO_GS);
private static final ResourceLocation textureHalloween = new ResourceLocation(LibResources.MODEL_TINY_POTATO_HALLOWEEN);
private static final ModelTinyPotato model = new ModelTinyPotato();
private final ItemStack[] cosmetics = Arrays.stream(ItemBaubleCosmetic.Variants.values()).map(v -> new ItemStack(ModItems.cosmetic, 1, v.ordinal())).toArray(ItemStack[]::new);
private static boolean matches(String name, String match) {
return name.equals(match) || name.startsWith(match + " ");
}
private static String removeFromFront(String name, String match) {
return name.substring(match.length()).trim();
}
@Override
public void renderTileEntityAt(@Nonnull TileTinyPotato potato, double x, double y, double z, float partialTicks, int destroyStage) {
@@ -62,28 +74,28 @@ public class RenderTileTinyPotato extends TileEntitySpecialRenderer<TileTinyPota
Minecraft mc = Minecraft.getMinecraft();
mc.renderEngine.bindTexture(ClientProxy.dootDoot ? textureHalloween : texture);
String name = potato.name.toLowerCase();
String name = potato.name.toLowerCase().trim();
boolean usedShader = false;
if (name.startsWith("gaia ")) {
if (matches(name, "gaia")) {
ShaderHelper.useShader(ShaderHelper.doppleganger);
name = name.substring(5);
name = removeFromFront(name, "gaia");
usedShader = true;
} else if (name.startsWith("hot ")) {
} else if (matches(name, "hot")) {
ShaderHelper.useShader(ShaderHelper.halo);
name = name.substring(4);
name = removeFromFront(name, "hot");
usedShader = true;
} else if (name.startsWith("magic ")) {
} else if (matches(name, "magic")) {
ShaderHelper.useShader(ShaderHelper.enchanterRune);
name = name.substring(6);
name = removeFromFront(name, "magic");
usedShader = true;
} else if (name.startsWith("gold ")) {
} else if (matches(name, "gold")) {
ShaderHelper.useShader(ShaderHelper.gold);
name = name.substring(5);
name = removeFromFront(name, "gold");
usedShader = true;
} else if (name.startsWith("snoop ")) {
} else if (matches(name, "snoop")) {
ShaderHelper.useShader(ShaderHelper.terraPlateRune);
name = name.substring(6);
name = removeFromFront(name, "snoop");
usedShader = true;
}
@@ -104,16 +116,23 @@ public class RenderTileTinyPotato extends TileEntitySpecialRenderer<TileTinyPota
GlStateManager.rotate(rotZ, 0F, 0F, 1F);
GlStateManager.pushMatrix();
if (name.equals("pahimar")) {
GlStateManager.scale(1F, 0.3F, 1F);
GlStateManager.translate(0F, 3.5F, 0F);
} else if (name.equals("kyle hyde"))
mc.renderEngine.bindTexture(textureGrayscale);
else if (name.equals("dinnerbone") || name.equals("grumm")) {
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.translate(0F, -2.625F, 0F);
} else if (name.equals("aureylian"))
GlStateManager.color(1F, 0.5F, 1F);
switch (name) {
case "pahimar":
GlStateManager.scale(1F, 0.3F, 1F);
GlStateManager.translate(0F, 3.5F, 0F);
break;
case "kyle hyde":
mc.renderEngine.bindTexture(textureGrayscale);
break;
case "dinnerbone":
case "grumm":
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.translate(0F, -2.625F, 0F);
break;
case "aureylian":
GlStateManager.color(1F, 0.5F, 1F);
break;
}
boolean render = !(name.equals("mami") || name.equals("soaryn") || name.equals("eloraam") && jump != 0);
@@ -154,14 +173,15 @@ public class RenderTileTinyPotato extends TileEntitySpecialRenderer<TileTinyPota
} else if (name.equals("skull kid")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.translate(0F, -0.7F, -0.4F);
renderItem(new ItemStack(ModItems.cosmetic, 1, 23));
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(0F, -1.6F, 0F);
renderItem(cosmetics[23]);
} else if (name.equals("kamina")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(0F, -0.6F, 0.4F);
renderItem(new ItemStack(ModItems.cosmetic, 1, 26));
GlStateManager.translate(0F, -1.4F, 0F);
renderItem(cosmetics[26]);
} else if (name.equals("haighyorkie")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
@@ -171,103 +191,98 @@ public class RenderTileTinyPotato extends TileEntitySpecialRenderer<TileTinyPota
} else if (name.equals("chitoge")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(0F, -0.2F, 0.1F);
renderItem(new ItemStack(ModItems.cosmetic, 1, 7));
GlStateManager.translate(0F, -1F, -0.4F);
renderItem(cosmetics[7]);
} else if (name.equals("direwolf20")) {
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(0F, -1.7F, 0.5F);
renderItem(new ItemStack(ModItems.cosmetic));
GlStateManager.translate(0F, -2.5F, 0.125F);
renderItem(cosmetics[0]);
} else if (name.equals("doctor")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(0F, -0.65F, 0.4F);
renderItem(new ItemStack(ModItems.cosmetic, 1, 25));
GlStateManager.translate(0F, -1.45F, 0F);
renderItem(cosmetics[25]);
} else if (name.equals("snoo")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(0.2F, 0F, -0.05F);
GlStateManager.rotate(-20F, 0F, 0F, 1F);
renderItem(new ItemStack(ModItems.cosmetic, 1, 24));
GlStateManager.translate(0F, -0.75F, -0.5F);
renderItem(cosmetics[24]);
} else if (name.equals("charlotte")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(0F, -0.7F, 0.4F);
renderItem(new ItemStack(ModItems.cosmetic, 1, 12));
GlStateManager.translate(0F, -1.6F, 0F);
renderItem(cosmetics[12]);
} else if (name.equals("greg") || name.equals("gregorioust")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.rotate(270F, 0F, 1F, 0F);
GlStateManager.translate(0F, -1F, 0.4F);
GlStateManager.translate(0F, -1.5F, -0.9F);
renderItem(new ItemStack(Items.BOOK));
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.scale(0.3F, 0.3F, 0.3F);
GlStateManager.translate(0F, 2.5F, 1.5F);
renderItem(new ItemStack(Blocks.IRON_ORE));
} else if (name.equals("profmobius")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.rotate(270F, 0F, 1F, 0F);
GlStateManager.translate(0F, -0.7F, 0.4F);
GlStateManager.translate(0F, -1.5F, -0.9F);
renderItem(new ItemStack(Items.BREAD));
} else if (name.equals("martysgames") || name.equals("marty")) {
GlStateManager.scale(0.7F, 0.7F, 0.7F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(0.3F, -1.8F, 0.7F);
GlStateManager.rotate(-15F, 0F, 0F, 1F);
GlStateManager.translate(-0.3F, -2.7F, -1.2F);
GlStateManager.rotate(15F, 0F, 0F, 1F);
renderItem(new ItemStack(ModItems.infiniteFruit, 1).setStackDisplayName("das boot"));
} else if (name.equals("tromped")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.rotate(270F, 0F, 1F, 0F);
GlStateManager.translate(0F, -0.7F, 0.4F);
GlStateManager.translate(0F, -1.5F, -0.9F);
renderItem(new ItemStack(ModItems.cacophonium));
} else if (name.equals("kain vinosec")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.rotate(90F, 0F, 1F, 0F);
GlStateManager.translate(-0.3F, -1F, 0.4F);
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.rotate(270F, 0F, 1F, 0F);
GlStateManager.translate(0.25F, -1.8F, -0.9F);
renderItem(new ItemStack(ModItems.recordGaia1));
GlStateManager.scale(0.5F, 0.5F, 0.5F);
GlStateManager.translate(0F, 0F, -0.85F);
GlStateManager.translate(0F, 0F, 0.85F);
renderItem(new ItemStack(ModItems.recordGaia2));
} else if (name.equals("mankrik")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(0F, 0.3F, 0.1F);
renderItem(new ItemStack(ModItems.cosmetic, 1, 31));
GlStateManager.translate(0F, -0.5F, -0.5F);
renderItem(cosmetics[31]);
} else if (name.equals("kurumi")) {
GlStateManager.scale(0.4F, 0.4F, 0.4F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(0.4F, -2F, 1.3F);
renderItem(new ItemStack(ModItems.cosmetic, 1, 17));
GlStateManager.translate(-0.45F, -2.85F, -1.75F);
renderItem(cosmetics[17]);
} else if (name.equals("ichun")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(0F, -0.7F, 0.4F);
renderItem(new ItemStack(ModItems.cosmetic, 1, 15));
GlStateManager.translate(0F, -1.45F, 0F);
renderItem(cosmetics[15]);
} else if (name.equals("wiiv") || name.equals("dylan4ever") || name.equals("dylankaiser")) {
GlStateManager.scale(1.5F, 1.5F, 1.5F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(90F, 0F, 1F, 0F);
GlStateManager.translate(-0.1F, -0.6F, -0.325F);
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.rotate(270F, 0F, 1F, 0F);
GlStateManager.translate(0F, -1.5F, -0.9F);
renderItem(new ItemStack(Items.PAINTING));
} else if (name.equals("jibril")) {
GlStateManager.scale(1.5F, 1.5F, 1.5F);
GlStateManager.translate(0F, 0.7F, 0F);
GlStateManager.translate(0F, -0.8F, 0F);
GlStateManager.rotate(90F, 0F, 1F, 0F);
ItemFlightTiara.renderHalo(null, partialTicks);
GlStateManager.disableBlend();
GlStateManager.disableLighting();
} else if (name.equals("nebris")) {
GlStateManager.scale(2F, 2F, 2F);
GlStateManager.rotate(180F, 1F, 0F, 0F);
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
renderItem(new ItemStack(Blocks.GLOWSTONE));
@@ -281,56 +296,64 @@ public class RenderTileTinyPotato extends TileEntitySpecialRenderer<TileTinyPota
renderBlock(Blocks.PORTAL);
} else if (name.equals("razz") || name.equals("razzleberryfox")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(90F, 0F, 1F, 0F);
GlStateManager.translate(0, -0.5F, 0.45F);
renderItem(new ItemStack(ModItems.cosmetic, 1, 8));
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.rotate(270F, 0F, 1F, 0F);
GlStateManager.translate(0F, -1.5F, 0F);
renderItem(cosmetics[8]);
} else if (name.equals("etho") || name.equals("ethoslab")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.rotate(90F, 0F, 1F, 0F);
GlStateManager.translate(0F, -0.7F, 0.4F);
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.rotate(270F, 0F, 1F, 0F);
GlStateManager.translate(0F, -1.5F, -0.9F);
renderItem(new ItemStack(Items.COOKIE));
} else if (name.equals("sethbling")) {
GlStateManager.scale(1.2F, 1.2F, 1.2F);
GlStateManager.rotate(-90F, 0F, 1F, 0F);
GlStateManager.translate(-0.5F, 1.4F, -0.5F);
GlStateManager.rotate(180F, 1F, 0F, 0F);
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
renderBlock(Blocks.COMMAND_BLOCK);
} else if (name.equals("bdoubleo100") || name.equals("bdoubleo")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(0.5F, -0.6F, 0.1F);
GlStateManager.translate(-0.65F, -1.5F, -0.45F);
renderItem(new ItemStack(Items.STICK));
} else if (name.equals("kingdaddydmac")) {
GlStateManager.scale(0.5F, 0.5F, 0.5F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(270F, 0F, 1F, 0F);
GlStateManager.translate(-0.3F, -2F, -1.075F);
GlStateManager.rotate(90F, 0F, 1F, 0F);
GlStateManager.translate(0F, -3F, 0.65F);
renderItem(new ItemStack(ModItems.manaRing, 1, 0));
GlStateManager.scale(0.5F, 0.5F, 0.5F);
GlStateManager.translate(0F, 0F, 4F);
GlStateManager.translate(0F, 0F, -4F);
renderItem(new ItemStack(ModItems.manaRing, 1, 0));
GlStateManager.scale(0.8F, 0.8F, 0.8F);
GlStateManager.translate(-1.7F, -1.2F, -0.1F);
GlStateManager.translate(1.25F, -1.25F, 2.25F);
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
renderBlock(Blocks.CAKE);
} else if (name.equals("sjin")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(0F, -0.77F, 0.4F);
renderItem(new ItemStack(ModItems.cosmetic, 1, 27));
GlStateManager.translate(0F, -1.6F, 0F);
renderItem(cosmetics[27]);
} else if (name.equals("martyn") || name.equals("inthelittlewood")) {
GlStateManager.scale(1.25F, 1.25F, 1.25F);
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.translate(0F, 0.05F, 0.1F);
GlStateManager.translate(0F, -0.8F, -0.2F);
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
renderItem(new ItemStack(Blocks.SAPLING, 0, 0));
} else if (name.equals("williewillus")) {
GlStateManager.rotate(180F, 1F, 0F, 0F);
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
renderItem(new ItemStack(Blocks.RED_NETHER_BRICK));
GlStateManager.scale(0.75F, 0.75F, 0.75F);
GlStateManager.translate(-1.1F, -1.25F, 0F);
renderItem(new ItemStack(Blocks.CHORUS_FLOWER));
GlStateManager.translate(2.2F, 0F, 0F);
renderItem(new ItemStack(Blocks.PRISMARINE));
} else if (ContributorFancinessHandler.flowerMap != null && ContributorFancinessHandler.flowerMap.containsKey(name)) {
ItemStack icon = ContributorFancinessHandler.flowerMap.get(name);
if (icon != null) {
@@ -410,7 +433,7 @@ public class RenderTileTinyPotato extends TileEntitySpecialRenderer<TileTinyPota
GlStateManager.popMatrix();
}
public void renderIcon(TextureAtlasSprite icon) {
private void renderIcon(TextureAtlasSprite icon) {
float f = icon.getMinU();
float f1 = icon.getMaxU();
float f2 = icon.getMinV();
@@ -418,11 +441,12 @@ public class RenderTileTinyPotato extends TileEntitySpecialRenderer<TileTinyPota
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
}
public void renderItem(ItemStack stack) {
private void renderItem(ItemStack stack) {
Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.HEAD);
}
public void renderBlock(Block block) {
private void renderBlock(Block block) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Minecraft.getMinecraft().getBlockRendererDispatcher().renderBlockBrightness(block.getDefaultState(), 1.0F);
}
}
}
@@ -82,6 +82,7 @@ public class BlockAltGrass extends BlockMod implements ILexiconable {
GameRegistry.register(new ItemBlockWithMetadataAndName(this), getRegistryName());
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tab, List<ItemStack> list) {
for(int i = 0; i < 6; i++)
@@ -120,6 +121,7 @@ public class BlockAltGrass extends BlockMod implements ILexiconable {
return type == EnumPlantType.Plains || type == EnumPlantType.Beach;
}
@SideOnly(Side.CLIENT)
@Override
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random r) {
if (state.getBlock() != this)
@@ -110,6 +110,7 @@ public class BlockAltar extends BlockMod implements ILexiconable {
return state;
}
@SideOnly(Side.CLIENT)
@Nonnull
@Override
public BlockRenderLayer getBlockLayer() {
@@ -121,6 +122,7 @@ public class BlockAltar extends BlockMod implements ILexiconable {
GameRegistry.register(new ItemBlockWithMetadataAndName(this), getRegistryName());
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tab, List<ItemStack> list) {
for(int i = 0; i < 9; i++)
@@ -179,7 +181,7 @@ public class BlockAltar extends BlockMod implements ILexiconable {
} else if(stack != null && stack.getItem() == Items.BUCKET && (tile.hasWater || tile.hasLava) && !Botania.gardenOfGlassLoaded) {
ItemStack bucket = tile.hasLava ? new ItemStack(Items.LAVA_BUCKET) : new ItemStack(Items.WATER_BUCKET);
if(stack.stackSize == 1)
player.inventory.setInventorySlotContents(player.inventory.currentItem, bucket);
player.setHeldItem(hand, bucket);
else {
if(!player.inventory.addItemStackToInventory(bucket))
player.dropItem(bucket, false);
@@ -24,6 +24,8 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.block.tile.TileBifrost;
@@ -66,6 +68,7 @@ public class BlockBifrost extends BlockMod implements ILexiconable {
return block != this && super.shouldSideBeRendered(state, world, pos, side);
}
@SideOnly(Side.CLIENT)
@Nonnull
@Override
public BlockRenderLayer getBlockLayer() {
@@ -20,6 +20,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.Botania;
@@ -59,6 +61,7 @@ public class BlockBifrostPerm extends BlockMod implements ILexiconable {
Botania.proxy.sparkleFX(world, pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.45F + 0.2F * (float) Math.random(), 6);
}
@SideOnly(Side.CLIENT)
@Nonnull
@Override
public BlockRenderLayer getBlockLayer() {
@@ -34,7 +34,6 @@ public abstract class BlockCamo extends BlockMod {
}
@Override
@SuppressWarnings("unchecked")
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack currentStack, EnumFacing side, float hitX, float hitY, float hitZ) {
TileEntity tile = world.getTileEntity(pos);
@@ -36,7 +36,7 @@ public class BlockFakeAir extends BlockMod {
private static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
public BlockFakeAir() {
super(Material.AIR, LibBlockNames.FAKE_AIR);
super(Material.STRUCTURE_VOID, LibBlockNames.FAKE_AIR);
setTickRandomly(true);
}
@@ -68,7 +68,7 @@ public class BlockFakeAir extends BlockMod {
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
if(shouldRemove(world, pos))
world.setBlockState(pos, Blocks.WATER.getDefaultState());
world.setBlockState(pos, rand.nextInt(10) == 0 ? Blocks.WATER.getDefaultState() : Blocks.AIR.getDefaultState());
}
@Override
@@ -64,10 +64,7 @@ public class BlockFloatingSpecialFlower extends BlockFloatingFlower implements I
GameRegistry.addRecipe(new SpecialFloatingFlowerRecipe());
RecipeSorter.register("botania:floatingSpecialFlower", SpecialFloatingFlowerRecipe.class, Category.SHAPELESS, "");
setDefaultState(((IExtendedBlockState) blockState.getBaseState())
.withProperty(BotaniaStateProps.ISLAND_TYPE, IFloatingFlower.IslandType.GRASS)
.withProperty(BotaniaStateProps.SUBTILE_ID, "daybloom")
.withProperty(BotaniaStateProps.COLOR, EnumDyeColor.WHITE));
setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.COLOR, EnumDyeColor.WHITE));
}
@Nonnull
@@ -208,6 +205,7 @@ public class BlockFloatingSpecialFlower extends BlockFloatingFlower implements I
((TileSpecialFlower) world.getTileEntity(pos)).onBlockAdded(world, pos, state);
}
@SideOnly(Side.CLIENT)
@Override
public void renderHUD(Minecraft mc, ScaledResolution res, World world, BlockPos pos) {
((TileSpecialFlower) world.getTileEntity(pos)).renderHUD(mc, res);
@@ -191,6 +191,7 @@ public class BlockHourglass extends BlockMod implements IManaTrigger, IWandable,
return false;
}
@SideOnly(Side.CLIENT)
@Override
public void renderHUD(Minecraft mc, ScaledResolution res, World world, BlockPos pos) {
TileHourglass tile = (TileHourglass) world.getTileEntity(pos);
@@ -88,6 +88,7 @@ public class BlockLightRelay extends BlockMod implements IWandable, ILexiconable
GameRegistry.register(new ItemBlockWithMetadataAndName(this), getRegistryName());
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tab, List<ItemStack> list) {
for(int i = 0; i < 2; i++)
@@ -76,6 +76,7 @@ public class BlockLivingrock extends BlockMod implements ILexiconable {
GameRegistry.register(new ItemBlockWithMetadataAndName(this), getRegistryName());
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tab, List<ItemStack> stacks) {
for(int i = 0; i < LivingRockVariant.values().length; i++)
@@ -80,6 +80,7 @@ public class BlockLivingwood extends BlockMod implements ILexiconable {
GameRegistry.register(new ItemBlockWithMetadataAndName(this), getRegistryName());
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tab, List<ItemStack> stacks) {
for(int i = 0; i < LivingWoodVariant.values().length; i++)
@@ -118,6 +118,7 @@ public class BlockModFlower extends BlockFlower implements ILexiconable, IPickup
return true;
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tab, @Nonnull List<ItemStack> stacks) {
for(int i = 0; i < 16; i++)
@@ -129,6 +130,7 @@ public class BlockModFlower extends BlockFlower implements ILexiconable, IPickup
return getMetaFromState(state);
}
@SideOnly(Side.CLIENT)
@Override
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
int hex = state.getValue(BotaniaStateProps.COLOR).getMapColor().colorValue;
@@ -101,6 +101,7 @@ public class BlockOpenCrate extends BlockMod implements ILexiconable, IWandable,
GameRegistry.register(new ItemBlockWithMetadataAndName(this), getRegistryName());
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tab, List<ItemStack> stacks) {
for(int i = 0; i < CrateVariant.values().length; i++)
@@ -156,6 +157,7 @@ public class BlockOpenCrate extends BlockMod implements ILexiconable, IWandable,
return crate.onWanded(world, player, stack);
}
@SideOnly(Side.CLIENT)
@Override
public void renderHUD(Minecraft mc, ScaledResolution res, World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
@@ -58,11 +58,7 @@ public class BlockPlatform extends BlockCamo implements ILexiconable, IWandable,
setHardness(2.0F);
setResistance(5.0F);
setSoundType(SoundType.WOOD);
setDefaultState(((IExtendedBlockState) blockState.getBaseState())
.withProperty(BotaniaStateProps.HELD_STATE, null)
.withProperty(BotaniaStateProps.HELD_WORLD, null)
.withProperty(BotaniaStateProps.HELD_POS, null)
.withProperty(BotaniaStateProps.PLATFORM_VARIANT, PlatformVariant.ABSTRUSE));
setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.PLATFORM_VARIANT, PlatformVariant.ABSTRUSE));
}
@Nonnull
@@ -116,6 +112,7 @@ public class BlockPlatform extends BlockCamo implements ILexiconable, IWandable,
GameRegistry.register(new ItemBlockWithMetadataAndName(this), getRegistryName());
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tab, List<ItemStack> stacks) {
for(int i = 0; i < PlatformVariant.values().length; i++)
@@ -93,6 +93,7 @@ public class BlockPylon extends BlockMod implements ILexiconable, IInfusionStabi
return getMetaFromState(state);
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs par2, List<ItemStack> par3) {
for(int i = 0; i < PylonVariant.values().length; i++)
@@ -119,7 +119,7 @@ public class BlockSparkChanger extends BlockMod implements ILexiconable {
pstack.stackSize--;
if(pstack.stackSize == 0)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
player.setHeldItem(hand, null);
return true;
}
@@ -10,7 +10,6 @@
*/
package vazkii.botania.common.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.SoundType;
import net.minecraft.block.properties.IProperty;
@@ -18,8 +17,6 @@ import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.particle.ParticleDigging;
import net.minecraft.client.renderer.block.statemap.StateMap;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
@@ -32,11 +29,9 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
@@ -57,6 +52,7 @@ import vazkii.botania.api.wand.IWandHUD;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.client.core.handler.ModelHandler;
import vazkii.botania.client.render.IModelRegister;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.tile.TileSpecialFlower;
import vazkii.botania.common.core.BotaniaCreativeTab;
import vazkii.botania.common.item.ModItems;
@@ -132,9 +128,7 @@ public class BlockSpecialFlower extends BlockFlower implements ISpecialFlower, I
setSoundType(SoundType.PLANT);
setTickRandomly(false);
setCreativeTab(BotaniaCreativeTab.INSTANCE);
setDefaultState(((IExtendedBlockState) blockState.getBaseState())
.withProperty(BotaniaStateProps.SUBTILE_ID, "daybloom")
.withProperty(BotaniaStateProps.COLOR, EnumDyeColor.WHITE).withProperty(type, EnumFlowerType.POPPY)
setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.COLOR, EnumDyeColor.WHITE).withProperty(type, EnumFlowerType.POPPY)
);
}
@@ -210,12 +204,14 @@ public class BlockSpecialFlower extends BlockFlower implements ISpecialFlower, I
return true;
}
@SideOnly(Side.CLIENT)
@Nonnull
@Override
public BlockRenderLayer getBlockLayer() {
return BlockRenderLayer.CUTOUT;
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tab, @Nonnull List<ItemStack> stacks) {
for(String s : BotaniaAPI.subtilesForCreativeMenu) {
@@ -342,45 +338,12 @@ public class BlockSpecialFlower extends BlockFlower implements ISpecialFlower, I
return ((TileSpecialFlower) world.getTileEntity(pos)).onBlockActivated(world, pos, state, player, hand, stack, side, hitX, hitY, hitZ);
}
@SideOnly(Side.CLIENT)
@Override
public void renderHUD(Minecraft mc, ScaledResolution res, World world, BlockPos pos) {
((TileSpecialFlower) world.getTileEntity(pos)).renderHUD(mc, res);
}
@Override
public boolean addLandingEffects(IBlockState state, net.minecraft.world.WorldServer worldObj, BlockPos blockPosition, IBlockState iblockstate, EntityLivingBase entity, int numberOfParticles) {
float f = (float) MathHelper.ceiling_float_int(entity.fallDistance - 3.0F);
double d0 = (double)Math.min(0.2F + f / 15.0F, 10.0F);
if (d0 > 2.5D) {
d0 = 2.5D;
}
int i = (int)(150.0D * d0);
worldObj.spawnParticle(EnumParticleTypes.BLOCK_DUST, entity.posX, entity.posY, entity.posZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, Block.getStateId(Blocks.WATERLILY.getDefaultState()));
return true;
}
@Override
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager effectRenderer) {
if (world.getBlockState(pos).getBlock() == this) {
int i = 4;
ParticleDigging.Factory factory = new ParticleDigging.Factory();
for (int j = 0; j < i; ++j) {
for (int k = 0; k < i; ++k) {
for (int l = 0; l < i; ++l) {
double d0 = (double)pos.getX() + ((double)j + 0.5D) / (double)i;
double d1 = (double)pos.getY() + ((double)k + 0.5D) / (double)i;
double d2 = (double)pos.getZ() + ((double)l + 0.5D) / (double)i;
effectRenderer.addEffect(factory.getEntityFX(-1, world, d0, d1, d2, d0 - (double)pos.getX() - 0.5D, d1 - (double)pos.getY() - 0.5D, d2 - (double)pos.getZ() - 0.5D, Block.getStateId(Blocks.WATERLILY.getDefaultState())));
}
}
}
return true;
} else {
return false;
}
}
@Override
public void register() {
GameRegistry.register(this);
@@ -66,6 +66,7 @@ public class BlockStorage extends BlockMod implements ILexiconable {
return getDefaultState().withProperty(BotaniaStateProps.STORAGE_VARIANT, StorageVariant.values()[meta]);
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs par2, List<ItemStack> par3) {
for(int i = 0; i < StorageVariant.values().length; i++)
@@ -49,7 +49,7 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexi
super(Material.IRON, LibBlockNames.CORPOREA_CRYSTAL_CUBE);
setHardness(5.5F);
setSoundType(SoundType.METAL);
setDefaultState(((IExtendedBlockState) blockState.getBaseState()).withProperty(Properties.AnimationProperty, null).withProperty(Properties.StaticProperty, true));
setDefaultState(blockState.getBaseState().withProperty(Properties.StaticProperty, true));
}
@Nonnull
@@ -46,6 +46,7 @@ public class BlockBuriedPetals extends BlockModFlower {
return AABB;
}
@SideOnly(Side.CLIENT)
@Override
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
EnumDyeColor color = state.getValue(BotaniaStateProps.COLOR);
@@ -77,6 +77,7 @@ public class BlockCustomBrick extends BlockMod implements ILexiconable {
GameRegistry.register(new ItemBlockWithMetadataAndName(this), getRegistryName());
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tab, List<ItemStack> stacks) {
for(int i = 0; i < CustomBrickVariant.values().length; i++)
@@ -10,19 +10,14 @@
*/
package vazkii.botania.common.block.decor;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.particle.ParticleDigging;
import net.minecraft.client.renderer.block.statemap.StateMap;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
@@ -31,10 +26,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
@@ -82,9 +75,7 @@ public class BlockFloatingFlower extends BlockMod implements ILexiconable, IInfu
setSoundType(SoundType.GROUND);
setLightLevel(1F);
setDefaultState(((IExtendedBlockState) blockState.getBaseState())
.withProperty(BotaniaStateProps.ISLAND_TYPE, IslandType.GRASS)
.withProperty(BotaniaStateProps.COLOR, EnumDyeColor.WHITE));
setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.COLOR, EnumDyeColor.WHITE));
}
@Nonnull
@@ -132,40 +123,6 @@ public class BlockFloatingFlower extends BlockMod implements ILexiconable, IInfu
return state;
}
@Override
public boolean addLandingEffects(IBlockState state, net.minecraft.world.WorldServer worldObj, BlockPos blockPosition, IBlockState iblockstate, EntityLivingBase entity, int numberOfParticles) {
float f = (float) MathHelper.ceiling_float_int(entity.fallDistance - 3.0F);
double d0 = (double)Math.min(0.2F + f / 15.0F, 10.0F);
if (d0 > 2.5D) {
d0 = 2.5D;
}
int i = (int)(150.0D * d0);
worldObj.spawnParticle(EnumParticleTypes.BLOCK_DUST, entity.posX, entity.posY, entity.posZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, Block.getStateId(Blocks.DIRT.getDefaultState()));
return true;
}
@Override
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager effectRenderer) {
if (world.getBlockState(pos).getBlock() == this) {
int i = 4;
ParticleDigging.Factory factory = new ParticleDigging.Factory();
for (int j = 0; j < i; ++j) {
for (int k = 0; k < i; ++k) {
for (int l = 0; l < i; ++l) {
double d0 = (double)pos.getX() + ((double)j + 0.5D) / (double)i;
double d1 = (double)pos.getY() + ((double)k + 0.5D) / (double)i;
double d2 = (double)pos.getZ() + ((double)l + 0.5D) / (double)i;
effectRenderer.addEffect(factory.getEntityFX(-1, world, d0, d1, d2, d0 - (double)pos.getX() - 0.5D, d1 - (double)pos.getY() - 0.5D, d2 - (double)pos.getZ() - 0.5D, Block.getStateId(Blocks.DIRT.getDefaultState())));
}
}
}
return true;
} else {
return false;
}
}
@Override
public void registerItemForm() {
GameRegistry.register(new ItemBlockWithMetadataAndName(this), getRegistryName());
@@ -80,6 +80,7 @@ public class BlockManaBeacon extends BlockMod implements ILexiconable {
return AABB;
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tab, List<ItemStack> stacks) {
for(int i = 0; i < 16; i++)
@@ -91,7 +91,7 @@ public class BlockManaFlame extends BlockMod implements ILexiconable {
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, @Nonnull World world, @Nonnull BlockPos pos) {
return null;
return NULL_AABB;
}
@Override
@@ -21,6 +21,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.block.BlockMod;
@@ -47,12 +49,14 @@ public class BlockManaGlass extends BlockMod implements ILexiconable {
return false;
}
@SideOnly(Side.CLIENT)
@Override
public boolean shouldSideBeRendered(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side) {
Block block = world.getBlockState(pos.offset(side)).getBlock();
return block == this ? false : super.shouldSideBeRendered(state, world, pos, side);
}
@SideOnly(Side.CLIENT)
@Nonnull
@Override
public BlockRenderLayer getBlockLayer() {
@@ -95,6 +95,7 @@ public class BlockPavement extends BlockMod {
GameRegistry.register(new ItemBlockWithMetadataAndName(this), getRegistryName());
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tab, List<ItemStack> stacks) {
for(int i = 0; i < TYPES; i++)
@@ -67,6 +67,7 @@ public class BlockPetalBlock extends BlockMod implements ILexiconable {
return getDefaultState().withProperty(BotaniaStateProps.COLOR, EnumDyeColor.byMetadata(meta));
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tab, List<ItemStack> list) {
for(int i = 0; i < 16; i++)
@@ -22,6 +22,8 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.state.BotaniaStateProps;
@@ -50,6 +52,7 @@ public class BlockStarfield extends BlockMod implements ILexiconable {
return AABB;
}
@SideOnly(Side.CLIENT)
@Nonnull
@Override
public BlockRenderLayer getBlockLayer() {
@@ -95,6 +95,7 @@ public class BlockTinyPotato extends BlockMod implements ILexiconable {
public void registerItemForm() {
GameRegistry.register(new ItemBlockTinyPotato(this), getRegistryName());
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9) {
TileEntity tile = world.getTileEntity(pos);
@@ -83,6 +83,7 @@ public class BlockUnstable extends BlockMod implements ILexiconable {
return AABB;
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tab, List<ItemStack> stacks) {
for(int i = 0; i < 16; i++)
@@ -21,6 +21,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.block.BlockMod;
@@ -39,6 +41,7 @@ public class BlockBiomeStone extends BlockMod implements ILexiconable {
setSoundType(SoundType.STONE);
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tab, List<ItemStack> list) {
for(int i = 0; i < 16; i++)
@@ -24,6 +24,7 @@ public class BlockAlfglassPane extends BlockModPane {
super(ModBlocks.elfGlass);
}
@SideOnly(Side.CLIENT)
@Nonnull
@Override
public BlockRenderLayer getBlockLayer() {
@@ -24,6 +24,7 @@ public class BlockBifrostPane extends BlockModPane {
super(ModBlocks.bifrostPerm);
}
@SideOnly(Side.CLIENT)
@Nonnull
@Override
public BlockRenderLayer getBlockLayer() {
@@ -24,6 +24,7 @@ public class BlockManaglassPane extends BlockModPane {
super(ModBlocks.manaGlass);
}
@SideOnly(Side.CLIENT)
@Nonnull
@Override
public BlockRenderLayer getBlockLayer() {
@@ -72,6 +72,7 @@ public class BlockBiomeStoneWall extends BlockModWall {
GameRegistry.register(new ItemBlockWithMetadataAndName(this), getRegistryName());
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tabs, @Nonnull List<ItemStack> list) {
for(int i = 0; i < 8; i++)
@@ -99,6 +99,7 @@ public abstract class BlockModWall extends BlockWall implements ILexiconable, IM
GameRegistry.register(new ItemBlockMod(this), getRegistryName());
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tabs, @Nonnull List<ItemStack> list) {
list.add(new ItemStack(item));
@@ -93,7 +93,7 @@ public class BlockBrewery extends BlockMod implements ILexiconable, IWandHUD {
InventoryHelper.withdrawFromInventory(brew, player);
} else {
if(stack != null)
return brew.addItem(player, stack);
return brew.addItem(player, stack, hand);
}
return false;
}
@@ -150,6 +150,7 @@ public class BlockBrewery extends BlockMod implements ILexiconable, IWandHUD {
return LexiconData.brewery;
}
@SideOnly(Side.CLIENT)
@Override
public void renderHUD(Minecraft mc, ScaledResolution res, World world, BlockPos pos) {
((TileBrewery) world.getTileEntity(pos)).renderHUD(mc, res);
@@ -31,12 +31,14 @@ import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.ItemHandlerHelper;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.state.BotaniaStateProps;
import vazkii.botania.api.wand.IWandHUD;
import vazkii.botania.api.wand.IWandable;
import vazkii.botania.client.core.handler.ModelHandler;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.BlockMod;
import vazkii.botania.common.block.tile.TileEnchanter;
import vazkii.botania.common.item.ModItems;
@@ -112,19 +114,21 @@ public class BlockEnchanter extends BlockMod implements IWandable, ILexiconable,
if(stack != null && stack.getItem() == ModItems.twigWand)
return false;
boolean stackEnchantable = stack != null && stack.getItem() != Items.BOOK && stack.isItemEnchantable() && stack.stackSize == 1 && stack.getItem().getItemEnchantability(stack) > 0;
boolean stackEnchantable = stack != null
&& stack.getItem() != Items.BOOK
&& stack.isItemEnchantable()
&& stack.stackSize == 1;
if(enchanter.itemToEnchant == null) {
if(stackEnchantable) {
enchanter.itemToEnchant = stack.copy();
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
player.setHeldItem(hand, null);
enchanter.sync();
}
} else if(enchanter.stage == TileEnchanter.State.IDLE) {
if(player.inventory.addItemStackToInventory(enchanter.itemToEnchant.copy())) {
enchanter.itemToEnchant = null;
enchanter.sync();
} else player.addChatMessage(new TextComponentTranslation("botaniamisc.invFull"));
ItemHandlerHelper.giveItemToPlayer(player, enchanter.itemToEnchant.copy());
enchanter.itemToEnchant = null;
enchanter.sync();
}
return true;
@@ -175,6 +179,7 @@ public class BlockEnchanter extends BlockMod implements IWandable, ILexiconable,
return LexiconData.manaEnchanting;
}
@SideOnly(Side.CLIENT)
@Override
public void renderHUD(Minecraft mc, ScaledResolution res, World world, BlockPos pos) {
((TileEnchanter) world.getTileEntity(pos)).renderHUD(res);
@@ -108,6 +108,7 @@ public class BlockForestDrum extends BlockMod implements IManaTrigger, ILexicona
return state.getBlock().getMetaFromState(state);
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs tab, List<ItemStack> list) {
for(int i = 0; i < 3; i++)
@@ -140,6 +140,7 @@ public class BlockPool extends BlockMod implements IWandHUD, IWandable, ILexicon
return drops;
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs par2, List<ItemStack> par3) {
par3.add(new ItemStack(item, 1, 0));
@@ -97,7 +97,7 @@ public class BlockPrism extends BlockMod implements IManaTrigger, ILexiconable,
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, @Nonnull World world, @Nonnull BlockPos pos) {
return null;
return NULL_AABB;
}
@Override
@@ -122,7 +122,7 @@ public class BlockPrism extends BlockMod implements IManaTrigger, ILexiconable,
if(lens == null && isHeldItemLens) {
if(!player.capabilities.isCreativeMode)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
player.setHeldItem(hand, null);
prism.getItemHandler().setStackInSlot(0, heldItem.copy());
prism.markDirty();
@@ -83,7 +83,7 @@ public class BlockRuneAltar extends BlockMod implements IWandable, ILexiconable
altar.trySetLastRecipe(player);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(altar);
} else if(stack != null) {
boolean result = altar.addItem(player, stack);
boolean result = altar.addItem(player, stack, hand);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(altar);
return result;
}
@@ -87,6 +87,7 @@ public class BlockSpreader extends BlockMod implements IWandable, IWandHUD, ILex
GameRegistry.register(new ItemBlockWithMetaNameAndColor(this), getRegistryName());
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(@Nonnull Item item, CreativeTabs par2, List<ItemStack> par3) {
for(int i = 0; i < 4; i++)
@@ -158,7 +159,7 @@ public class BlockSpreader extends BlockMod implements IWandable, IWandHUD, ILex
if(lens == null && isHeldItemLens) {
if (!player.capabilities.isCreativeMode)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
player.setHeldItem(hand, null);
spreader.getItemHandler().setStackInSlot(0, heldItem.copy());
spreader.markDirty();
@@ -174,7 +175,7 @@ public class BlockSpreader extends BlockMod implements IWandable, IWandHUD, ILex
spreader.paddingColor = heldItem.getItemDamage();
heldItem.stackSize--;
if(heldItem.stackSize == 0)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
player.setHeldItem(hand, null);
} else if(heldItem == null && spreader.paddingColor != -1 && lens == null) {
ItemStack pad = new ItemStack(Blocks.WOOL, 1, spreader.paddingColor);
if(!player.inventory.addItemStackToInventory(pad))
@@ -233,9 +234,7 @@ public class BlockSpreader extends BlockMod implements IWandable, IWandHUD, ILex
@Override
public AxisAlignedBB getWireframeAABB(World world, BlockPos pos) {
float f = 1F / 16F;
return new AxisAlignedBB(pos.getX() + f, pos.getY() + f, pos.getZ() + f,
pos.getX() + 1 - f, pos.getY() + 1 - f, pos.getZ() + 1 - f);
return FULL_BLOCK_AABB.offset(pos).contract(1.0/16.0);
}
@SideOnly(Side.CLIENT)
@@ -58,7 +58,7 @@ public class BlockTerraPlate extends BlockMod implements ILexiconable {
if(player == null || !player.capabilities.isCreativeMode) {
stack.stackSize--;
if(stack.stackSize == 0 && player != null)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
player.setHeldItem(hand, null);
}
ItemStack target = stack.copy();
@@ -21,6 +21,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.wand.IWandHUD;
@@ -51,6 +53,7 @@ public class BlockTurntable extends BlockMod implements IWandable, IWandHUD, ILe
return new TileTurntable();
}
@SideOnly(Side.CLIENT)
@Override
public void renderHUD(Minecraft mc, ScaledResolution res, World world, BlockPos pos) {
((TileTurntable) world.getTileEntity(pos)).renderHUD(mc, res);
@@ -1,6 +1,8 @@
package vazkii.botania.common.block.subtile.functional;
import net.minecraft.client.audio.ISound;
import net.minecraft.client.audio.ITickableSound;
import net.minecraft.client.audio.MovingSound;
import net.minecraft.client.audio.Sound;
import net.minecraft.client.audio.SoundEventAccessor;
import net.minecraft.client.audio.SoundHandler;
@@ -32,14 +34,18 @@ public class BergamuteEventHandler {
ISound sound = evt.getResultSound();
if (sound != null && shouldSilence(sound.getCategory())) {
SubTileBergamute berg = SubTileBergamute.getBergamuteNearby(sound.getXPosF(), sound.getYPosF(), sound.getZPosF());
if(sound instanceof ITickableSound) {
evt.setResultSound(new WrappedTickableSound((ITickableSound) sound, MULTIPLIER));
} else {
SubTileBergamute berg = SubTileBergamute.getBergamuteNearby(sound.getXPosF(), sound.getYPosF(), sound.getZPosF());
if (berg != null) {
evt.setResultSound(new WrappedSound(sound, MULTIPLIER));
if (berg != null) {
evt.setResultSound(new WrappedSound(sound, MULTIPLIER));
if (RAND.nextBoolean()) {
Color color = TilePool.PARTICLE_COLOR;
BotaniaAPI.internalHandler.sparkleFX(berg.getWorld(), berg.getPos().getX() + 0.3 + Math.random() * 0.5, berg.getPos().getY() + 0.5 + Math.random() * 0.5, berg.getPos().getZ() + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5);
if (RAND.nextBoolean()) {
Color color = TilePool.PARTICLE_COLOR;
BotaniaAPI.internalHandler.sparkleFX(berg.getWorld(), berg.getPos().getX() + 0.3 + Math.random() * 0.5, berg.getPos().getY() + 0.5 + Math.random() * 0.5, berg.getPos().getZ() + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5);
}
}
}
}
@@ -54,15 +60,18 @@ public class BergamuteEventHandler {
private final ISound compose;
private final float volMult;
private final boolean recheck;
private WrappedSound(ISound toWrap, float volMult) {
this.compose = toWrap;
this.volMult = volMult;
this.recheck = toWrap instanceof MovingSound;
}
@Override
public float getVolume() {
return compose.getVolume() * volMult;
float mult = recheck && SubTileBergamute.getBergamuteNearby(getXPosF(), getYPosF(), getZPosF()) == null ? 1F : volMult;
return compose.getVolume() * mult;
}
@Nonnull @Override public ResourceLocation getSoundLocation() { return compose.getSoundLocation(); }
@@ -77,4 +86,18 @@ public class BergamuteEventHandler {
@Override public float getZPosF() { return compose.getZPosF(); }
@Nonnull @Override public AttenuationType getAttenuationType() { return compose.getAttenuationType(); }
}
@SideOnly(Side.CLIENT)
private static class WrappedTickableSound extends WrappedSound implements ITickableSound {
private final ITickableSound compose;
private WrappedTickableSound(ITickableSound toWrap, float volMult) {
super(toWrap, volMult);
this.compose = toWrap;
}
@Override public boolean isDonePlaying() { return compose.isDonePlaying(); }
@Override public void update() { compose.update(); }
}
}
@@ -45,7 +45,7 @@ public class SubTileBergamute extends SubTileFunctional {
@Override
public int getColor() {
return 0x1FCBFF;
return 0xF46C6C;
}
@Override
@@ -50,19 +50,16 @@ public class SubTileBubbell extends SubTileFunctional {
if(ticksExisted % 10 == 0 && range < getRange())
range++;
for(int i = -range; i < range + 1; i++)
for(int j = -range; j < range + 1; j++)
for(int k = -range; k < range + 1; k++) {
BlockPos pos = supertile.getPos().add(i, j, k);
if(MathHelper.pointDistanceSpace(i, j, k, 0, 0, 0) < range) {
IBlockState state = supertile.getWorld().getBlockState(pos);
if(state.getMaterial() == Material.WATER) {
supertile.getWorld().setBlockState(pos, ModBlocks.fakeAir.getDefaultState(), 2);
TileFakeAir air = (TileFakeAir) supertile.getWorld().getTileEntity(pos);
air.setFlower(supertile);
}
}
for(BlockPos pos : BlockPos.getAllInBoxMutable(getPos().add(-range, -range, -range), getPos().add(range, range, range))) {
if(getPos().distanceSq(pos) < range * range) {
IBlockState state = supertile.getWorld().getBlockState(pos);
if(state.getMaterial() == Material.WATER) {
supertile.getWorld().setBlockState(pos, ModBlocks.fakeAir.getDefaultState(), 2);
TileFakeAir air = (TileFakeAir) supertile.getWorld().getTileEntity(pos);
air.setFlower(supertile);
}
}
}
}
}
@@ -39,51 +39,45 @@ public class SubTileExoflame extends SubTileFunctional {
boolean did = false;
fireFurnaces : {
for(int i = -RANGE; i < RANGE + 1; i++)
for(int j = -RANGE_Y; j < RANGE_Y + 1; j++)
for(int k = -RANGE; k < RANGE + 1; k++) {
BlockPos pos = supertile.getPos().add(i, j, k);
TileEntity tile = supertile.getWorld().getTileEntity(pos);
Block block = supertile.getWorld().getBlockState(pos).getBlock();
if(tile != null) {
if(tile instanceof TileEntityFurnace && (block == Blocks.FURNACE || block == Blocks.LIT_FURNACE)) {
TileEntityFurnace furnace = (TileEntityFurnace) tile;
boolean canSmelt = canFurnaceSmelt(furnace);
if(canSmelt && mana > 2) {
if(furnace.getField(0) < 2) { // Field 0 -> Burn time
if(furnace.getField(0) == 0)
BlockFurnace.setState(true, supertile.getWorld(), pos);
furnace.setField(0, 200);
mana = Math.max(0, mana - COST);
}
if(ticksExisted % 2 == 0)
furnace.setField(2, Math.min(199, furnace.getField(2) + 1)); // Field 2 -> cook time
did = true;
if(mana <= 0)
break fireFurnaces;
}
} else if(tile instanceof IExoflameHeatable) {
IExoflameHeatable heatable = (IExoflameHeatable) tile;
if(heatable.canSmelt() && mana > 2) {
if(heatable.getBurnTime() == 0) {
heatable.boostBurnTime();
mana = Math.max(0, mana - COST);
}
if(ticksExisted % 2 == 0)
heatable.boostCookTime();
if(mana <= 0)
break fireFurnaces;
}
}
for(BlockPos pos : BlockPos.getAllInBox(getPos().add(-RANGE, -RANGE_Y, -RANGE), getPos().add(RANGE, RANGE_Y, RANGE))) {
TileEntity tile = supertile.getWorld().getTileEntity(pos);
Block block = supertile.getWorld().getBlockState(pos).getBlock();
if(tile != null) {
if(tile instanceof TileEntityFurnace && (block == Blocks.FURNACE || block == Blocks.LIT_FURNACE)) {
TileEntityFurnace furnace = (TileEntityFurnace) tile;
boolean canSmelt = canFurnaceSmelt(furnace);
if(canSmelt && mana > 2) {
if(furnace.getField(0) < 2) { // Field 0 -> Burn time
if(furnace.getField(0) == 0)
BlockFurnace.setState(true, supertile.getWorld(), pos);
furnace.setField(0, 200);
mana = Math.max(0, mana - COST);
}
if(ticksExisted % 2 == 0)
furnace.setField(2, Math.min(199, furnace.getField(2) + 1)); // Field 2 -> cook time
did = true;
if(mana <= 0)
break;
}
} else if(tile instanceof IExoflameHeatable) {
IExoflameHeatable heatable = (IExoflameHeatable) tile;
if(heatable.canSmelt() && mana > 2) {
if(heatable.getBurnTime() == 0) {
heatable.boostBurnTime();
mana = Math.max(0, mana - COST);
}
if(ticksExisted % 2 == 0)
heatable.boostCookTime();
if(mana <= 0)
break;
}
}
}
}
if(did)
@@ -96,14 +96,11 @@ public class SubTileMarimorphosis extends SubTileFunctional {
int range = getRange();
int rangeY = getRangeY();
for(int i = -range; i < range + 1; i++)
for(int j = -rangeY; j < rangeY; j++)
for(int k = -range; k < range + 1; k++) {
BlockPos pos = supertile.getPos().add(i, j, k);
IBlockState state = supertile.getWorld().getBlockState(pos);
if(state.getBlock().isReplaceableOreGen(state, supertile.getWorld(), pos, BlockStateMatcher.forBlock(Blocks.STONE)))
possibleCoords.add(pos);
}
for(BlockPos pos : BlockPos.getAllInBox(getPos().add(-range, -rangeY, -range), getPos().add(range, rangeY, range))) {
IBlockState state = supertile.getWorld().getBlockState(pos);
if(state.getBlock().isReplaceableOreGen(state, supertile.getWorld(), pos, BlockStateMatcher.forBlock(Blocks.STONE)))
possibleCoords.add(pos);
}
if(possibleCoords.isEmpty())
return null;
@@ -103,14 +103,11 @@ public class SubTileOrechid extends SubTileFunctional {
List<BlockPos> possibleCoords = new ArrayList<>();
Block source = getSourceBlock();
for(int i = -RANGE; i < RANGE + 1; i++)
for(int j = -RANGE_Y; j < RANGE_Y; j++)
for(int k = -RANGE; k < RANGE + 1; k++) {
BlockPos pos = supertile.getPos().add(i, j, k);
IBlockState state = supertile.getWorld().getBlockState(pos);
if(state.getBlock().isReplaceableOreGen(state, supertile.getWorld(), pos, BlockStateMatcher.forBlock(source)))
possibleCoords.add(pos);
}
for(BlockPos pos : BlockPos.getAllInBox(getPos().add(-RANGE, -RANGE_Y, -RANGE), getPos().add(RANGE, RANGE_Y, RANGE))) {
IBlockState state = supertile.getWorld().getBlockState(pos);
if(state.getBlock().isReplaceableOreGen(state, supertile.getWorld(), pos, BlockStateMatcher.forBlock(source)))
possibleCoords.add(pos);
}
if(possibleCoords.isEmpty())
return null;
@@ -93,16 +93,15 @@ public class SubTileRannuncarpus extends SubTileFunctional {
Item stackItem = stack.getItem();
if(stackItem instanceof ItemBlock || stackItem instanceof ItemBlockSpecial || stackItem instanceof ItemRedstone || stackItem instanceof IFlowerPlaceable) {
if(!scanned) {
for(int i = -rangePlace; i < rangePlace + 1; i++)
for(int j = -rangePlaceY; j < rangePlaceY + 1; j++)
for(int l = -rangePlace; l < rangePlace + 1; l++) {
BlockPos pos_ = pos.add(i, j, l);
IBlockState stateAbove = supertile.getWorld().getBlockState(pos_.up());
Block blockAbove = stateAbove.getBlock();
if(filter == supertile.getWorld().getBlockState(pos_) && (blockAbove.isAir(stateAbove, supertile.getWorld(), pos_.up()) || blockAbove.isReplaceable(supertile.getWorld(), pos_.up())))
validPositions.add(pos_.up());
}
for(BlockPos pos_ : BlockPos.getAllInBox(pos.add(-rangePlace, -rangePlaceY, -rangePlace), pos.add(rangePlace, rangePlaceY, rangePlace))) {
IBlockState stateAbove = supertile.getWorld().getBlockState(pos_.up());
Block blockAbove = stateAbove.getBlock();
BlockPos up = pos_.up();
if(filter == supertile.getWorld().getBlockState(pos_)
&& (blockAbove.isAir(stateAbove, supertile.getWorld(), up)
|| blockAbove.isReplaceable(supertile.getWorld(), up)))
validPositions.add(up);
}
scanned = true;
}
@@ -141,7 +141,7 @@ public class SubTileSpectranthemum extends SubTileFunctional {
public boolean bindTo(EntityPlayer player, ItemStack wand, BlockPos pos, EnumFacing side) {
boolean bound = super.bindTo(player, wand, pos, side);
if(!bound && !pos.equals(bindPos) && MathHelper.pointDistanceSpace(pos, supertile.getPos()) <= BIND_RANGE && !(pos.equals(supertile.getPos()))) {
if(!bound && !pos.equals(bindPos) && pos.distanceSq(supertile.getPos()) <= BIND_RANGE * BIND_RANGE && !(pos.equals(supertile.getPos()))) {
bindPos = pos;
sync();
@@ -58,26 +58,22 @@ public class SubTileMunchdew extends SubTileGenerating {
List<BlockPos> coords = new ArrayList<>();
BlockPos pos = supertile.getPos();
for(int i = -RANGE; i < RANGE + 1; i++)
for(int j = 0; j < RANGE_Y; j++)
for(int k = -RANGE; k < RANGE + 1; k++) {
BlockPos pos_ = pos.add(i, j, k);
if(supertile.getWorld().getBlockState(pos_).getMaterial() == Material.LEAVES) {
boolean exposed = false;
for(EnumFacing dir : EnumFacing.VALUES) {
IBlockState offState = supertile.getWorld().getBlockState(pos_.offset(dir));
if(offState.getBlock().isAir(offState, supertile.getWorld(), pos_.offset(dir))) {
exposed = true;
break;
}
}
if(exposed)
coords.add(pos_);
for(BlockPos pos_ : BlockPos.getAllInBox(pos.add(-RANGE, -RANGE_Y, -RANGE), pos.add(RANGE, RANGE_Y, RANGE))) {
if(supertile.getWorld().getBlockState(pos_).getMaterial() == Material.LEAVES) {
boolean exposed = false;
for(EnumFacing dir : EnumFacing.VALUES) {
IBlockState offState = supertile.getWorld().getBlockState(pos_.offset(dir));
if(offState.getBlock().isAir(offState, supertile.getWorld(), pos_.offset(dir))) {
exposed = true;
break;
}
}
if(exposed)
coords.add(pos_);
}
}
if(coords.isEmpty())
break eatLeaves;
@@ -222,7 +222,8 @@ public class TileAlfPortal extends TileMod {
for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) {
if(recipe.matches(stacksIn, false)) {
recipe.matches(stacksIn, true);
spawnItem(recipe.getOutput().copy());
for(ItemStack output : recipe.getOutputs())
spawnItem(output.copy());
break;
}
}
@@ -16,6 +16,7 @@ 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.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import vazkii.botania.api.BotaniaAPI;
@@ -31,6 +32,7 @@ import vazkii.botania.common.Botania;
import vazkii.botania.common.block.ModBlocks;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.awt.*;
import java.util.List;
@@ -44,7 +46,7 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver {
int manaLastTick = 0;
public int signal = 0;
public boolean addItem(EntityPlayer player, ItemStack stack) {
public boolean addItem(@Nullable EntityPlayer player, ItemStack stack, @Nullable EnumHand hand) {
if(recipe != null || stack == null || stack.getItem() instanceof IBrewItem && ((IBrewItem) stack.getItem()).getBrew(stack) != null && ((IBrewItem) stack.getItem()).getBrew(stack) != BotaniaAPI.fallbackBrew || itemHandler.getStackInSlot(0) == null != stack.getItem() instanceof IBrewContainer)
return false;
@@ -60,7 +62,7 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver {
if(player == null || !player.capabilities.isCreativeMode) {
stack.stackSize--;
if(stack.stackSize == 0 && player != null)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
player.setHeldItem(hand, null);
}
break;
@@ -99,7 +101,7 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver {
for(EntityItem item : items)
if(!item.isDead && item.getEntityItem() != null) {
ItemStack stack = item.getEntityItem();
if(addItem(null, stack) && stack.stackSize == 0)
if(addItem(null, stack, null) && stack.stackSize == 0)
item.setDead();
}
}
@@ -371,7 +371,7 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
}
private boolean isEnchantmentValid(Enchantment ench) {
if(!ench.canApply(itemToEnchant) || !ench.type.canEnchantItem(itemToEnchant.getItem()))
if(!ench.canApply(itemToEnchant))
return false;
for(EnchantmentData data : enchants) {
@@ -160,7 +160,7 @@ public class TileLightRelay extends TileMod implements IWandBindable {
@Override
public boolean bindTo(EntityPlayer player, ItemStack wand, BlockPos pos, EnumFacing side) {
if(player.worldObj.getBlockState(pos).getBlock() != ModBlocks.lightRelay || MathHelper.pointDistanceSpace(pos, getPos()) > MAX_DIST)
if(player.worldObj.getBlockState(pos).getBlock() != ModBlocks.lightRelay || pos.distanceSq(getPos()) > MAX_DIST * MAX_DIST)
return false;
bindPos = pos;
@@ -19,6 +19,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import org.lwjgl.opengl.GL11;
@@ -35,6 +36,7 @@ import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.item.ModItems;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
@@ -53,7 +55,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver
List<ItemStack> lastRecipe = null;
int recipeKeepTicks = 0;
public boolean addItem(EntityPlayer player, ItemStack stack) {
public boolean addItem(@Nullable EntityPlayer player, ItemStack stack, @Nullable EnumHand hand) {
if(cooldown > 0 || stack.getItem() == ModItems.twigWand || stack.getItem() == ModItems.lexicon)
return false;
@@ -61,7 +63,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver
if(player == null || !player.capabilities.isCreativeMode) {
stack.stackSize--;
if(stack.stackSize == 0 && player != null)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
player.setHeldItem(hand, null);
}
EntityItem item = new EntityItem(worldObj, getPos().getX() + 0.5, getPos().getY() + 1, getPos().getZ() + 0.5, new ItemStack(ModBlocks.livingrock));
@@ -111,7 +113,7 @@ public class TileRuneAltar extends TileSimpleInventory implements IManaReceiver
for(EntityItem item : items)
if(!item.isDead && item.getEntityItem() != null && item.getEntityItem().getItem() != Item.getItemFromBlock(ModBlocks.livingrock)) {
ItemStack stack = item.getEntityItem();
if(addItem(null, stack) && stack.stackSize == 0)
if(addItem(null, stack, null) && stack.stackSize == 0)
item.setDead();
}
}
@@ -25,6 +25,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.subtile.ISubTileSlowableContainer;
@@ -165,6 +167,7 @@ public class TileSpecialFlower extends TileMod implements IWandBindable, ISubTil
return list;
}
@SideOnly(Side.CLIENT)
public void renderHUD(Minecraft mc, ScaledResolution res) {
if(subTile != null)
subTile.renderHUD(mc, res);
@@ -25,7 +25,7 @@ public class TileTinyPotato extends TileMod {
public void interact() {
jump();
if(name.equalsIgnoreCase("shia labeouf") && !worldObj.isRemote && nextDoIt == 0) {
if(name.toLowerCase().trim().endsWith("shia labeouf") && !worldObj.isRemote && nextDoIt == 0) {
nextDoIt = 40;
worldObj.playSound(null, pos, BotaniaSoundEvents.doit, SoundCategory.BLOCKS, 1F, 1F);
}
@@ -47,7 +47,7 @@ public class TileCorporeaRetainer extends TileMod {
this.request = request;
this.requestCount = requestCount;
pendingRequest = true;
worldObj.updateComparatorOutputLevel(pos, worldObj.getBlockState(pos).getBlock());
worldObj.updateComparatorOutputLevel(getPos(), worldObj.getBlockState(getPos()).getBlock());
}
public boolean hasPendingRequest() {
@@ -65,7 +65,7 @@ public class TileCorporeaRetainer extends TileMod {
ICorporeaRequestor requestor = (ICorporeaRequestor) inv.world.getTileEntity(inv.pos);
requestor.doCorporeaRequest(request, requestCount, spark);
pendingRequest = false;
worldObj.updateComparatorOutputLevel(pos, worldObj.getBlockState(pos).getBlock());
worldObj.updateComparatorOutputLevel(getPos(), worldObj.getBlockState(getPos()).getBlock());
}
}
}
@@ -301,7 +301,6 @@ public final class BotaniaCreativeTab extends CreativeTabs {
addBlock(ModBlocks.manaBeacon);
addItem(ModItems.signalFlare);
addStack(new ItemStack(Blocks.DIRT, 1, 1));
addBlock(ModBlocks.dirtPath);
addBlock(ModFluffBlocks.dirtPathSlab);
@@ -52,10 +52,6 @@ public final class MathHelper {
return ret;
}
public static float pointDistanceSpace(BlockPos p1, BlockPos p2) {
return pointDistanceSpace(p1.getX(), p1.getY(), p1.getZ(), p2.getX(), p2.getY(), p2.getZ());
}
public static float pointDistanceSpace(double x1, double y1, double z1, double x2, double y2, double z2) {
return (float) Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2));
}
@@ -167,7 +167,6 @@ public final class ModCraftingRecipes {
public static IRecipe recipeFireRod;
public static IRecipe recipeVineBall;
public static IRecipe recipeSlingshot;
public static IRecipe recipeMossStone;
public static IRecipe recipeLensInfluence;
public static IRecipe recipeLensWeight;
public static IRecipe recipeLensPaint;
@@ -1118,10 +1117,6 @@ public final class ModCraftingRecipes {
'A', LibOreDict.RUNE[3]);
recipeSlingshot = BotaniaAPI.getLatestAddedRecipe();
// Moss Stone Recipe
addShapelessOreDictRecipe(new ItemStack(Blocks.MOSSY_COBBLESTONE), "cobblestone", new ItemStack(ModItems.vineBall));
recipeMossStone = BotaniaAPI.getLatestAddedRecipe();
// Influence Lens Recipe
addOreDictRecipe(new ItemStack(ModItems.lens, 1, 12),
"PRP", "PLP", "PPP",
@@ -52,10 +52,8 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
private ICorporeaSpark master;
private List<ICorporeaSpark> connections = new ArrayList<>();
private List<ICorporeaSpark> connectionsClient = new ArrayList<>();
private List<ICorporeaSpark> relatives = new ArrayList<>();
private boolean firstUpdateClient = true;
private boolean firstUpdateServer = true;
private boolean firstTick = true;
public EntityCorporeaSpark(World world) {
super(world);
@@ -86,24 +84,25 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
@Override
public void onUpdate() {
super.onUpdate();
if(worldObj.isRemote)
return;
InvWithLocation inv = getSparkInventory();
if(inv == null) {
if(!worldObj.isRemote)
dropAndKill();
dropAndKill();
return;
}
if(isMaster())
master = this;
if(worldObj.isRemote ? firstUpdateClient : firstUpdateServer) {
if(firstTick) {
if(isMaster())
restartNetwork();
else findNetwork();
if(worldObj.isRemote)
firstUpdateClient = false;
else firstUpdateServer = false;
firstTick = false;
}
if(master != null && (((Entity) master).isDead || master.getNetwork() != getNetwork()))
@@ -125,7 +124,6 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
public void setDead() {
super.setDead();
connections.remove(this);
connectionsClient.remove(this);
restartNetwork();
}
@@ -143,20 +141,16 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
}
this.master = master;
if(worldObj.isRemote)
connectionsClient = connections;
else this.connections = connections;
this.connections = connections;
}
List<ICorporeaSpark> getNearbySparks() {
private List<ICorporeaSpark> getNearbySparks() {
List ret = worldObj.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(posX - SCAN_RANGE, posY - SCAN_RANGE, posZ - SCAN_RANGE, posX + SCAN_RANGE, posY + SCAN_RANGE, posZ + SCAN_RANGE), Predicates.instanceOf(ICorporeaSpark.class));
return ((List<ICorporeaSpark>) ret);
}
void restartNetwork() {
if(worldObj.isRemote)
connectionsClient = new ArrayList<>();
else connections = new ArrayList<>();
private void restartNetwork() {
connections = new ArrayList<>();
relatives = new ArrayList<>();
if(master != null) {
@@ -167,7 +161,7 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
}
}
void findNetwork() {
private void findNetwork() {
List<ICorporeaSpark> sparks = getNearbySparks();
if(sparks.size() > 0) {
for(ICorporeaSpark spark : sparks)
@@ -183,18 +177,18 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
}
}
void displayRelatives(ArrayList<ICorporeaSpark> checked, ICorporeaSpark spark) {
private static void displayRelatives(EntityPlayer player, List<ICorporeaSpark> checked, ICorporeaSpark spark) {
if(spark == null)
return;
List<ICorporeaSpark> sparks = spark.getRelatives();
if(sparks.isEmpty())
EntitySpark.particleBeam((Entity) spark, (Entity) spark.getMaster());
EntitySpark.particleBeam(player, (Entity) spark, (Entity) spark.getMaster());
else for(ICorporeaSpark endSpark : sparks) {
if(!checked.contains(endSpark)) {
EntitySpark.particleBeam((Entity) spark, (Entity) endSpark);
EntitySpark.particleBeam(player, (Entity) spark, (Entity) endSpark);
checked.add(endSpark);
displayRelatives(checked, endSpark);
displayRelatives(player, checked, endSpark);
}
}
}
@@ -209,7 +203,7 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
@Override
public List<ICorporeaSpark> getConnections() {
return worldObj.isRemote ? connectionsClient : connections;
return connections;
}
@Override
@@ -275,29 +269,30 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
if(stack != null) {
if(stack.getItem() == ModItems.twigWand) {
if(player.isSneaking()) {
if(!player.worldObj.isRemote)
if(!player.worldObj.isRemote) {
dropAndKill();
if(isMaster())
restartNetwork();
if(player.worldObj.isRemote)
player.swingArm(hand);
if(isMaster())
restartNetwork();
} else player.swingArm(hand);
return true;
} else {
displayRelatives(new ArrayList<>(), master);
if(!player.worldObj.isRemote) {
displayRelatives(player, new ArrayList<>(), master);
}
return true;
}
} else if(stack.getItem() == ModItems.dye) {
int color = stack.getItemDamage();
if(color != getNetwork().getMetadata()) {
setNetwork(EnumDyeColor.byMetadata(color));
if(!worldObj.isRemote) {
setNetwork(EnumDyeColor.byMetadata(color));
if(master != null)
restartNetwork();
else findNetwork();
if(master != null)
restartNetwork();
else findNetwork();
stack.stackSize--;
if(player.worldObj.isRemote)
player.swingArm(hand);
stack.stackSize--;
} else player.swingArm(hand);
}
}
}
@@ -12,8 +12,10 @@ package vazkii.botania.common.entity;
import baubles.common.lib.PlayerHandler;
import gnu.trove.map.hash.TObjectIntHashMap;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
@@ -215,9 +217,9 @@ public class EntitySpark extends Entity implements ISparkEntity {
getEntityId(), e.getEntityId()));
}
public static void particleBeam(Entity e1, Entity e2) {
public static void particleBeam(EntityPlayer player, Entity e1, Entity e2) {
if(e1 != null && e2 != null && !e1.worldObj.isRemote) {
PacketHandler.sendToNearby(e1.worldObj, e1,
PacketHandler.sendTo(((EntityPlayerMP) player),
new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.SPARK_NET_INDICATOR, e1.posX, e1.posY, e1.posZ,
e1.getEntityId(), e2.getEntityId()));
}
@@ -258,7 +260,7 @@ public class EntitySpark extends Entity implements ISparkEntity {
} else {
List<ISparkEntity> allSparks = SparkHelper.getSparksAround(worldObj, posX, posY, posZ);
for(ISparkEntity spark : allSparks)
particleBeam(this, (Entity) spark);
particleBeam(player, this, (Entity) spark);
return true;
}
} else if(stack.getItem() == ModItems.sparkUpgrade && upgrade == SparkUpgradeType.NONE) {
@@ -40,7 +40,7 @@ public class EntityThrownItem extends EntityItem {
pickupDelay = (int) MethodHandles.pickupDelay_getter.invokeExact(item);
} catch (Throwable ignored) {}
item.setPickupDelay(pickupDelay);
setPickupDelay(pickupDelay);
motionX = item.motionX;
motionY = item.motionY;
motionZ = item.motionZ;
@@ -63,12 +63,10 @@ public class EntityThrownItem extends EntityItem {
if (!worldObj.isRemote)
{
Entity entity = null;
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, getEntityBoundingBox().addCoord(motionX*2, motionY*2, motionZ*2).expand(2.0D, 2.0D, 2.0D));
List<Entity> list = worldObj.getEntitiesWithinAABBExcludingEntity(this, getEntityBoundingBox().addCoord(motionX*2, motionY*2, motionZ*2).expand(2.0D, 2.0D, 2.0D));
double d0 = 0.0D;
for (Object aList : list) {
Entity entity1 = (Entity) aList;
for (Entity entity1 : list) {
int pickupDelay;
try {
pickupDelay = (int) MethodHandles.pickupDelay_getter.invokeExact(this);
@@ -69,55 +69,58 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
if(getBlock(par1ItemStack) != Blocks.AIR && player.isSneaking()) {
int dmg = par1ItemStack.getItemDamage();
par1ItemStack.setItemDamage(~dmg & 1);
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
if(getBlock(stack) != Blocks.AIR && player.isSneaking()) {
int dmg = stack.getItemDamage();
stack.setItemDamage(~dmg & 1);
player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 0.3F, 0.1F);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
IBlockState state = world.getBlockState(pos);
boolean set = setBlock(stack, state.getBlock(), state.getBlock().getMetaFromState(state));
if(!set) {
if (Item.getItemFromBlock(state.getBlock()) != null
&& setBlock(stack, state.getBlock(), state.getBlock().getMetaFromState(state))) {
return EnumActionResult.SUCCESS;
} else {
Block bBlock = getBlock(stack);
int bmeta = getBlockMeta(stack);
if(bBlock == null)
return EnumActionResult.PASS;
TileEntity tile = world.getTileEntity(pos);
if(tile != null && tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) {
IItemHandler inv = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
ItemStack toAdd = new ItemStack(bBlock, 1, bmeta);
int maxSize = toAdd.getMaxStackSize();
toAdd.stackSize = remove(stack, maxSize);
ItemStack remainder = ItemHandlerHelper.insertItemStacked(inv, toAdd, false);
if(remainder != null)
add(stack, remainder.stackSize);
if(!world.isRemote) {
IItemHandler inv = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
ItemStack toAdd = new ItemStack(bBlock, 1, bmeta);
int maxSize = toAdd.getMaxStackSize();
toAdd.stackSize = remove(stack, maxSize);
ItemStack remainder = ItemHandlerHelper.insertItemStacked(inv, toAdd, false);
if(remainder != null)
add(stack, remainder.stackSize);
}
return EnumActionResult.SUCCESS;
} else {
int entities = world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos.offset(side), pos.offset(side).add(1, 1, 1))).size();
BlockPos correctedPos = bBlock.isReplaceable(world, pos) ? pos : pos.offset(side);
if(player.capabilities.isCreativeMode || getBlockCount(stack) > 0) {
ItemStack toUse = new ItemStack(bBlock, 1, bmeta);
if(entities == 0 && !(correctedPos.getY() < 0) && !(correctedPos.getY() >= 256)) {
int remove = player.capabilities.isCreativeMode ? 1 : remove(stack, 1);
if(remove > 0) {
ItemStack toUse = new ItemStack(bBlock, 1, bmeta);
if (Item.getItemFromBlock(bBlock).onItemUse(toUse, player, world, pos, hand, side, hitX, hitY, hitZ) == EnumActionResult.SUCCESS) {
remove(stack, 1);
ItemsRemainingRenderHandler.set(toUse, getBlockCount(stack));
Item.getItemFromBlock(bBlock).onItemUse(toUse, player, world, pos, hand, side, hitX, hitY, hitZ);
set = true;
return EnumActionResult.SUCCESS;
}
}
}
}
player.setItemStackToSlot(hand == EnumHand.MAIN_HAND ? EntityEquipmentSlot.MAINHAND : EntityEquipmentSlot.OFFHAND, stack);
return set ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
return EnumActionResult.PASS;
}
@Override
@@ -210,7 +213,7 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
}
private boolean setBlock(ItemStack stack, Block block, int meta) {
if(getBlock(stack) == Blocks.AIR || getBlockCount(stack) == 0) {
if(Item.getItemFromBlock(block) != null && (getBlock(stack) == Blocks.AIR || getBlockCount(stack) == 0)) {
ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, Block.REGISTRY.getNameForObject(block).toString());
ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta);
return true;
@@ -257,8 +260,7 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
}
public static Block getBlock(ItemStack stack) {
Block block = Block.getBlockFromName(getBlockName(stack));
return block;
return Block.getBlockFromName(getBlockName(stack));
}
public static int getBlockMeta(ItemStack stack) {
@@ -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 @ [Jun 27, 2014, 2:41:19 AM (GMT)]
*/
package vazkii.botania.common.item;
@@ -54,7 +54,7 @@ public class ItemBottledMana extends ItemMod {
setMaxDamage(6);
}
public void effect(EntityLivingBase living, int id) {
public void effect(ItemStack stack, EntityLivingBase living, int id) {
switch(id) {
case 0 : { // Random motion
living.motionX = (Math.random() - 0.5) * 3;
@@ -98,13 +98,14 @@ public class ItemBottledMana extends ItemMod {
case 7 : { // All your inventory is belong to us
if(!living.worldObj.isRemote && living instanceof EntityPlayer) {
EntityPlayer player = ((EntityPlayer) living);
for(int i = 0; i < player.inventory.getSizeInventory(); i++)
if(i != player.inventory.currentItem) {
ItemStack stackAt = player.inventory.getStackInSlot(i);
for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stackAt = player.inventory.getStackInSlot(i);
if(stackAt != stack) {
if(stackAt != null)
player.entityDropItem(stackAt, 0);
player.inventory.setInventorySlotContents(i, null);
}
}
}
break;
@@ -179,9 +180,9 @@ public class ItemBottledMana extends ItemMod {
case 15 : { // Drop own Head
if(!living.worldObj.isRemote && living instanceof EntityPlayer) {
living.attackEntityFrom(DamageSource.magic, living.getHealth() - 1);
ItemStack stack = new ItemStack(Items.SKULL, 1, 3);
ItemNBTHelper.setString(stack, "SkullOwner", living.getName());
living.entityDropItem(stack, 0);
ItemStack skull = new ItemStack(Items.SKULL, 1, 3);
ItemNBTHelper.setString(skull, "SkullOwner", living.getName());
living.entityDropItem(skull, 0);
}
break;
}
@@ -189,15 +190,13 @@ public class ItemBottledMana extends ItemMod {
}
@Override
public void onUpdate(ItemStack par1ItemStack, World world, Entity par3Entity, int par4, boolean par5) {
getSeed(par1ItemStack);
public void onUpdate(ItemStack par1ItemStack, World world, Entity par3Entity, int par4, boolean par5) {}
private void randomEffect(EntityLivingBase player, ItemStack stack) {
effect(stack, player, new Random(getSeed(stack)).nextInt(16));
}
public void randomEffect(EntityLivingBase player, ItemStack stack) {
effect(player, new Random(getSeed(stack)).nextInt(16));
}
long getSeed(ItemStack stack) {
private long getSeed(ItemStack stack) {
long seed = ItemNBTHelper.getLong(stack, TAG_SEED, -1);
if(seed == -1)
return randomSeed(stack);
@@ -36,6 +36,9 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.core.helpers.Strings;
import vazkii.botania.api.sound.BotaniaSoundEvents;
import vazkii.botania.common.Botania;
import vazkii.botania.common.achievement.ICraftAchievement;
import vazkii.botania.common.achievement.ModAchievements;
import vazkii.botania.common.block.ModBlocks;
@@ -45,13 +48,14 @@ import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.lib.LibObfuscation;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
public class ItemCacophonium extends ItemMod implements ICraftAchievement {
private static final String TAG_SOUND = "sound";
private static final String TAG_SOUND_NAME = "soundName";
private static final String TAG_HAS_SOUND = "hasSound";
public ItemCacophonium() {
super(LibItemNames.CACOPHONIUM);
@@ -62,32 +66,33 @@ public class ItemCacophonium extends ItemMod implements ICraftAchievement {
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity, EnumHand hand) {
if(entity instanceof EntityLiving) {
EntityLiving living = (EntityLiving) entity;
SoundEvent sound;
try {
if(living instanceof EntityCreeper)
sound = SoundEvents.ENTITY_CREEPER_PRIMED;
else if(living instanceof EntitySlime)
sound = ((EntitySlime) living).isSmallSlime() ? SoundEvents.ENTITY_SMALL_SLIME_SQUISH : SoundEvents.ENTITY_SLIME_SQUISH;
else sound = (SoundEvent) ReflectionHelper.findMethod(EntityLiving.class, living, LibObfuscation.GET_LIVING_SOUND).invoke(living);
SoundEvent sound = null;
if(sound != null) {
String s = EntityList.getEntityString(entity);
if(s == null)
s = "generic";
ItemNBTHelper.setString(stack, TAG_SOUND, sound.getRegistryName().toString());
ItemNBTHelper.setString(stack, TAG_SOUND_NAME, "entity." + s + ".name");
ItemNBTHelper.setBoolean(stack, TAG_HAS_SOUND, true);
player.setHeldItem(hand, stack);
//player.inventory.setInventorySlotContents(player.inventory.currentItem, stack.copy());
if(player.worldObj.isRemote)
player.swingArm(hand);
return true;
if(living instanceof EntityCreeper)
sound = SoundEvents.ENTITY_CREEPER_PRIMED;
else if(living instanceof EntitySlime)
sound = ((EntitySlime) living).isSmallSlime() ? SoundEvents.ENTITY_SMALL_SLIME_SQUISH : SoundEvents.ENTITY_SLIME_SQUISH;
else {
try {
sound = (SoundEvent) ReflectionHelper.findMethod(EntityLiving.class, living, LibObfuscation.GET_LIVING_SOUND).invoke(living);
} catch (InvocationTargetException | IllegalAccessException ignored) {
Botania.LOGGER.debug("Couldn't get living sound");
}
} catch (Exception e) {
e.printStackTrace();
}
if(sound != null) {
String s = EntityList.getEntityString(entity);
if(s == null)
s = "generic";
ItemNBTHelper.setString(stack, TAG_SOUND, sound.getRegistryName().toString());
ItemNBTHelper.setString(stack, TAG_SOUND_NAME, "entity." + s + ".name");
player.setHeldItem(hand, stack);
if(player.worldObj.isRemote)
player.swingArm(hand);
return true;
}
}
@@ -97,15 +102,7 @@ public class ItemCacophonium extends ItemMod implements ICraftAchievement {
@Nonnull
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
boolean can = isDOIT(stack);
if(!can) {
String sound = ItemNBTHelper.getString(stack, TAG_SOUND, "");
isDOIT(stack);
if(sound != null && !sound.isEmpty())
can = true;
}
if(can) {
if(getSound(stack) != null) {
Block block = world.getBlockState(pos).getBlock();
if(block == Blocks.NOTEBLOCK) {
world.setBlockState(pos, ModBlocks.cacophonium.getDefaultState());
@@ -123,7 +120,7 @@ public class ItemCacophonium extends ItemMod implements ICraftAchievement {
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean adv) {
if(isDOIT(stack))
list.add(I18n.format("botaniamisc.justDoIt"));
else if(ItemNBTHelper.getBoolean(stack, TAG_HAS_SOUND, false))
else if(getSound(stack) != null)
list.add(I18n.format(ItemNBTHelper.getString(stack, TAG_SOUND_NAME, "")));
}
@@ -140,10 +137,10 @@ public class ItemCacophonium extends ItemMod implements ICraftAchievement {
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
if(ItemNBTHelper.getBoolean(par1ItemStack, TAG_HAS_SOUND, false) || isDOIT(par1ItemStack))
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
if(getSound(stack) != null)
player.setActiveHand(hand);
return ActionResult.newResult(EnumActionResult.SUCCESS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
@Override
@@ -156,13 +153,17 @@ public class ItemCacophonium extends ItemMod implements ICraftAchievement {
if(stack == null)
return;
String sound = ItemNBTHelper.getString(stack, TAG_SOUND, "");
boolean doit = isDOIT(stack);
if(doit)
sound = "botania:doit";
SoundEvent sound = getSound(stack);
if(sound != null && !sound.isEmpty() && SoundEvent.REGISTRY.containsKey(new ResourceLocation(sound)))
world.playSound(null, x, y, z, SoundEvent.REGISTRY.getObject(new ResourceLocation(sound)), category, volume, doit ? 1F : (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F + 1.0F);
if(sound != null)
world.playSound(null, x, y, z, sound, category, volume, sound == BotaniaSoundEvents.doit ? 1F : (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F + 1.0F);
}
@Nullable
private static SoundEvent getSound(ItemStack stack) {
if(isDOIT(stack))
return BotaniaSoundEvents.doit;
else return SoundEvent.REGISTRY.getObject(new ResourceLocation(ItemNBTHelper.getString(stack, TAG_SOUND, "")));
}
private static boolean isDOIT(ItemStack stack) {
@@ -44,20 +44,22 @@ public class ItemEnderHand extends ItemMod implements IManaUsingItem, IBlockProv
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
if(ManaItemHandler.requestManaExact(stack, player, COST_SELF, false)) {
player.displayGUIChest(player.getInventoryEnderChest());
if(!player.worldObj.isRemote)
player.displayGUIChest(player.getInventoryEnderChest());
ManaItemHandler.requestManaExact(stack, player, COST_SELF, true);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1F, 1F);
player.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1F, 1F);
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer iplayer, EntityLivingBase entity, EnumHand hand) {
if(ConfigHandler.enderPickpocketEnabled && entity instanceof EntityPlayer && ManaItemHandler.requestManaExact(stack, iplayer, COST_OTHER, false)) {
iplayer.displayGUIChest(((EntityPlayer) entity).getInventoryEnderChest());
ManaItemHandler.requestManaExact(stack, iplayer, COST_OTHER, true);
entity.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1F, 1F);
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity, EnumHand hand) {
if(ConfigHandler.enderPickpocketEnabled && entity instanceof EntityPlayer && ManaItemHandler.requestManaExact(stack, player, COST_OTHER, false)) {
if(!player.worldObj.isRemote)
player.displayGUIChest(((EntityPlayer) entity).getInventoryEnderChest());
ManaItemHandler.requestManaExact(stack, player, COST_OTHER, true);
player.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1F, 1F);
return true;
}
@@ -112,24 +112,24 @@ public class ItemGrassHorn extends ItemMod {
int rangeY = 3 + stackDmg * 4;
List<BlockPos> coords = new ArrayList<>();
for(int i = -range; i < range + 1; i++)
for(int j = -range; j < range + 1; j++)
for(int k = -rangeY; k < rangeY + 1; k++) {
BlockPos pos = srcPos.add(i, k, j);
Block block = world.getBlockState(pos).getBlock();
if(block instanceof IHornHarvestable ? ((IHornHarvestable) block).canHornHarvest(world, pos, stack, type) : stackDmg == 0 && block instanceof BlockBush && !(block instanceof ISpecialFlower) || stackDmg == 1 && block.isLeaves(world.getBlockState(pos), world, pos) || stackDmg == 2 && block == Blocks.SNOW_LAYER)
coords.add(pos);
}
for(BlockPos pos : BlockPos.getAllInBox(srcPos.add(-range, -rangeY, -range), srcPos.add(range, rangeY, range))) {
Block block = world.getBlockState(pos).getBlock();
if(block instanceof IHornHarvestable
? ((IHornHarvestable) block).canHornHarvest(world, pos, stack, type)
: stackDmg == 0 && block instanceof BlockBush && !(block instanceof ISpecialFlower)
|| stackDmg == 1 && block.isLeaves(world.getBlockState(pos), world, pos)
|| stackDmg == 2 && block == Blocks.SNOW_LAYER)
coords.add(pos);
}
Collections.shuffle(coords, rand);
int count = Math.min(coords.size(), 32 + stackDmg * 16);
for(int i = 0; i < count; i++) {
BlockPos currCoords = coords.get(i);
List<ItemStack> items = new ArrayList<>();
IBlockState state = world.getBlockState(currCoords);
Block block = state.getBlock();
items.addAll(block.getDrops(world, currCoords, state, 0));
List<ItemStack> items = block.getDrops(world, currCoords, state, 0);
if(block instanceof IHornHarvestable && ((IHornHarvestable) block).hasSpecialHornHarvest(world, currCoords, stack, type))
((IHornHarvestable) block).harvestByHorn(world, currCoords, stack, type);
@@ -279,21 +279,10 @@ public class ItemGrassSeeds extends ItemMod implements IFloatingFlowerVariant {
* should be removed.
*/
public boolean tick() {
++ticksExisted;
// Go through all blocks in the specified RANGE, and then
// try and spread around that block if it is our target block already
for(int i = -RANGE; i <= RANGE; i++) {
for(int j = -RANGE; j <= RANGE; j++) {
BlockPos pos = startCoords.add(i, 0, j);
IBlockState state = world.getBlockState(pos);
if(state == stateToSet) {
// Only make changes every 20 ticks
if(ticksExisted % 20 != 0) continue;
if(++ticksExisted % 20 == 0) {
for(BlockPos pos : BlockPos.getAllInBox(startCoords.add(-RANGE, 0, -RANGE), startCoords.add(RANGE, 0, RANGE))) {
if(world.getBlockState(pos) == stateToSet)
tickBlock(pos);
}
}
}
@@ -12,6 +12,7 @@ package vazkii.botania.common.item;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@@ -29,6 +30,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -75,9 +77,6 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem, IColorable {
RecipeSorter.register("botania:manaGunLens", ManaGunLensRecipe.class, Category.SHAPELESS, "");
RecipeSorter.register("botania:manaGunRemoveLens", ManaGunRemoveLensRecipe.class, Category.SHAPELESS, "");
RecipeSorter.register("botania:manaGunClip", ManaGunClipRecipe.class, Category.SHAPELESS, "");
addPropertyOverride(new ResourceLocation("botania", "clip"), (itemStack, world, entityLivingBase) -> hasClip(itemStack) ? 1 : 0);
addPropertyOverride(new ResourceLocation("botania", "desu"), (itemStack, world, entityLivingBase) -> isSugoiKawaiiDesuNe(itemStack) ? 1 : 0);
}
@Nonnull
@@ -141,17 +140,21 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem, IColorable {
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack par1ItemStack, int tintIndex) {
if(tintIndex != 1)
return 0xFFFFFF;
public int getColorFromItemStack(ItemStack stack, int tintIndex) {
ItemStack lens = getLens(stack);
if(lens != null && tintIndex == 0)
return ((IColorable) ModItems.lens).getColorFromItemStack(lens, tintIndex);
EntityManaBurst burst = getBurst(Minecraft.getMinecraft().thePlayer, par1ItemStack, false);
Color color = new Color(burst == null ? 0x20FF20 : burst.getColor());
if(tintIndex == 2) {
EntityManaBurst burst = getBurst(Minecraft.getMinecraft().thePlayer, stack, false);
Color color = new Color(burst == null ? 0x20FF20 : burst.getColor());
float mul = (float) (Math.sin((double) ClientTickHandler.ticksInGame / 5) * 0.15F);
int c = (int) (255 * mul);
float mul = (float) (Math.sin((double) ClientTickHandler.ticksInGame / 5) * 0.15F);
int c = (int) (255 * mul);
return new Color(Math.max(0, Math.min(255, color.getRed() + c)), Math.max(0, Math.min(255, color.getGreen() + c)), Math.max(0, Math.min(255, color.getBlue() + c))).getRGB();
} else return 0xFFFFFF;
return new Color(Math.max(0, Math.min(255, color.getRed() + c)), Math.max(0, Math.min(255, color.getGreen() + c)), Math.max(0, Math.min(255, color.getBlue() + c))).getRGB();
}
@Override
@@ -331,4 +334,23 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem, IColorable {
public boolean usesMana(ItemStack stack) {
return true;
}
@SideOnly(Side.CLIENT)
@Override
public void registerModels() {
ModelLoader.registerItemVariants(this,
new ModelResourceLocation("botania:desuGunClip", "inventory"),
new ModelResourceLocation("botania:desuGun", "inventory"),
new ModelResourceLocation("botania:manaGunClip", "inventory"),
new ModelResourceLocation("botania:manaGun", "inventory"));
ModelLoader.setCustomMeshDefinition(this, stack -> {
if (hasClip(stack) && isSugoiKawaiiDesuNe(stack))
return new ModelResourceLocation("botania:desuGunClip", "inventory");
else if (isSugoiKawaiiDesuNe(stack))
return new ModelResourceLocation("botania:desuGun", "inventory");
else if(hasClip(stack))
return new ModelResourceLocation("botania:manaGunClip", "inventory");
else return new ModelResourceLocation("botania:manaGun", "inventory");
});
}
}
@@ -46,23 +46,20 @@ public class ItemObedienceStick extends ItemMod {
Actuator act = pool ? Actuator.functionalActuator : Actuator.generatingActuator;
int range = pool ? SubTileFunctional.LINK_RANGE : SubTileGenerating.LINK_RANGE;
for(int i = -range; i < range + 1; i++)
for(int j = -range; j < range + 1; j++)
for(int k = -range; k < range + 1; k++) {
BlockPos pos_ = pos.add(i, j, k);
if(MathHelper.pointDistanceSpace(pos_, pos) > range)
continue;
for(BlockPos pos_ : BlockPos.getAllInBox(pos.add(-range, -range, -range), pos.add(range, range, range))) {
if(pos_.distanceSq(pos) > range * range)
continue;
TileEntity tile = world.getTileEntity(pos_);
if(tile instanceof ISubTileContainer) {
SubTileEntity subtile = ((ISubTileContainer) tile).getSubTile();
if(act.actuate(subtile, tileAt)) {
Vector3 orig = new Vector3(pos_.getX() + 0.5, pos_.getY() + 0.5, pos_.getZ() + 0.5);
Vector3 end = new Vector3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
ItemTwigWand.doParticleBeam(world, orig, end);
}
}
TileEntity tile = world.getTileEntity(pos_);
if(tile instanceof ISubTileContainer) {
SubTileEntity subtile = ((ISubTileContainer) tile).getSubTile();
if(act.actuate(subtile, tileAt)) {
Vector3 orig = new Vector3(pos_.getX() + 0.5, pos_.getY() + 0.5, pos_.getZ() + 0.5);
Vector3 end = new Vector3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
ItemTwigWand.doParticleBeam(world, orig, end);
}
}
}
if(player.worldObj.isRemote)
player.swingArm(hand);
@@ -57,20 +57,22 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack par1ItemStack, World world, EntityPlayer player, EnumHand hand) {
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
if(!EntityDoppleganger.isTruePlayer(player))
return ActionResult.newResult(EnumActionResult.FAIL, par1ItemStack);
return ActionResult.newResult(EnumActionResult.FAIL, stack);
if(canEquip(par1ItemStack, player)) {
ItemStack toEquip = stack.copy();
toEquip.stackSize = 1;
if(canEquip(toEquip, player)) {
InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player);
for(int i = 0; i < baubles.getSizeInventory(); i++) {
if(baubles.isItemValidForSlot(i, par1ItemStack)) {
if(baubles.isItemValidForSlot(i, toEquip)) {
ItemStack stackInSlot = baubles.getStackInSlot(i);
if(stackInSlot == null || ((IBauble) stackInSlot.getItem()).canUnequip(stackInSlot, player)) {
if(!world.isRemote) {
baubles.setInventorySlotContents(i, par1ItemStack.copy());
if(!player.capabilities.isCreativeMode)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
baubles.setInventorySlotContents(i, toEquip);
stack.stackSize--;
}
if(stackInSlot != null) {
@@ -83,7 +85,7 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
}
}
return ActionResult.newResult(EnumActionResult.PASS, par1ItemStack);
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
@Override
@@ -45,7 +45,7 @@ import java.util.List;
public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble {
private enum Variants {
public enum Variants {
BLACK_BOWTIE, BLACK_TIE, RED_GLASSES, PUFFY_SCARF,
ENGINEER_GOGGLES, EYEPATCH, WICKED_EYEPATCH, RED_RIBBONS,
PINK_FLOWER_BUD, POLKA_DOTTED_BOWS, BLUE_BUTTERFLY, CAT_EARS,
@@ -16,6 +16,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.RayTraceResult;
import vazkii.botania.api.item.ISortableTool;
import vazkii.botania.api.item.ISortableTool.ToolType;
@@ -78,7 +79,7 @@ public class ItemSwapRing extends ItemBauble {
}
if(bestSlot != -1) {
player.inventory.setInventorySlotContents(player.inventory.currentItem, bestTool);
player.setHeldItem(EnumHand.MAIN_HAND, bestTool);
player.inventory.setInventorySlotContents(bestSlot, currentStack);
}
}
@@ -16,6 +16,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.MathHelper;
import vazkii.botania.api.mana.IManaSpreader;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.tile.mana.TileSpreader;
import java.awt.*;
@@ -48,22 +49,20 @@ public class LensFlare extends Lens {
float my = (float) (MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI) * f / 2D);
int storedColor = ItemLens.getStoredColor(stack);
float r = 1, g = 1, b = 1;
int hex = -1;
TileEntity tile = (TileEntity) spreader;
if(storedColor == 16) {
Color c = Color.getHSBColor(tile.getWorld().getTotalWorldTime() * 2 % 360 / 360F, 1F, 1F);
r = c.getRed() / 255F;
g = c.getGreen() / 255F;
b = c.getBlue() / 255F;
hex = Color.HSBtoRGB(tile.getWorld().getTotalWorldTime() * 2 % 360 / 360F, 1F, 1F);
} else if(storedColor >= 0) {
int hex = EnumDyeColor.byMetadata(storedColor).getMapColor().colorValue;
r = (hex & 0xFF0000) >> 16;
g = (hex & 0xFF00) >> 8;
b = (hex & 0xFF);
hex = EnumDyeColor.byMetadata(storedColor).getMapColor().colorValue;
}
Botania.proxy.wispFX(tile.getWorld(), tile.getPos().getX() + 0.5, tile.getPos().getY() + 0.5, tile.getPos().getZ() + 0.5, r / 255F, g / 255F, b / 255F, 0.4F, mx, my, mz);
float r = ((hex & 0xFF0000) >> 16) / 255F;
float g = ((hex & 0xFF00) >> 8) / 255F;
float b = (hex & 0xFF) / 255F;
Botania.proxy.wispFX(tile.getWorld(), tile.getPos().getX() + 0.5, tile.getPos().getY() + 0.5, tile.getPos().getZ() + 0.5, r, g, b, 0.4F, mx, my, mz);
}
}
@@ -49,7 +49,7 @@ public class LensMagnet extends Lens {
BlockPos srcCoords = burst.getBurstSourceBlockPos();
if(MathHelper.pointDistanceSpace(tile.getPos(), srcCoords) > 3 && receiver.canRecieveManaFromBursts() && !receiver.isFull()) {
if(tile.getPos().distanceSq(srcCoords) > 9 && receiver.canRecieveManaFromBursts() && !receiver.isFull()) {
Vector3 burstVec = Vector3.fromEntity(entity);
Vector3 tileVec = Vector3.fromTileEntityCenter(tile).add(0, -0.1, 0);
Vector3 motionVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ);
Loaded 100 of 126 files, more files were not shown because too many files have changed in this diff. Show more