mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 16:58:34 +01:00
Added portable jukebox
This commit is contained in:
parent
28eb55582f
commit
a924004f10
17 changed files with 373 additions and 11 deletions
|
@ -34,8 +34,7 @@ import de.ellpeck.actuallyadditions.mod.material.InitToolMaterials;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.BannerHelper;
|
import de.ellpeck.actuallyadditions.mod.misc.BannerHelper;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.LaserRelayConnectionHandler;
|
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.LaserRelayConnectionHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.MethodHandler;
|
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.MethodHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
import de.ellpeck.actuallyadditions.mod.misc.sound.SoundHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.DefaultFarmerBehavior;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.ore.InitOreDict;
|
import de.ellpeck.actuallyadditions.mod.ore.InitOreDict;
|
||||||
import de.ellpeck.actuallyadditions.mod.proxy.IProxy;
|
import de.ellpeck.actuallyadditions.mod.proxy.IProxy;
|
||||||
|
|
|
@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.BlockColoredLamp;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.crafting.recipe.RecipeKeepDataShaped;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.crafting;
|
package de.ellpeck.actuallyadditions.mod.crafting;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.crafting.recipe.RecipeKeepDataShaped;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.crafting.recipe.RecipeKeepDataShapeless;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.crafting.recipe.RecipePotionRingCharging;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.crafting.recipe.RecipeSwitchJukeboxDisc;
|
||||||
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
||||||
|
@ -48,9 +52,11 @@ public final class InitCrafting{
|
||||||
|
|
||||||
RecipeSorter.register(ModUtil.MOD_ID+":recipeKeepDataShaped", RecipeKeepDataShaped.class, RecipeSorter.Category.SHAPED, "after:minecraft:shaped");
|
RecipeSorter.register(ModUtil.MOD_ID+":recipeKeepDataShaped", RecipeKeepDataShaped.class, RecipeSorter.Category.SHAPED, "after:minecraft:shaped");
|
||||||
RecipeSorter.register(ModUtil.MOD_ID+":recipeKeepDataShapeless", RecipeKeepDataShapeless.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
|
RecipeSorter.register(ModUtil.MOD_ID+":recipeKeepDataShapeless", RecipeKeepDataShapeless.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
|
||||||
|
RecipeSorter.register(ModUtil.MOD_ID+":recipePotionRingCharging", RecipePotionRingCharging.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
|
||||||
|
RecipeSorter.register(ModUtil.MOD_ID+":recipeSwitchJukeboxDisc", RecipeSwitchJukeboxDisc.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
|
||||||
|
|
||||||
GameRegistry.addRecipe(new RecipePotionRingCharging());
|
GameRegistry.addRecipe(new RecipePotionRingCharging());
|
||||||
RecipeSorter.register(ModUtil.MOD_ID+":recipePotionRingCharging", RecipePotionRingCharging.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
|
GameRegistry.addRecipe(new RecipeSwitchJukeboxDisc());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@ import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.crafting.recipe.RecipeKeepDataShaped;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.crafting.recipe.RecipeKeepDataShapeless;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.metalists.*;
|
import de.ellpeck.actuallyadditions.mod.items.metalists.*;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
|
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* © 2015-2016 Ellpeck
|
* © 2015-2016 Ellpeck
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.crafting;
|
package de.ellpeck.actuallyadditions.mod.crafting.recipe;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
|
@ -8,7 +8,7 @@
|
||||||
* © 2015-2016 Ellpeck
|
* © 2015-2016 Ellpeck
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.crafting;
|
package de.ellpeck.actuallyadditions.mod.crafting.recipe;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
|
@ -8,7 +8,7 @@
|
||||||
* © 2015-2016 Ellpeck
|
* © 2015-2016 Ellpeck
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.crafting;
|
package de.ellpeck.actuallyadditions.mod.crafting.recipe;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemPotionRing;
|
import de.ellpeck.actuallyadditions.mod.items.ItemPotionRing;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
|
@ -78,7 +78,7 @@ public class RecipePotionRingCharging implements IRecipe{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRecipeSize(){
|
public int getRecipeSize(){
|
||||||
return 0;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -0,0 +1,145 @@
|
||||||
|
/*
|
||||||
|
* This file ("RecipeSwitchJukeboxDisc.java") is part of the Actually Additions mod for Minecraft.
|
||||||
|
* It is created and owned by Ellpeck and distributed
|
||||||
|
* under the Actually Additions License to be found at
|
||||||
|
* http://ellpeck.de/actaddlicense
|
||||||
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||||
|
*
|
||||||
|
* © 2015-2016 Ellpeck
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.ellpeck.actuallyadditions.mod.crafting.recipe;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.items.ItemPortableJukebox;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
|
import net.minecraft.inventory.InventoryCrafting;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemRecord;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.crafting.IRecipe;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class RecipeSwitchJukeboxDisc implements IRecipe{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean matches(InventoryCrafting inv, World world){
|
||||||
|
ItemStack juke = StackUtil.getNull();
|
||||||
|
boolean foundDisc = false;
|
||||||
|
|
||||||
|
for(int i = 0; i < inv.getSizeInventory(); i++){
|
||||||
|
ItemStack stack = inv.getStackInSlot(i);
|
||||||
|
if(StackUtil.isValid(stack)){
|
||||||
|
if(stack.getItem() instanceof ItemPortableJukebox){
|
||||||
|
if(!StackUtil.isValid(juke)){
|
||||||
|
juke = stack;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(stack.getItem() instanceof ItemRecord){
|
||||||
|
if(!foundDisc){
|
||||||
|
foundDisc = true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StackUtil.isValid(juke)){
|
||||||
|
String disc = ItemPortableJukebox.getDisc(juke);
|
||||||
|
return (disc == null || disc.isEmpty()) == foundDisc;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getCraftingResult(InventoryCrafting inv){
|
||||||
|
ItemStack disc = StackUtil.getNull();
|
||||||
|
ItemStack juke = StackUtil.getNull();
|
||||||
|
|
||||||
|
for(int i = 0; i < inv.getSizeInventory(); i++){
|
||||||
|
ItemStack stack = inv.getStackInSlot(i);
|
||||||
|
if(StackUtil.isValid(stack)){
|
||||||
|
if(stack.getItem() instanceof ItemPortableJukebox){
|
||||||
|
juke = stack.copy();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
disc = stack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StackUtil.isValid(juke)){
|
||||||
|
if(StackUtil.isValid(disc)){
|
||||||
|
ResourceLocation reg = disc.getItem().getRegistryName();
|
||||||
|
if(reg != null){
|
||||||
|
ItemPortableJukebox.setDisc(juke, reg.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
String onJuke = ItemPortableJukebox.getDisc(juke);
|
||||||
|
if(onJuke != null && !onJuke.isEmpty()){
|
||||||
|
Item itemOnJuke = Item.REGISTRY.getObject(new ResourceLocation(onJuke));
|
||||||
|
if(itemOnJuke != null){
|
||||||
|
disc = new ItemStack(itemOnJuke);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return disc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return juke;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRecipeSize(){
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getRecipeOutput(){
|
||||||
|
return StackUtil.getNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv){
|
||||||
|
NonNullList<ItemStack> remain = NonNullList.withSize(inv.getSizeInventory(), StackUtil.getNull());
|
||||||
|
|
||||||
|
int jukePlace = -1;
|
||||||
|
ItemStack juke = StackUtil.getNull();
|
||||||
|
boolean foundDisc = false;
|
||||||
|
|
||||||
|
for(int i = 0; i < inv.getSizeInventory(); i++){
|
||||||
|
ItemStack stack = inv.getStackInSlot(i);
|
||||||
|
if(StackUtil.isValid(stack)){
|
||||||
|
if(stack.getItem() instanceof ItemPortableJukebox){
|
||||||
|
juke = stack;
|
||||||
|
jukePlace = i;
|
||||||
|
}
|
||||||
|
else if(stack.getItem() instanceof ItemRecord){
|
||||||
|
foundDisc = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!foundDisc && jukePlace >= 0 && StackUtil.isValid(juke)){
|
||||||
|
ItemStack copy = juke.copy();
|
||||||
|
ItemPortableJukebox.setDisc(copy, null);
|
||||||
|
remain.set(jukePlace, copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
return remain;
|
||||||
|
}
|
||||||
|
}
|
|
@ -166,6 +166,7 @@ public class CreativeTab extends CreativeTabs{
|
||||||
this.add(InitItems.itemSpawnerChanger);
|
this.add(InitItems.itemSpawnerChanger);
|
||||||
this.add(InitItems.itemWaterBowl);
|
this.add(InitItems.itemWaterBowl);
|
||||||
|
|
||||||
|
this.add(InitItems.itemPortableJukebox);
|
||||||
this.add(InitItems.itemDrill);
|
this.add(InitItems.itemDrill);
|
||||||
this.add(InitItems.itemDrillUpgradeSpeed);
|
this.add(InitItems.itemDrillUpgradeSpeed);
|
||||||
this.add(InitItems.itemDrillUpgradeSpeedII);
|
this.add(InitItems.itemDrillUpgradeSpeedII);
|
||||||
|
|
|
@ -193,10 +193,12 @@ public final class InitItems{
|
||||||
public static Item itemBag;
|
public static Item itemBag;
|
||||||
public static Item itemVoidBag;
|
public static Item itemVoidBag;
|
||||||
public static Item itemFillingWand;
|
public static Item itemFillingWand;
|
||||||
|
public static Item itemPortableJukebox;
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
ModUtil.LOGGER.info("Initializing Items...");
|
ModUtil.LOGGER.info("Initializing Items...");
|
||||||
|
|
||||||
|
itemPortableJukebox = new ItemPortableJukebox("item_portable_jukebox");
|
||||||
itemFillingWand = new ItemFillingWand("item_filling_wand");
|
itemFillingWand = new ItemFillingWand("item_filling_wand");
|
||||||
itemBag = new ItemBag("item_bag", false);
|
itemBag = new ItemBag("item_bag", false);
|
||||||
itemVoidBag = new ItemBag("item_void_bag", true);
|
itemVoidBag = new ItemBag("item_void_bag", true);
|
||||||
|
|
|
@ -0,0 +1,122 @@
|
||||||
|
/*
|
||||||
|
* This file ("ItemPortableJukebox.java") is part of the Actually Additions mod for Minecraft.
|
||||||
|
* It is created and owned by Ellpeck and distributed
|
||||||
|
* under the Actually Additions License to be found at
|
||||||
|
* http://ellpeck.de/actaddlicense
|
||||||
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||||
|
*
|
||||||
|
* © 2015-2016 Ellpeck
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemRecord;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.EnumActionResult;
|
||||||
|
import net.minecraft.util.EnumHand;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ItemPortableJukebox extends ItemBase{
|
||||||
|
|
||||||
|
public ItemPortableJukebox(String name){
|
||||||
|
super(name);
|
||||||
|
this.setMaxStackSize(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public boolean hasEffect(ItemStack stack){
|
||||||
|
return ItemUtil.isEnabled(stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand){
|
||||||
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
|
||||||
|
if(!world.isRemote){
|
||||||
|
if(player.isSneaking()){
|
||||||
|
String disc = getDisc(stack);
|
||||||
|
if(disc != null && !disc.isEmpty()){
|
||||||
|
ItemUtil.changeEnabled(player, hand);
|
||||||
|
|
||||||
|
if(ItemUtil.isEnabled(stack)){
|
||||||
|
int slot = -1;
|
||||||
|
|
||||||
|
for(int i = 0; i < player.inventory.getSizeInventory(); i++){
|
||||||
|
if(player.inventory.getStackInSlot(i) == stack){
|
||||||
|
slot = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(slot >= 0){
|
||||||
|
playSoundToAllAround(player, disc, slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void playSoundToAllAround(EntityPlayer player, String disc, int slot){
|
||||||
|
NBTTagCompound compound = new NBTTagCompound();
|
||||||
|
compound.setString("Disc", disc);
|
||||||
|
compound.setUniqueId("PlayerId", player.getUniqueID());
|
||||||
|
compound.setInteger("Slot", slot);
|
||||||
|
|
||||||
|
PacketHandler.theNetwork.sendToAllAround(new PacketServerToClient(compound, PacketHandler.SEND_PORTABLE_JUKEBOX_SOUND_HANDLER), new NetworkRegistry.TargetPoint(player.world.provider.getDimension(), player.posX, player.posY, player.posZ, 32));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDisc(ItemStack stack){
|
||||||
|
if(stack.hasTagCompound()){
|
||||||
|
return stack.getTagCompound().getString("Disc");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDisc(ItemStack stack, String disc){
|
||||||
|
boolean hasTag = stack.hasTagCompound();
|
||||||
|
|
||||||
|
if(disc != null){
|
||||||
|
if(!hasTag){
|
||||||
|
stack.setTagCompound(new NBTTagCompound());
|
||||||
|
}
|
||||||
|
stack.getTagCompound().setString("Disc", disc);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(hasTag){
|
||||||
|
stack.getTagCompound().removeTag("Disc");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced){
|
||||||
|
String disc = getDisc(stack);
|
||||||
|
|
||||||
|
if(disc != null && !disc.isEmpty()){
|
||||||
|
Item item = Item.REGISTRY.getObject(new ResourceLocation(disc));
|
||||||
|
if(item instanceof ItemRecord){
|
||||||
|
tooltip.add("Disc: "+((ItemRecord)item).getRecordNameLocal());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tooltip.add("No Disc");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* This file ("MovingPlayerSound.java") is part of the Actually Additions mod for Minecraft.
|
||||||
|
* It is created and owned by Ellpeck and distributed
|
||||||
|
* under the Actually Additions License to be found at
|
||||||
|
* http://ellpeck.de/actaddlicense
|
||||||
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||||
|
*
|
||||||
|
* © 2015-2016 Ellpeck
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.ellpeck.actuallyadditions.mod.misc.sound;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.items.ItemPortableJukebox;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
|
import net.minecraft.client.audio.MovingSound;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.SoundCategory;
|
||||||
|
import net.minecraft.util.SoundEvent;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public class MovingPlayerSound extends MovingSound{
|
||||||
|
|
||||||
|
private final EntityPlayer player;
|
||||||
|
private final int playerInvSlot;
|
||||||
|
|
||||||
|
public MovingPlayerSound(SoundEvent sound, SoundCategory category, EntityPlayer player, int playerInvSlot){
|
||||||
|
super(sound, category);
|
||||||
|
this.player = player;
|
||||||
|
this.playerInvSlot = playerInvSlot;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(){
|
||||||
|
if(!this.player.isDead){
|
||||||
|
ItemStack stack = this.player.inventory.getStackInSlot(this.playerInvSlot);
|
||||||
|
if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemPortableJukebox){
|
||||||
|
if(ItemUtil.isEnabled(stack)){
|
||||||
|
this.xPosF = (float)this.player.posX;
|
||||||
|
this.yPosF = (float)this.player.posY;
|
||||||
|
this.zPosF = (float)this.player.posZ;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.donePlaying = true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,7 @@
|
||||||
* © 2015-2016 Ellpeck
|
* © 2015-2016 Ellpeck
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.misc;
|
package de.ellpeck.actuallyadditions.mod.misc.sound;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
|
@ -11,6 +11,7 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.network;
|
package de.ellpeck.actuallyadditions.mod.network;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.misc.sound.MovingPlayerSound;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IStringReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IStringReactor;
|
||||||
|
@ -21,8 +22,13 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemRecord;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.SoundCategory;
|
||||||
|
import net.minecraft.util.SoundEvent;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
|
@ -121,6 +127,31 @@ public final class PacketHandler{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
public static final IDataHandler SEND_PORTABLE_JUKEBOX_SOUND_HANDLER = new IDataHandler(){
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void handleData(NBTTagCompound compound){
|
||||||
|
String disc = compound.getString("Disc");
|
||||||
|
UUID playerId = compound.getUniqueId("PlayerId");
|
||||||
|
int slot = compound.getInteger("Slot");
|
||||||
|
|
||||||
|
Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
EntityPlayer player = mc.world.getPlayerEntityByUUID(playerId);
|
||||||
|
if(player != null){
|
||||||
|
Item item = Item.REGISTRY.getObject(new ResourceLocation(disc));
|
||||||
|
if(item instanceof ItemRecord){
|
||||||
|
ItemRecord record = (ItemRecord)item;
|
||||||
|
|
||||||
|
SoundEvent sound = record.getSound();
|
||||||
|
if(sound != null){
|
||||||
|
mc.getSoundHandler().playSound(new MovingPlayerSound(sound, SoundCategory.RECORDS, player, slot));
|
||||||
|
mc.ingameGUI.setRecordPlayingMessage(record.getRecordNameLocal());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public static SimpleNetworkWrapper theNetwork;
|
public static SimpleNetworkWrapper theNetwork;
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
|
@ -135,5 +166,6 @@ public final class PacketHandler{
|
||||||
DATA_HANDLERS.add(GUI_NUMBER_TO_TILE_HANDLER);
|
DATA_HANDLERS.add(GUI_NUMBER_TO_TILE_HANDLER);
|
||||||
DATA_HANDLERS.add(CHANGE_PLAYER_DATA_HANDLER);
|
DATA_HANDLERS.add(CHANGE_PLAYER_DATA_HANDLER);
|
||||||
DATA_HANDLERS.add(GUI_BUTTON_TO_CONTAINER_HANDLER);
|
DATA_HANDLERS.add(GUI_BUTTON_TO_CONTAINER_HANDLER);
|
||||||
|
DATA_HANDLERS.add(SEND_PORTABLE_JUKEBOX_SOUND_HANDLER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
import de.ellpeck.actuallyadditions.mod.misc.sound.SoundHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
|
|
|
@ -14,7 +14,7 @@ import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
|
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
import de.ellpeck.actuallyadditions.mod.misc.sound.SoundHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
import de.ellpeck.actuallyadditions.mod.misc.sound.SoundHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
|
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
|
|
Loading…
Reference in a new issue