Skip to content

Commit

Permalink
Don't use client-side classes in serverside code (fixes #277)
Browse files Browse the repository at this point in the history
  • Loading branch information
founderio committed Feb 25, 2019
1 parent 25acd31 commit 7c69f88
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 36 deletions.
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod_version=1.1.0-alpha4
mod_version=1.1.0-alpha5
mod_name=Taam
mod_group=net.teamio.taam
mc_version=1.12.2
Expand Down
16 changes: 4 additions & 12 deletions common/net/teamio/taam/Taam.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package net.teamio.taam;

import net.minecraft.block.state.IBlockState;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.teamio.taam.content.common.BlockOre;
Expand All @@ -30,9 +27,6 @@
import net.teamio.taam.util.TaamUtil;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

Expand Down Expand Up @@ -345,8 +339,8 @@ public boolean isDirectionSupported(EnumFacing dir) {
}

@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
// So far, no additional info
public String[] getTooltip() {
return null;
}
}

Expand Down Expand Up @@ -505,10 +499,8 @@ public String unlocalizedName() {
}

@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
if (info != null) {
Collections.addAll(tooltip, info);
}
public String[] getTooltip() {
return info;
}

/*
Expand Down
12 changes: 7 additions & 5 deletions common/net/teamio/taam/content/conveyors/ItemAppliance.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {

@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side,
float hitX, float hitY, float hitZ, IBlockState newState) {
float hitX, float hitY, float hitZ, IBlockState newState) {
EnumFacing dir = side.getOpposite();
int meta = stack.getMetadata();
IConveyorApplianceMetaInfo info = getInfo(meta);

// If the player clicked the top or bottom & that is not supported
// use the player's facing direction
if(!info.isDirectionSupported(dir)) {
if(dir.getAxis() == EnumFacing.Axis.Y) {
if (!info.isDirectionSupported(dir)) {
if (dir.getAxis() == EnumFacing.Axis.Y) {
dir = player.getAdjustedHorizontalFacing();
} else {
return false;
Expand Down Expand Up @@ -105,8 +105,10 @@ public void addInformation(ItemStack stack, @Nullable World worldIn, List<String
}
// Add metadata-specific values
int meta = stack.getMetadata();
IConveyorApplianceMetaInfo info = getInfo(meta);
info.addInformation(stack, worldIn, tooltip, flagIn);
String[] ttip = getInfo(meta).getTooltip();
if (ttip != null) {
Collections.addAll(tooltip, ttip);
}
}

}
12 changes: 3 additions & 9 deletions common/net/teamio/taam/conveyors/IConveyorApplianceMetaInfo.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
package net.teamio.taam.conveyors;

import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.World;

import javax.annotation.Nullable;
import java.util.List;

/**
* Meta information for appliances
*/
public interface IConveyorApplianceMetaInfo extends IStringSerializable {
public interface IConveyorApplianceMetaInfo extends IStringSerializable {
/**
* Return true if this appliance can be oriented in the requested direction.
* Used to prevent using an unsupported orientation before placing a block.
* Checked in {@link net.teamio.taam.content.conveyors.ItemAppliance}.
*
* @param dir
* @return
*/
Expand All @@ -26,7 +21,6 @@ public interface IConveyorApplianceMetaInfo extends IStringSerializable {

String unlocalizedName();

void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn);

String[] getTooltip();

}
8 changes: 1 addition & 7 deletions common/net/teamio/taam/machines/IMachineMetaInfo.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package net.teamio.taam.machines;

import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.World;

import javax.annotation.Nullable;
import java.util.List;

public interface IMachineMetaInfo extends IStringSerializable {
IMachine createMachine(IMachineWrapper wrapper);
Expand All @@ -15,5 +9,5 @@ public interface IMachineMetaInfo extends IStringSerializable {

String unlocalizedName();

void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn);
String[] getTooltip();
}
7 changes: 5 additions & 2 deletions common/net/teamio/taam/machines/MachineItemBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.teamio.taam.content.IRotatable;

import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;

public class MachineItemBlock extends ItemBlock {
Expand All @@ -34,8 +35,10 @@ public int getMetadata(int damage) {
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
int meta = stack.getMetadata();
IMachineMetaInfo info = MachineTileEntity.getInfo(meta);
info.addInformation(stack, worldIn, tooltip, flagIn);
String[] ttip = MachineTileEntity.getInfo(meta).getTooltip();
if (ttip != null) {
Collections.addAll(tooltip, ttip);
}
}

@Override
Expand Down

0 comments on commit 7c69f88

Please sign in to comment.