Skip to content

Commit

Permalink
Update libs
Browse files Browse the repository at this point in the history
Update to Forge 10.13.1.1217
Update to Clashsoft Lib 1.7.10-2.7.1
  • Loading branch information
Clashsoft committed Oct 8, 2014
1 parent 1ad05fc commit 6a51832
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 107 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ gradlew
gradlew.bat
bin/
build/

.settings/org.eclipse.jdt.core.prefs
13 changes: 0 additions & 13 deletions .settings/org.eclipse.jdt.core.prefs

This file was deleted.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ targetCompatibility = 1.7

minecraft
{
version = "1.7.10-10.13.0.1207"
version = "1.7.10-10.13.1.1217"

if(file('../run').exists())
{
Expand Down
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions src/main/java/clashsoft/playerinventoryapi/PlayerInventoryAPI.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package clashsoft.playerinventoryapi;

import clashsoft.cslib.config.CSConfig;
import clashsoft.cslib.minecraft.entity.CSEntities;
import clashsoft.cslib.minecraft.entity.CSEntities.EntityProperties;
import clashsoft.cslib.minecraft.init.ClashsoftMod;
import clashsoft.cslib.minecraft.update.CSUpdate;
import clashsoft.cslib.minecraft.update.reader.SimpleUpdateReader;
Expand All @@ -9,6 +11,7 @@
import clashsoft.playerinventoryapi.api.invobject.IInventoryObject;
import clashsoft.playerinventoryapi.common.PIEventHandler;
import clashsoft.playerinventoryapi.common.PIProxy;
import clashsoft.playerinventoryapi.lib.ExtendedInventory;
import clashsoft.playerinventoryapi.network.PINetHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
Expand All @@ -17,6 +20,10 @@
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.IExtendedEntityProperties;

@Mod(modid = PlayerInventoryAPI.MODID, name = PlayerInventoryAPI.NAME, version = PlayerInventoryAPI.VERSION)
public class PlayerInventoryAPI extends ClashsoftMod
{
Expand Down Expand Up @@ -51,6 +58,21 @@ public PlayerInventoryAPI()
public void preInit(FMLPreInitializationEvent event)
{
super.preInit(event);

CSEntities.registerProperties(new EntityProperties(ExtendedInventory.IDENTIFIER, ExtendedInventory.class)
{
@Override
public boolean canApply(Entity entity)
{
return entity instanceof EntityPlayer;
}

@Override
public IExtendedEntityProperties createProperties(Entity entity)
{
return new ExtendedInventory((EntityPlayer) entity);
}
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,19 @@

import clashsoft.playerinventoryapi.PlayerInventoryAPI;
import clashsoft.playerinventoryapi.lib.ExtendedInventory;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.relauncher.Side;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;

public class PIEventHandler
{
@SubscribeEvent
public void entityConstructing(EntityConstructing event)
{
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && event.entity instanceof EntityPlayer)
{
ExtendedInventory props = new ExtendedInventory((EntityPlayer) event.entity);
ExtendedInventory.set((EntityPlayer) event.entity, props);
}
}

@SubscribeEvent
public void entityJoinWorld(EntityJoinWorldEvent event)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Arrays;

import clashsoft.cslib.minecraft.entity.CSEntities;
import clashsoft.cslib.minecraft.stack.CSStacks;
import clashsoft.playerinventoryapi.PlayerInventoryAPI;
import clashsoft.playerinventoryapi.network.EIPacket;
Expand Down Expand Up @@ -90,83 +91,9 @@ public void onUpdate()
}
}

/**
* Returns the {@link ExtendedInventory} of the player. Note the this method
* may return {@code null} if an {@link ExtendedInventory} hasn't already
* been applied to the player.
*
* @see Entity#getExtendedProperties(String)
* @param player
* @return
*/
protected static ExtendedInventory get_(EntityPlayer player)
{
return (ExtendedInventory) player.getExtendedProperties(IDENTIFIER);
}

/**
* Returns the {@link ExtendedInventory} of the player. If the player
* doesn't already have an {@link ExtendedInventory}, a new one is created
* and applied to the player.
*
* @see ExtendedInventory#get_(EntityPlayer)
* @see ExtendedInventory#set_(EntityPlayer, ExtendedInventory)
* @param player
* the player
* @return the extended inventory
*/
public static ExtendedInventory get(EntityPlayer player)
{
ExtendedInventory props = get_(player);
return props == null ? set_(player, new ExtendedInventory(player)) : props;
}

/**
* Sets the {@link ExtendedInventory} of the player and applies it.
*
* @see Entity#registerExtendedProperties(String, IExtendedEntityProperties)
* @param player
* the player
* @param ei
* the extended inventory
* @return the extended inventory
*/
protected static ExtendedInventory set_(EntityPlayer player, ExtendedInventory ei)
{
player.registerExtendedProperties(IDENTIFIER, ei);
return ei;
}

/**
* Sets the {@link ExtendedInventory} of the player and applies it. If the
* player already has an {@link ExtendedInventory}, the data of the given
* {@link ExtendedInventory} is copied to the existing one using
* {@link #copy(ExtendedInventory, ExtendedInventory)}. Otherwise, the given
* {@link ExtendedInventory} is directly applied using
* {@link #set_(EntityPlayer, ExtendedInventory)}
*
* @param player
* @param ei
* @return
*/
public static ExtendedInventory set(EntityPlayer player, ExtendedInventory ei)
{
ExtendedInventory ei2 = get_(player);
if (ei2 == null)
{
return set_(player, ei);
}
else
{
copy(ei, ei2);
return ei2;
}
}

public static void copy(ExtendedInventory source, ExtendedInventory dest)
{
dest.itemStacks = source.itemStacks;
dest.entity = source.entity;
return (ExtendedInventory) CSEntities.getProperties(IDENTIFIER, player);
}

/**
Expand All @@ -180,7 +107,7 @@ public void sync()
}

/**
* Syncs slot # {@code slot} with the player.
* Syncs the given {@code slot} with the player.
*
* @param player
* @param slot
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package clashsoft.playerinventoryapi.network;

import java.io.IOException;

import clashsoft.cslib.minecraft.network.CSPacket;
import clashsoft.playerinventoryapi.lib.ExtendedInventory;

Expand All @@ -22,7 +24,7 @@ public EIPacket(ExtendedInventory inventory)
}

@Override
public void write(PacketBuffer buf)
public void write(PacketBuffer buf) throws IOException
{
int len = this.stacks.length;
buf.writeInt(len);
Expand All @@ -34,7 +36,7 @@ public void write(PacketBuffer buf)
}

@Override
public void read(PacketBuffer buf)
public void read(PacketBuffer buf) throws IOException
{
int len = buf.readInt();
this.stacks = new ItemStack[len];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package clashsoft.playerinventoryapi.network;

import java.io.IOException;

import clashsoft.cslib.minecraft.network.CSPacket;
import clashsoft.playerinventoryapi.lib.ExtendedInventory;

Expand All @@ -24,14 +26,14 @@ public EISlotPacket(ExtendedInventory ei, int slot)
}

@Override
public void write(PacketBuffer buf)
public void write(PacketBuffer buf) throws IOException
{
buf.writeInt(this.slot);
writeItemStack(buf, this.stack);
}

@Override
public void read(PacketBuffer buf)
public void read(PacketBuffer buf) throws IOException
{
this.slot = buf.readInt();
this.stack = readItemStack(buf);
Expand Down

0 comments on commit 6a51832

Please sign in to comment.