Skip to content

Commit

Permalink
Version 1.1.1
Browse files Browse the repository at this point in the history
Reach trait now affects attack range... that was more difficult than it
should be
Fixed 'empty' melting recipes for Valkyrie Armour
  • Loading branch information
Shnupbups committed Jul 1, 2018
1 parent 5baa9d4 commit 8577ed6
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.


version = "1.1.0"
version = "1.1.1"
group = "shnupbups.tinkersaether" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "tinkersaether"

Expand Down
18 changes: 14 additions & 4 deletions src/main/java/shnupbups/tinkersaether/TinkersAether.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.common.registry.EntityEntry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.relauncher.Side;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import shnupbups.tinkersaether.config.TAConfig;
import shnupbups.tinkersaether.entities.EntityDart;
import shnupbups.tinkersaether.misc.MiscUtils;
import shnupbups.tinkersaether.modules.ModuleBase;
import shnupbups.tinkersaether.network.HandlerExtendedAttack;
import shnupbups.tinkersaether.network.MessageExtendedAttack;
import shnupbups.tinkersaether.proxy.CommonProxy;
import slimeknights.tconstruct.library.materials.BowMaterialStats;
import slimeknights.tconstruct.tools.TinkerMaterials;
Expand All @@ -26,14 +31,16 @@
public class TinkersAether {
public static final String modid = "tinkersaether";
public static final String name = "MoreTiC";
public static final String version = "1.1.0";
public static final String version = "1.1.1";

@Mod.Instance(modid)
public static TinkersAether instance;

@SidedProxy(serverSide = "shnupbups.tinkersaether.proxy.CommonProxy", clientSide = "shnupbups.tinkersaether.proxy.ClientProxy")
public static CommonProxy proxy;

public static SimpleNetworkWrapper network = NetworkRegistry.INSTANCE.newSimpleChannel(modid+"network");

public static final Logger logger = LogManager.getLogger(modid);

public static BowMaterialStats plzNo = new BowMaterialStats(0.2f, 0.4f, -1f);
Expand All @@ -45,16 +52,19 @@ public TinkersAether() {

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
ModuleBase.aether.preInit();
ModuleBase.base.preInit();
}

@Mod.EventHandler
public void init(FMLInitializationEvent event) {
int packet = 0;
network.registerMessage(HandlerExtendedAttack.class,MessageExtendedAttack.class, packet++, Side.SERVER);

if(TAConfig.darts) {
proxy.initToolGuis();
}

ModuleBase.aether.init();
ModuleBase.base.init();

if(TAConfig.skyroot) {
MiscUtils.displace(TinkerMaterials.wood.getIdentifier()); // Skyroot needs priority
Expand All @@ -63,7 +73,7 @@ public void init(FMLInitializationEvent event) {

@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) {

ModuleBase.base.postInit();
}

@SubscribeEvent
Expand Down
19 changes: 6 additions & 13 deletions src/main/java/shnupbups/tinkersaether/modules/ModuleBase.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package shnupbups.tinkersaether.modules;

import com.legacy.aether.items.ItemsAether;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
Expand Down Expand Up @@ -31,7 +30,7 @@

@Mod.EventBusSubscriber(modid = TinkersAether.modid)
public class ModuleBase {
public static ModuleBase aether = new ModuleBase();
public static ModuleBase base = new ModuleBase();

public ModuleBase() {
MinecraftForge.EVENT_BUS.register(this);
Expand Down Expand Up @@ -178,21 +177,15 @@ public void init() {

TinkersAether.logger.info("Base Module - OreDict Registered");

TinkersAether.logger.info("Base Module - End Init");
}

public void postInit() {
if(TAConfig.gravitite) {
TinkerRegistry.registerMelting("blockEnchantedGravitite", gravitite.getFluid(), Material.VALUE_Ingot);
TinkerRegistry.registerBasinCasting(new CastingRecipe(MiscUtils.stackFromOreDict("blockEnchantedGravitite"), gravitite.getFluid(), Material.VALUE_Ingot, 180));
TinkersAether.logger.info("Base Module - Gravitite Stuffs Registered");
}

if(TAConfig.valkyrie) {
TinkerRegistry.registerMelting(ItemsAether.valkyrie_boots, valkyrie.getFluid(), Material.VALUE_Ingot*4);
TinkerRegistry.registerMelting(ItemsAether.valkyrie_chestplate, valkyrie.getFluid(), Material.VALUE_Ingot*8);
TinkerRegistry.registerMelting(ItemsAether.valkyrie_helmet, valkyrie.getFluid(), Material.VALUE_Ingot*5);
TinkerRegistry.registerMelting(ItemsAether.valkyrie_leggings, valkyrie.getFluid(), Material.VALUE_Ingot*7);
}

TinkersAether.logger.info("Base Module - Gravitite Stuffs Registered");

TinkersAether.logger.info("Base Module - End Init");
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package shnupbups.tinkersaether.network;

import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import shnupbups.tinkersaether.traits.Reach;
import slimeknights.tconstruct.library.tools.TinkerToolCore;
import slimeknights.tconstruct.library.utils.ToolHelper;

public class HandlerExtendedAttack implements IMessageHandler<MessageExtendedAttack,IMessage> {
@Override
public IMessage onMessage(MessageExtendedAttack message, MessageContext ctx) {
EntityPlayerMP player = ctx.getServerHandler().player;
player.getServer().addScheduledTask( new Runnable() {
@Override
public void run() {
Entity entity = player.getEntityWorld().getEntityByID(message.getEntityId());
ItemStack stack = player.getHeldItemMainhand();
if(stack.isEmpty() || !(stack.getItem() instanceof TinkerToolCore)) {
return;
}
if(ToolHelper.getTraits(stack).contains(Reach.reach)) {
player.attackTargetEntityWithCurrentItem(entity);
}
}
});
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package shnupbups.tinkersaether.network;

import io.netty.buffer.ByteBuf;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;

public class MessageExtendedAttack implements IMessage {

private int entity;

public MessageExtendedAttack() {

}

public MessageExtendedAttack(int entity) {
this.entity=entity;
}

@Override
public void fromBytes(ByteBuf buf) {
entity = ByteBufUtils.readVarInt(buf, 4);
}

@Override
public void toBytes(ByteBuf buf) {
ByteBufUtils.writeVarInt(buf, entity, 4);
}

public int getEntityId() {
return entity;
}
}
46 changes: 46 additions & 0 deletions src/main/java/shnupbups/tinkersaether/traits/Reach.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package shnupbups.tinkersaether.traits;

import net.minecraft.entity.Entity;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import shnupbups.tinkersaether.TinkersAether;
import shnupbups.tinkersaether.network.MessageExtendedAttack;
import slimeknights.tconstruct.library.traits.AbstractTrait;

import java.util.List;
import java.util.UUID;

public class Reach extends AbstractTrait {
Expand All @@ -32,4 +39,43 @@ public void onPlayerUpdate(LivingEvent.LivingUpdateEvent event) {
}
}
}

@SubscribeEvent
public void onMouseClick(PlayerInteractEvent.LeftClickEmpty event) {
EntityPlayer player = event.getEntityPlayer();
ItemStack stack = player.getHeldItemMainhand();
if(isToolWithTrait(stack)) {
Vec3d playerVision = player.getLookVec();
AxisAlignedBB reachDistance = player.getEntityBoundingBox().grow(10.0D);
List<Entity> locatedEntities = player.world.getEntitiesWithinAABB(Entity.class, reachDistance);
Entity found = null;
double foundLen = 0.0D;
for (Object o : locatedEntities) {
if (o == player) {
continue;
}
Entity ent = (Entity) o;
if (!ent.canBeCollidedWith()) {
continue;
}
Vec3d vec = new Vec3d(ent.posX - player.posX, ent.getEntityBoundingBox().minY + ent.height / 2f - player.posY - player.getEyeHeight(), ent.posZ - player.posZ);
double len = vec.lengthVector();
if (len > 10.0F) {
continue;
}
vec = vec.normalize();
double dot = playerVision.dotProduct(vec);
if (dot < 1.0 - 0.125 / len || !player.canEntityBeSeen(ent)) {
continue;
}
if (foundLen == 0.0 || len < foundLen) {
found = ent;
foundLen = len;
}
}
if (found != null && player.getRidingEntity() != found) {
TinkersAether.network.sendToServer(new MessageExtendedAttack(found.getEntityId()));
}
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"modid": "tinkersaether",
"name": "Tinker's Aether",
"description": "Adds Aether materials and stuff to Tinker's Construct.",
"version": "1.1.0",
"version": "1.1.1",
"mcversion": "${mcversion}",
"url": "",
"updateUrl": "",
Expand Down

0 comments on commit 8577ed6

Please sign in to comment.