mirror of
https://github.com/GTNewHorizons/Avaritia.git
synced 2026-11-20 12:19:39 +00:00
BALLS OF... well, everything really.
This commit is contained in:
1 parent
2ce89feeab
commit
97f87ce024
21 files changed
+726
-56
No files matched your search
@@ -38,6 +38,7 @@ public class ClientProxy extends CommonProxy {
|
||||
MinecraftForgeClient.registerItemRenderer(LudicrousItems.infinity_armor, sparkly);
|
||||
MinecraftForgeClient.registerItemRenderer(LudicrousItems.infinity_pants, sparkly);
|
||||
MinecraftForgeClient.registerItemRenderer(LudicrousItems.infinity_shoes, sparkly);
|
||||
MinecraftForgeClient.registerItemRenderer(LudicrousItems.matter_cluster, sparkly);
|
||||
|
||||
MinecraftForgeClient.registerItemRenderer(LudicrousItems.fractured_ore, new FracturedOreRenderer());
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package fox.spiteful.avaritia;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import fox.spiteful.avaritia.items.ItemArmorInfinity;
|
||||
import fox.spiteful.avaritia.items.ItemFracturedOre;
|
||||
import fox.spiteful.avaritia.items.ItemMatterCluster;
|
||||
import fox.spiteful.avaritia.items.LudicrousItems;
|
||||
import fox.spiteful.avaritia.items.tools.ItemPickaxeInfinity;
|
||||
import fox.spiteful.avaritia.items.tools.ItemSwordInfinity;
|
||||
@@ -25,6 +26,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
@@ -83,6 +85,7 @@ public class LudicrousEvents {
|
||||
if(held.getItem() == LudicrousItems.infinity_pickaxe){
|
||||
if(event.block.getMaterial() == Material.rock){
|
||||
List<ItemStack> adds = new ArrayList<ItemStack>();
|
||||
List<ItemStack> removals = new ArrayList<ItemStack>();
|
||||
for(ItemStack drop : event.drops){
|
||||
if(drop.getItem() != Item.getItemFromBlock(event.block) && !(drop.getItem() instanceof ItemBlock)){
|
||||
drop.stackSize = Math.min(drop.stackSize * 4, drop.getMaxStackSize());
|
||||
@@ -95,13 +98,24 @@ public class LudicrousEvents {
|
||||
String orename = OreDictionary.getOreName(oreids[i]);
|
||||
if (orename.startsWith("ore")) {
|
||||
// add the fractured ores
|
||||
adds.add(ifo.getStackForOre(drop, Math.min(drop.stackSize * 4, drop.getMaxStackSize())));
|
||||
adds.add(ifo.getStackForOre(drop, Math.min(drop.stackSize * 5, drop.getMaxStackSize())));
|
||||
removals.add(drop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
event.drops.addAll(adds);
|
||||
event.drops.removeAll(removals);
|
||||
}
|
||||
|
||||
if (held.getTagCompound().getBoolean("hammer")
|
||||
&& ToolHelper.hammering.contains(event.harvester)
|
||||
&& ToolHelper.hammerdrops.containsKey(event.harvester)
|
||||
&& ToolHelper.hammerdrops.get(event.harvester) != null) {
|
||||
|
||||
ToolHelper.hammerdrops.get(event.harvester).addAll(event.drops);
|
||||
event.drops.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,4 +217,21 @@ public class LudicrousEvents {
|
||||
event.drops.add(entityitem);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void clusterClustererererer(EntityItemPickupEvent event) {
|
||||
if(event.entityPlayer != null && event.item.getEntityItem().getItem() == LudicrousItems.matter_cluster) {
|
||||
ItemStack stack = event.item.getEntityItem();
|
||||
EntityPlayer player = event.entityPlayer;
|
||||
|
||||
for (int i=0; i<player.inventory.mainInventory.length; i++) {
|
||||
if (stack.stackSize == 0) {
|
||||
break;
|
||||
}
|
||||
ItemStack slot = player.inventory.mainInventory[i];
|
||||
if (slot != null && slot.getItem() != null && slot.getItem() == LudicrousItems.matter_cluster) {
|
||||
ItemMatterCluster.mergeClusters(stack, slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package fox.spiteful.avaritia.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.stats.AchievementList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
|
||||
@Deprecated // maybe someday... but not today
|
||||
public class EntityCollationItem extends EntityItem {
|
||||
public static final String ITEMTAG = "item";
|
||||
|
||||
public EntityCollationItem(World world, double x, double y, double z, Collection<ItemStack> items) {
|
||||
super(world, x,y,z);
|
||||
ItemStack watchstack = new ItemStack(Blocks.bedrock);
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
NBTTagList itemlist = new NBTTagList();
|
||||
|
||||
for (ItemStack stack : items) {
|
||||
NBTTagCompound itemtag = stack.writeToNBT(new NBTTagCompound());
|
||||
itemlist.appendTag(itemtag);
|
||||
}
|
||||
|
||||
tag.setTag(ITEMTAG, itemlist);
|
||||
watchstack.setTagCompound(tag);
|
||||
|
||||
this.setEntityItemStack(watchstack);
|
||||
|
||||
this.lifespan = 18000;
|
||||
this.delayBeforeCanPickup = 20;
|
||||
this.isImmuneToFire = true;
|
||||
}
|
||||
|
||||
// default constructors
|
||||
public EntityCollationItem(World world, double x, double y, double z, ItemStack stack) {
|
||||
super(world, x, y, z, stack);
|
||||
}
|
||||
|
||||
public EntityCollationItem(World world, double x, double y, double z) {
|
||||
super(world, x, y, z);
|
||||
}
|
||||
|
||||
public EntityCollationItem(World world) {
|
||||
super(world);
|
||||
}
|
||||
// end that junk
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
ItemStack stack = this.getEntityItem();
|
||||
NBTTagList list = stack.getTagCompound().getTagList(ITEMTAG, 10);
|
||||
if (list.tagCount() == 0) {
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean combineItems(EntityItem other) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// and the big one!
|
||||
@Override
|
||||
public void onCollideWithPlayer(EntityPlayer player)
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
if (this.delayBeforeCanPickup > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityItemPickupEvent event = new EntityItemPickupEvent(player, this);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String owner = this.func_145798_i();
|
||||
|
||||
ItemStack basestack = this.getEntityItem();
|
||||
NBTTagList list = basestack.getTagCompound().getTagList(ITEMTAG, 10);
|
||||
List<Integer> removed = new ArrayList<Integer>();
|
||||
|
||||
for (int i=0; i<list.tagCount(); i++) {
|
||||
|
||||
ItemStack itemstack = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i));
|
||||
|
||||
if (this.delayBeforeCanPickup <= 0
|
||||
&& (owner == null || lifespan - this.age <= 200 || owner.equals(player.getCommandSenderName()))
|
||||
&& (event.getResult() == Result.ALLOW || player.inventory.addItemStackToInventory(itemstack)))
|
||||
{
|
||||
if (itemstack.getItem() == Item.getItemFromBlock(Blocks.log))
|
||||
{
|
||||
player.triggerAchievement(AchievementList.mineWood);
|
||||
}
|
||||
|
||||
if (itemstack.getItem() == Item.getItemFromBlock(Blocks.log2))
|
||||
{
|
||||
player.triggerAchievement(AchievementList.mineWood);
|
||||
}
|
||||
|
||||
if (itemstack.getItem() == Items.leather)
|
||||
{
|
||||
player.triggerAchievement(AchievementList.killCow);
|
||||
}
|
||||
|
||||
if (itemstack.getItem() == Items.diamond)
|
||||
{
|
||||
player.triggerAchievement(AchievementList.diamonds);
|
||||
}
|
||||
|
||||
if (itemstack.getItem() == Items.blaze_rod)
|
||||
{
|
||||
player.triggerAchievement(AchievementList.blazeRod);
|
||||
}
|
||||
|
||||
if (itemstack.getItem() == Items.diamond && this.func_145800_j() != null)
|
||||
{
|
||||
EntityPlayer entityplayer1 = this.worldObj.getPlayerEntityByName(this.func_145800_j());
|
||||
|
||||
if (entityplayer1 != null && entityplayer1 != player)
|
||||
{
|
||||
entityplayer1.triggerAchievement(AchievementList.field_150966_x);
|
||||
}
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().firePlayerItemPickupEvent(player, this);
|
||||
|
||||
this.worldObj.playSoundAtEntity(player, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
//player.onItemPickup(this, itemstack.stackSize);
|
||||
|
||||
if (itemstack.stackSize <= 0)
|
||||
{
|
||||
removed.add(0, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<removed.size(); i++) {
|
||||
int index = removed.get(i);
|
||||
list.removeTag(index);
|
||||
}
|
||||
|
||||
if (list.tagCount() == 0) {
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
this.setEntityItemStack(basestack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,6 +207,12 @@ public class ItemArmorInfinity extends ItemArmor implements ICosmicRenderItem, I
|
||||
return this.cosmicMask;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMaskMultiplier(ItemStack stack) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomEntity (ItemStack stack)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ItemFracturedOre extends Item {
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SuppressWarnings({ "rawtypes"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list)
|
||||
@@ -92,7 +92,7 @@ public class ItemFracturedOre extends Item {
|
||||
public void registerIcons(IIconRegister ir) {
|
||||
super.registerIcons(ir);
|
||||
|
||||
this.unknownIcon = ir.registerIcon("avaritia:unknown");
|
||||
unknownIcon = ir.registerIcon("avaritia:unknown");
|
||||
}
|
||||
|
||||
// ########################################
|
||||
@@ -146,53 +146,6 @@ public class ItemFracturedOre extends Item {
|
||||
}
|
||||
}
|
||||
|
||||
private static class ItemStackWrapper {
|
||||
public final ItemStack stack;
|
||||
|
||||
public ItemStackWrapper(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object otherobj) {
|
||||
if (otherobj instanceof ItemStackWrapper) {
|
||||
ItemStackWrapper other = (ItemStackWrapper)otherobj;
|
||||
|
||||
if (this.stack.getItem().equals(other.stack.getItem())
|
||||
&& this.stack.getItemDamage() == other.stack.getItemDamage()
|
||||
) {
|
||||
|
||||
if (this.stack.stackTagCompound == null && other.stack.stackTagCompound == null) {
|
||||
return true;
|
||||
} else {
|
||||
if (this.stack.stackTagCompound == null ^ other.stack.stackTagCompound == null) {
|
||||
return false;
|
||||
}
|
||||
else if (this.stack.stackTagCompound.equals(other.stack.stackTagCompound)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int h = this.stack.getItem().hashCode();
|
||||
if (this.stack.stackTagCompound != null) {
|
||||
h ^= this.stack.stackTagCompound.hashCode();
|
||||
}
|
||||
return h ^ this.stack.getItemDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.stack.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static class NameStack {
|
||||
String name;
|
||||
int damage;
|
||||
|
||||
@@ -0,0 +1,291 @@
|
||||
package fox.spiteful.avaritia.items;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
import codechicken.lib.math.MathHelper;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import fox.spiteful.avaritia.Lumberjack;
|
||||
import fox.spiteful.avaritia.items.tools.ToolHelper;
|
||||
import fox.spiteful.avaritia.render.ICosmicRenderItem;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemMatterCluster extends Item implements ICosmicRenderItem {
|
||||
|
||||
protected static Random randy = new Random();
|
||||
|
||||
public static final String MAINTAG = "clusteritems";
|
||||
public static final String LISTTAG = "items";
|
||||
public static final String ITEMTAG = "item";
|
||||
public static final String COUNTTAG = "count";
|
||||
public static final String MAINCOUNTTAG = "total";
|
||||
|
||||
public static int capacity = 64*64;
|
||||
|
||||
public IIcon iconFull;
|
||||
public IIcon cosmicIcon;
|
||||
public IIcon cosmicIconFull;
|
||||
|
||||
public ItemMatterCluster() {
|
||||
this.setMaxStackSize(1);
|
||||
this.setUnlocalizedName("avaritia_mattercluster");
|
||||
this.setTextureName("avaritia:mattercluster");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister ir) {
|
||||
super.registerIcons(ir);
|
||||
|
||||
this.cosmicIcon = ir.registerIcon("avaritia:mattercluster_mask");
|
||||
|
||||
this.iconFull = ir.registerIcon("avaritia:mattercluster_full");
|
||||
this.cosmicIconFull = ir.registerIcon("avaritia:mattercluster_full_mask");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack)
|
||||
{
|
||||
return LudicrousItems.cosmic;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean debug) {
|
||||
if (!stack.hasTagCompound() || !stack.getTagCompound().hasKey(MAINTAG)) {
|
||||
return;
|
||||
}
|
||||
NBTTagCompound clustertag = stack.getTagCompound().getCompoundTag(MAINTAG);
|
||||
|
||||
tooltip.add(clustertag.getInteger(MAINCOUNTTAG) + "/" + capacity + " " + StatCollector.translateToLocal("tooltip.matter_cluster.counter"));
|
||||
tooltip.add("");
|
||||
|
||||
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
NBTTagList list = clustertag.getTagList(LISTTAG, 10);
|
||||
for (int i=0; i<list.tagCount(); i++) {
|
||||
NBTTagCompound tag = list.getCompoundTagAt(i);
|
||||
ItemStack countstack = ItemStack.loadItemStackFromNBT(tag.getCompoundTag(ITEMTAG));
|
||||
int count = tag.getInteger(COUNTTAG);
|
||||
|
||||
tooltip.add(countstack.getItem().getRarity(countstack).rarityColor + countstack.getDisplayName() +EnumChatFormatting.GRAY+" x " + count);
|
||||
}
|
||||
} else {
|
||||
tooltip.add(EnumChatFormatting.DARK_GRAY + StatCollector.translateToLocal("tooltip.matter_cluster.desc"));
|
||||
tooltip.add(EnumChatFormatting.DARK_GRAY.toString() + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("tooltip.matter_cluster.desc2"));
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ItemStack> makeClusters(List<ItemStack> input) {
|
||||
Map<ItemStackWrapper, Integer> items = ToolHelper.collateMatterCluster(input);
|
||||
List<ItemStack> clusters = new ArrayList<ItemStack>();
|
||||
List<Entry<ItemStackWrapper, Integer>> itemlist = new ArrayList<Entry<ItemStackWrapper, Integer>>();
|
||||
itemlist.addAll(items.entrySet());
|
||||
|
||||
int currentTotal = 0;
|
||||
Map<ItemStackWrapper, Integer> currentItems = new HashMap<ItemStackWrapper, Integer>();
|
||||
|
||||
while(!itemlist.isEmpty()) {
|
||||
Entry<ItemStackWrapper, Integer> e = itemlist.get(0);
|
||||
ItemStackWrapper wrap = e.getKey();
|
||||
int wrapcount = e.getValue();
|
||||
|
||||
int count = Math.min(capacity - currentTotal, wrapcount);
|
||||
|
||||
if (!currentItems.containsKey(e.getKey())) {
|
||||
currentItems.put(wrap, count);
|
||||
} else {
|
||||
currentItems.put(wrap, currentItems.get(wrap) + count);
|
||||
}
|
||||
currentTotal += count;
|
||||
|
||||
e.setValue(wrapcount - count);
|
||||
if (e.getValue() == 0) {
|
||||
itemlist.remove(0);
|
||||
}
|
||||
|
||||
if (currentTotal == capacity) {
|
||||
ItemStack cluster = makeCluster(currentItems);
|
||||
|
||||
clusters.add(cluster);
|
||||
|
||||
currentTotal = 0;
|
||||
currentItems = new HashMap<ItemStackWrapper, Integer>();
|
||||
}
|
||||
}
|
||||
|
||||
if (currentTotal > 0) {
|
||||
ItemStack cluster = makeCluster(currentItems);
|
||||
|
||||
clusters.add(cluster);
|
||||
}
|
||||
|
||||
return clusters;
|
||||
}
|
||||
|
||||
public static ItemStack makeCluster(Map<ItemStackWrapper, Integer> input) {
|
||||
ItemStack cluster = new ItemStack(LudicrousItems.matter_cluster);
|
||||
int total = 0;
|
||||
for (int num : input.values()) {
|
||||
total += num;
|
||||
}
|
||||
setClusterData(cluster, input, total);
|
||||
return cluster;
|
||||
}
|
||||
|
||||
public static Map<ItemStackWrapper, Integer> getClusterData(ItemStack cluster) {
|
||||
if (!cluster.hasTagCompound() || !cluster.getTagCompound().hasKey(MAINTAG)) {
|
||||
return null;
|
||||
}
|
||||
NBTTagCompound tag = cluster.getTagCompound().getCompoundTag(MAINTAG);
|
||||
NBTTagList list = tag.getTagList(LISTTAG, 10);
|
||||
Map<ItemStackWrapper, Integer> data = new HashMap<ItemStackWrapper, Integer>();
|
||||
|
||||
for (int i=0; i<list.tagCount(); i++) {
|
||||
NBTTagCompound entry = list.getCompoundTagAt(i);
|
||||
ItemStackWrapper wrap = new ItemStackWrapper(ItemStack.loadItemStackFromNBT(entry.getCompoundTag(ITEMTAG)));
|
||||
int count = entry.getInteger(COUNTTAG);
|
||||
data.put(wrap, count);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public static int getClusterSize(ItemStack cluster) {
|
||||
if (!cluster.hasTagCompound() || !cluster.getTagCompound().hasKey(MAINTAG)) {
|
||||
return 0;
|
||||
}
|
||||
return cluster.getTagCompound().getCompoundTag(MAINTAG).getInteger(MAINCOUNTTAG);
|
||||
}
|
||||
|
||||
public static void setClusterData(ItemStack stack, Map<ItemStackWrapper, Integer> data, int count) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound clustertag = new NBTTagCompound();
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for (Entry<ItemStackWrapper, Integer> entry : data.entrySet()) {
|
||||
NBTTagCompound itemtag = new NBTTagCompound();
|
||||
itemtag.setTag(ITEMTAG, entry.getKey().stack.writeToNBT(new NBTTagCompound()));
|
||||
itemtag.setInteger(COUNTTAG, entry.getValue());
|
||||
list.appendTag(itemtag);
|
||||
}
|
||||
clustertag.setTag(LISTTAG, list);
|
||||
clustertag.setInteger(MAINCOUNTTAG, count);
|
||||
stack.getTagCompound().setTag(MAINTAG, clustertag);
|
||||
}
|
||||
|
||||
public static void mergeClusters(ItemStack donor, ItemStack recipient) {
|
||||
int donorcount = getClusterSize(donor);
|
||||
int recipientcount = getClusterSize(recipient);
|
||||
|
||||
Lumberjack.info("merge 1");
|
||||
Lumberjack.info(donorcount +", "+ recipientcount);
|
||||
if (donorcount == 0 || donorcount == capacity || recipientcount == capacity) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<ItemStackWrapper, Integer> donordata = getClusterData(donor);
|
||||
Map<ItemStackWrapper, Integer> recipientdata = getClusterData(recipient);
|
||||
List<Entry<ItemStackWrapper, Integer>> datalist = new ArrayList<Entry<ItemStackWrapper, Integer>>();
|
||||
datalist.addAll(donordata.entrySet());
|
||||
|
||||
Lumberjack.info("merge 2");
|
||||
while (recipientcount < capacity && donorcount > 0) {
|
||||
Entry<ItemStackWrapper, Integer> e = datalist.get(0);
|
||||
ItemStackWrapper wrap = e.getKey();
|
||||
int wrapcount = e.getValue();
|
||||
|
||||
int count = Math.min(capacity - recipientcount, wrapcount);
|
||||
|
||||
if (!recipientdata.containsKey(wrap)) {
|
||||
recipientdata.put(wrap, count);
|
||||
} else {
|
||||
recipientdata.put(wrap, recipientdata.get(wrap) + count);
|
||||
}
|
||||
|
||||
donorcount -= count;
|
||||
recipientcount += count;
|
||||
|
||||
if (wrapcount - count > 0) {
|
||||
e.setValue(wrapcount - count);
|
||||
} else {
|
||||
donordata.remove(wrap);
|
||||
datalist.remove(0);
|
||||
}
|
||||
}
|
||||
|
||||
Lumberjack.info("merge 4");
|
||||
setClusterData(recipient, recipientdata, recipientcount);
|
||||
|
||||
if (donorcount > 0) {
|
||||
setClusterData(donor, donordata, donorcount);
|
||||
} else {
|
||||
donor.setTagCompound(null);
|
||||
donor.stackSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
List<ItemStack> drops = ToolHelper.collateMatterClusterContents(ItemMatterCluster.getClusterData(stack));
|
||||
|
||||
for (ItemStack drop : drops) {
|
||||
ToolHelper.dropItem(drop, world, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ));
|
||||
}
|
||||
|
||||
stack.stackSize = 0;
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getMaskTexture(ItemStack stack) {
|
||||
int count = getClusterSize(stack);
|
||||
if (count == capacity) {
|
||||
return cosmicIconFull;
|
||||
}
|
||||
return cosmicIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMaskMultiplier(ItemStack stack) {
|
||||
int count = getClusterSize(stack);
|
||||
return count / (float)capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int pass) {
|
||||
int count = getClusterSize(stack);
|
||||
if (count == capacity) {
|
||||
return iconFull;
|
||||
}
|
||||
return super.getIcon(stack, pass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconIndex(ItemStack stack)
|
||||
{
|
||||
return this.getIcon(stack, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package fox.spiteful.avaritia.items;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemStackWrapper {
|
||||
public final ItemStack stack;
|
||||
|
||||
public ItemStackWrapper(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object otherobj) {
|
||||
if (otherobj instanceof ItemStackWrapper) {
|
||||
ItemStackWrapper other = (ItemStackWrapper)otherobj;
|
||||
|
||||
if (this.stack.getItem().equals(other.stack.getItem())
|
||||
&& this.stack.getItemDamage() == other.stack.getItemDamage()
|
||||
) {
|
||||
|
||||
if (this.stack.stackTagCompound == null && other.stack.stackTagCompound == null) {
|
||||
return true;
|
||||
} else {
|
||||
if (this.stack.stackTagCompound == null ^ other.stack.stackTagCompound == null) {
|
||||
return false;
|
||||
}
|
||||
else if (this.stack.stackTagCompound.equals(other.stack.stackTagCompound)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int h = this.stack.getItem().hashCode();
|
||||
if (this.stack.stackTagCompound != null) {
|
||||
h ^= this.stack.stackTagCompound.hashCode();
|
||||
}
|
||||
return h ^ this.stack.getItemDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.stack.toString();
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ public class LudicrousItems {
|
||||
public static Item cosmic_meatballs;
|
||||
public static Item endest_pearl;
|
||||
public static Item fractured_ore;
|
||||
public static Item matter_cluster;
|
||||
|
||||
public static Item infinity_helm;
|
||||
public static Item infinity_armor;
|
||||
@@ -68,6 +69,8 @@ public class LudicrousItems {
|
||||
GameRegistry.registerItem(infinity_shoes, "Infinity_Shoes");
|
||||
fractured_ore = new ItemFracturedOre();
|
||||
GameRegistry.registerItem(fractured_ore, "Fractured_Ore");
|
||||
matter_cluster = new ItemMatterCluster();
|
||||
GameRegistry.registerItem(matter_cluster, "Matter_Cluster");
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new ItemArmorInfinity.abilityHandler());
|
||||
}
|
||||
|
||||
@@ -103,9 +103,16 @@ public class ItemSwordInfinity extends ItemSword implements ICosmicRenderItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getMaskTexture(ItemStack stack) {
|
||||
return cosmicMask;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMaskMultiplier(ItemStack stack) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
|
||||
@@ -12,13 +12,29 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import fox.spiteful.avaritia.Lumberjack;
|
||||
import fox.spiteful.avaritia.entity.EntityCollationItem;
|
||||
import fox.spiteful.avaritia.items.ItemMatterCluster;
|
||||
import fox.spiteful.avaritia.items.ItemStackWrapper;
|
||||
import fox.spiteful.avaritia.items.LudicrousItems;
|
||||
|
||||
public class ToolHelper {
|
||||
|
||||
@@ -27,14 +43,47 @@ public class ToolHelper {
|
||||
public static Material[] materialsAxe = new Material[]{ Material.coral, Material.leaves, Material.plants, Material.wood };
|
||||
|
||||
private static Random randy = new Random();
|
||||
|
||||
public static Set<EntityPlayer> hammering = new HashSet<EntityPlayer>();
|
||||
public static Map<EntityPlayer, List<ItemStack>> hammerdrops = new WeakHashMap<EntityPlayer, List<ItemStack>>();
|
||||
|
||||
public static void removeBlocksInIteration(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int xs, int ys, int zs, int xe, int ye, int ze, Block block, Material[] materialsListing, boolean silk, int fortune, boolean dispose) {
|
||||
float blockHardness = block == null ? 1F : block.getBlockHardness(world, x, y, z);
|
||||
|
||||
if (!hammerdrops.containsKey(player) || hammerdrops.get(player) == null) {
|
||||
hammerdrops.put(player, new ArrayList<ItemStack>());
|
||||
}
|
||||
|
||||
if (!hammering.contains(player)) {
|
||||
hammering.add(player);
|
||||
}
|
||||
|
||||
for(int x1 = xs; x1 < xe; x1++)
|
||||
for(int y1 = ys; y1 < ye; y1++)
|
||||
for(int z1 = zs; z1 < ze; z1++)
|
||||
removeBlockWithDrops(player, stack, world, x1 + x, y1 + y, z1 + z, block, materialsListing, silk, fortune, blockHardness, dispose);
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(!world.isRemote /*&& ConfigHandler.blockBreakParticles && ConfigHandler.blockBreakParticlesTool*/)
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
|
||||
if (hammering.contains(player)) {
|
||||
hammering.remove(player);
|
||||
}
|
||||
|
||||
//List<ItemStack> drops = collateDropList(hammerdrops.get(player));
|
||||
//Lumberjack.info(drops);
|
||||
|
||||
if(!world.isRemote) {
|
||||
List<ItemStack> clusters = ItemMatterCluster.makeClusters(hammerdrops.get(player));
|
||||
|
||||
for (ItemStack cluster : clusters) {
|
||||
EntityItem ent = new EntityItem(world, x,y,z, cluster);
|
||||
world.spawnEntityInWorld(ent);
|
||||
}
|
||||
}
|
||||
|
||||
hammerdrops.put(player, null);
|
||||
}
|
||||
|
||||
public static boolean isRightMaterial(Material material, Material[] materialsListing) {
|
||||
@@ -80,8 +129,8 @@ public class ToolHelper {
|
||||
|
||||
} else world.setBlockToAir(x, y, z);
|
||||
|
||||
if(!world.isRemote /*&& ConfigHandler.blockBreakParticles && ConfigHandler.blockBreakParticlesTool*/)
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blk) + (meta << 12));
|
||||
//if(!world.isRemote /*&& ConfigHandler.blockBreakParticles && ConfigHandler.blockBreakParticlesTool*/)
|
||||
// world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blk) + (meta << 12));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +158,7 @@ public class ToolHelper {
|
||||
return world.rayTraceBlocks(vec3, vec31, wut);
|
||||
}
|
||||
|
||||
private static void dropItem(ItemStack drop, World world, int x, int y, int z){
|
||||
public static void dropItem(ItemStack drop, World world, int x, int y, int z){
|
||||
float f = 0.7F;
|
||||
double d0 = (double)(randy.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
|
||||
double d1 = (double)(randy.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
|
||||
@@ -118,4 +167,50 @@ public class ToolHelper {
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
|
||||
public static List<ItemStack> collateDropList(List<ItemStack> input) {
|
||||
return collateMatterClusterContents(collateMatterCluster(input));
|
||||
}
|
||||
|
||||
public static List<ItemStack> collateMatterClusterContents(Map<ItemStackWrapper, Integer> input) {
|
||||
List<ItemStack> collated = new ArrayList<ItemStack>();
|
||||
|
||||
for (Entry<ItemStackWrapper, Integer> e : input.entrySet()) {
|
||||
int count = e.getValue();
|
||||
ItemStackWrapper wrap = e.getKey();
|
||||
|
||||
int size = wrap.stack.getMaxStackSize();
|
||||
int fullstacks = (int) Math.floor(count / size);
|
||||
|
||||
for(int i=0; i<fullstacks; i++) {
|
||||
count -= size;
|
||||
ItemStack stack = wrap.stack.copy();
|
||||
stack.stackSize = size;
|
||||
collated.add(stack);
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
ItemStack stack = wrap.stack.copy();
|
||||
stack.stackSize = count;
|
||||
collated.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
return collated;
|
||||
}
|
||||
|
||||
public static Map<ItemStackWrapper, Integer> collateMatterCluster(List<ItemStack> input) {
|
||||
Map<ItemStackWrapper, Integer> counts = new HashMap<ItemStackWrapper, Integer>();
|
||||
|
||||
for (ItemStack stack : input) {
|
||||
ItemStackWrapper wrap = new ItemStackWrapper(stack);
|
||||
if (!counts.containsKey(wrap)) {
|
||||
counts.put(wrap, 0);
|
||||
}
|
||||
|
||||
counts.put(wrap, counts.get(wrap) + stack.stackSize);
|
||||
}
|
||||
|
||||
return counts;
|
||||
}
|
||||
}
|
||||
@@ -74,9 +74,12 @@ public class CosmicItemRenderer implements IItemRenderer {
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
ICosmicRenderItem icri = (ICosmicRenderItem)(item.getItem());
|
||||
|
||||
CosmicRenderShenanigans.cosmicOpacity = icri.getMaskMultiplier(item);
|
||||
CosmicRenderShenanigans.inventoryRender = true;
|
||||
CosmicRenderShenanigans.useShader();
|
||||
ICosmicRenderItem icri = (ICosmicRenderItem)(item.getItem());
|
||||
|
||||
IIcon cosmicicon = icri.getMaskTexture(item);
|
||||
|
||||
GL11.glColor4d(1, 1, 1, 1);
|
||||
@@ -156,8 +159,11 @@ public class CosmicItemRenderer implements IItemRenderer {
|
||||
}
|
||||
|
||||
if (item.getItem() instanceof ICosmicRenderItem) {
|
||||
CosmicRenderShenanigans.useShader();
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
ICosmicRenderItem icri = (ICosmicRenderItem)(item.getItem());
|
||||
CosmicRenderShenanigans.cosmicOpacity = icri.getMaskMultiplier(item);
|
||||
CosmicRenderShenanigans.useShader();
|
||||
|
||||
IIcon cosmicicon = icri.getMaskTexture(item);
|
||||
|
||||
float minu = cosmicicon.getMinU();
|
||||
@@ -166,6 +172,7 @@ public class CosmicItemRenderer implements IItemRenderer {
|
||||
float maxv = cosmicicon.getMaxV();
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, maxu, minv, minu, maxv, cosmicicon.getIconWidth(), cosmicicon.getIconHeight(), scale);
|
||||
CosmicRenderShenanigans.releaseShader();
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
@@ -20,6 +20,7 @@ public class CosmicRenderShenanigans {
|
||||
|
||||
public static String[] lightmapobf = new String[] {"lightmapColors", "field_78504_Q", "U"};
|
||||
public static boolean inventoryRender = false;
|
||||
public static float cosmicOpacity = 1.0f;
|
||||
|
||||
static {
|
||||
shaderCallback = new ShaderCallback() {
|
||||
@@ -55,6 +56,9 @@ public class CosmicRenderShenanigans {
|
||||
|
||||
int s = ARBShaderObjects.glGetUniformLocationARB(shader, "externalScale");
|
||||
ARBShaderObjects.glUniform1fARB(s, scale);
|
||||
|
||||
int o = ARBShaderObjects.glGetUniformLocationARB(shader, "opacity");
|
||||
ARBShaderObjects.glUniform1fARB(o, cosmicOpacity);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,4 +9,7 @@ public interface ICosmicRenderItem {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getMaskTexture(ItemStack stack);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMaskMultiplier(ItemStack stack);
|
||||
}
|
||||
Reference in new issue
Block a user