Skip to content

Commit

Permalink
some update
Browse files Browse the repository at this point in the history
  • Loading branch information
H2Sxxa committed Jun 10, 2023
1 parent 55dbb68 commit bf4b3f6
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.compile.nullAnalysis.mode": "automatic"
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ task initembedJar(type:Copy){
def alljar = fileTree(dir:embeddir,includes:['*jar'])
duplicatesStrategy(DuplicatesStrategy.INCLUDE)
//Unpack Jar to class
for (jarpath:alljar){
for (jarpath in alljar){
println 'Unpack ' + jarpath
def zipFile = file(jarpath)
def outputDir = file(tempdir)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/teamgensouspark/kekkai/Kekkai.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.apache.logging.log4j.Logger;

import io.github.teamgensouspark.kekkai.proxy.CommonProxy;
import io.github.teamgensouspark.kekkai.proxy.Const;

@Mod(
Expand All @@ -24,6 +25,5 @@ public class Kekkai {
public static void PreInit(FMLPreInitializationEvent event)
{
logger=event.getModLog();
ModReg.preInitRegistries();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.github.teamgensouspark.kekkai.interfaces;

public interface IHasModel {
public void registerModels();
}
23 changes: 23 additions & 0 deletions src/main/java/io/github/teamgensouspark/kekkai/item/ItemBase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.github.teamgensouspark.kekkai.item;

import io.github.teamgensouspark.kekkai.Kekkai;
import io.github.teamgensouspark.kekkai.interfaces.IHasModel;
import io.github.teamgensouspark.kekkai.register.RegisterInit;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

public class ItemBase extends Item implements IHasModel {

public ItemBase(String name,CreativeTabs tab){
setTranslationKey(name);
setRegistryName(name);
setCreativeTab(tab);

RegisterInit.ITEMS.add(this);
}
@Override
public void registerModels() {
Kekkai.proxy.registerItemRenderer(this, 0, "inventory");
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package io.github.teamgensouspark.kekkai.proxy;

public class Const {
public static String MODID = "kekkai";
public static String VERSION = "1.0.0";
public static String NAME = "Kekkai";

public static final String MODID = "kekkai";
public static final String VERSION = "1.0.0";
public static final String NAME = "Kekkai";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.github.teamgensouspark.kekkai.register;

import io.github.teamgensouspark.kekkai.interfaces.IHasModel;
import net.katsstuff.teamnightclipse.danmakucore.entity.spellcard.Spellcard;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@EventBusSubscriber
public class RegisterHandle {

public static void preInitRegistries(){
}

@SubscribeEvent
public static void onItemRegister(RegistryEvent.Register<Item> event) {
event.getRegistry().registerAll(RegisterInit.ITEMS.toArray(new Item[0]));
}
@SubscribeEvent
public static void onSpellCardRegister(RegistryEvent.Register<Spellcard> event){
event.getRegistry().registerAll(RegisterInit.SPELL_CARDS.toArray(new Spellcard[0]));
}

@SubscribeEvent
public static void onModelRegister(ModelRegistryEvent event) {
for(Item item : RegisterInit.ITEMS){
if(item instanceof IHasModel) {
((IHasModel)item).registerModels();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.github.teamgensouspark.kekkai.register;

import java.util.ArrayList;
import java.util.List;

import net.katsstuff.teamnightclipse.danmakucore.entity.spellcard.Spellcard;
import net.minecraft.item.Item;

public class RegisterInit {
public static final List<Spellcard> SPELL_CARDS = new ArrayList<>();
public static final List<Item> ITEMS = new ArrayList<>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.github.teamgensouspark.kekkai.spellcard;

public class Generator {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package io.github.teamgensouspark.kekkai.spellcard;

import java.lang.reflect.Constructor;

import io.github.teamgensouspark.kekkai.Kekkai;
import net.katsstuff.teamnightclipse.danmakucore.entity.living.TouhouCharacter;
import net.katsstuff.teamnightclipse.danmakucore.entity.spellcard.EntitySpellcard;
import net.katsstuff.teamnightclipse.danmakucore.entity.spellcard.Spellcard;
import net.katsstuff.teamnightclipse.danmakucore.entity.spellcard.SpellcardEntity;
import net.minecraft.entity.EntityLivingBase;
import scala.Option;

public class SpellCardBase<T extends SpellcardEntity> extends Spellcard {
int level = 1;
int removeTime = 50;
int endTime = 50;
String name;
TouhouCharacter character;
Class<T> spellcard;
public SpellCardBase (String name,Class<T> spellcard,TouhouCharacter character){
super(name);
this.name=name;
this.character=character;
this.spellcard=spellcard;

//ModSpellCard.SPELL_CARDS.add(this);
}

@Override
public SpellcardEntity instantiate(EntitySpellcard entitySpellcard, Option<EntityLivingBase> target) {
try {
Constructor<T> constructor = this.spellcard.getDeclaredConstructor(Spellcard.class,EntitySpellcard.class,Option.class);
constructor.setAccessible(true);
return constructor.newInstance(this,entitySpellcard,target);
} catch (Exception e) {
Kekkai.logger.error("Reflect Failed");
return new SpellcardEntity(this,entitySpellcard,target) {
@Override
public void onSpellcardUpdate() {}
};
}
}

@Override
public int level() {
return this.level;
}

public Spellcard setlevel(int level){
this.level=level;
return this;
}

@Override
public int removeTime() {
return this.removeTime;
}

public Spellcard setremoveTime(int removeTime){
this.removeTime=removeTime;
return this;
}

@Override
public int endTime() {
return this.endTime;
}

public Spellcard setendTime(int endTime){
this.endTime=endTime;
return this;
}

@Override
public TouhouCharacter touhouUser() {
return this.character;
}
}
File renamed without changes.

0 comments on commit bf4b3f6

Please sign in to comment.