Skip to content

Commit

Permalink
For a dev release version
Browse files Browse the repository at this point in the history
  • Loading branch information
Giant-Salted-Fish committed Mar 6, 2023
1 parent 5e32004 commit 527264d
Show file tree
Hide file tree
Showing 31 changed files with 689 additions and 159 deletions.
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// See https://gitlab.com/gofancy/fancygradle
plugins {
id 'eclipse'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '5.1.+'
id 'wtf.gofancy.fancygradle' version '1.1.+'
}

version = '1.0'
group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'modid'
version = '0.2.0-alpha'
group = 'com.mcwb' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = '[MC-1.12.2] FMUM 2.0 v' + version + ' - 2023-3-6'

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.

Expand Down
7 changes: 7 additions & 0 deletions run/mcwb/Octagon Weapons/assets/mcwb/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ item.cic_is9_rear_sight-tritium_green.name=CIC IS-9 Rear Sight - Tritium Green
item.cic_is9_rear_sight-tritium_red.name=CIC IS-9 Rear Sight - Tritium Red
item.cic_is9_rear_sight-tritium_white.name=CIC IS-9 Rear Sight - Tritium White

# Optic sight
item.kobra_ekp8mpp.name=Kobra EKP-8M-PP
item.eotech_exps30.name=Eotech EXPS3-0

# Grip
item.td_grip.name=TD Grip

# Muzzle
item.556mm_thread_protector.name=5.56mm Thread Protector

Expand Down
9 changes: 8 additions & 1 deletion run/mcwb/Octagon Weapons/assets/mcwb/lang/zh_cn.lang
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ item.hk416_165_barrel.name=H&K416 16.5英寸枪管
item.hk416_20_barrel.name=H&K416 20英寸枪管
item.hk416_barrel_extension.name=H&K416 枪管节套
item.hk416_barrel_nut.name=H&K416 枪管螺母
item.hk416_bolt.name=H&K416 枪击组件
item.hk416_bolt.name=H&K416 枪机组件
item.hk416_buffer_tube.name=H&K416 缓冲管
item.hk416_charge_handle.name=H&K416 拉机柄
item.hk416_dust_cover.name=H&K416 防尘盖
Expand Down Expand Up @@ -64,6 +64,13 @@ item.cic_is9_rear_sight-tritium_green.name=CIC IS-9 照门 - 绿氚光
item.cic_is9_rear_sight-tritium_red.name=CIC IS-9 照门 - 红氚光
item.cic_is9_rear_sight-tritium_white.name=CIC IS-9 照门 - 白氚光

# 光瞄
item.kobra_ekp8mpp.name=Kobra EKP-8M-PP 反射式红点瞄具
item.eotech_exps30.name=Eotech EXPS3-0 全息瞄具

# 握把
item.td_grip.name=TD 握把

# 膛口装置
item.556mm_thread_protector.name=5.56mm 螺纹保护帽

Expand Down
5 changes: 3 additions & 2 deletions run/mcwb/Octagon Weapons/pack.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "oc.pack",
"author": "oc.author",
"version": "0.1.0-alpha",
"coreVersion": "0.1.0-alpha"
"version": "0.2.0-alpha",
"coreVersion": "0.2.0-alpha",
"ignoreEntries": [ "com" ]
}
6 changes: 5 additions & 1 deletion src/main/java/com/mcwb/client/gun/GunPartRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mcwb.client.item.ModifiableItemRenderer;
import com.mcwb.client.render.IAnimator;
import com.mcwb.client.render.IRenderer;
import com.mcwb.common.MCWB;
import com.mcwb.common.gun.IGunPart;
import com.mcwb.common.load.BuildableLoader;
import com.mcwb.util.ArmTracker;
Expand All @@ -17,7 +18,10 @@ public class GunPartRenderer< T extends IGunPart< ? > >
extends ModifiableItemRenderer< T > implements IGunPartRenderer< T >
{
public static final BuildableLoader< IRenderer >
LOADER = new BuildableLoader<>( "gun_part", GunPartRenderer.class );
LOADER = new BuildableLoader<>(
"gun_part",
json -> MCWB.GSON.fromJson( json, GunPartRenderer.class )
);

@Override
public void setupLeftArmToRender( ArmTracker leftArm, IAnimator animator )
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/mcwb/client/gun/GunRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.mcwb.client.player.PlayerPatchClient;
import com.mcwb.client.render.IAnimator;
import com.mcwb.client.render.IRenderer;
import com.mcwb.common.MCWB;
import com.mcwb.common.gun.IGun;
import com.mcwb.common.load.BuildableLoader;
import com.mcwb.common.load.IContentProvider;
Expand All @@ -30,8 +31,8 @@
@SideOnly( Side.CLIENT )
public class GunRenderer< T extends IGun< ? > > extends GunPartRenderer< T >
{
public static final BuildableLoader< IRenderer >
LOADER = new BuildableLoader<>( "gun", GunRenderer.class );
public static final BuildableLoader< IRenderer > LOADER =
new BuildableLoader<>( "gun", json -> MCWB.GSON.fromJson( json, GunRenderer.class ) );

protected static final Vec3f HOLD_POS = new Vec3f( -14F / 160F, -72F / 160F, 87.5F / 160F );
protected static final Vec3f HOLD_ROT = new Vec3f( 0F, 0F, -5F );
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/mcwb/client/gun/OpticSightRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.mcwb.client.module.IDeferredRenderer;
import com.mcwb.client.render.IAnimator;
import com.mcwb.client.render.IRenderer;
import com.mcwb.common.MCWB;
import com.mcwb.common.gun.IGunPart;
import com.mcwb.common.load.BuildableLoader;
import com.mcwb.common.load.IContentProvider;
Expand All @@ -25,7 +26,10 @@
public class OpticSightRenderer< T extends IGunPart< ? > > extends GunPartRenderer< T >
{
public static final BuildableLoader< IRenderer >
LOADER = new BuildableLoader<>( "optic_sight", OpticSightRenderer.class );
LOADER = new BuildableLoader<>(
"optic_sight",
json -> MCWB.GSON.fromJson( json, OpticSightRenderer.class )
);

@SerializedName( value = "lenMeshPath", alternate = "lenMesh" )
protected String lenMeshPath = "";
Expand Down
112 changes: 112 additions & 0 deletions src/main/java/com/mcwb/client/player/OpLoadAmmoClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package com.mcwb.client.player;

import com.mcwb.client.MCWBClient;
import com.mcwb.client.input.InputHandler;
import com.mcwb.common.IAutowirePacketHandler;
import com.mcwb.common.ammo.IAmmoType;
import com.mcwb.common.gun.IMag;
import com.mcwb.common.item.IItem;
import com.mcwb.common.item.IItemType;
import com.mcwb.common.item.IItemTypeHost;
import com.mcwb.common.network.PacketCode;
import com.mcwb.common.network.PacketCodeAssist;
import com.mcwb.common.network.PacketCodeAssist.Code;
import com.mcwb.common.operation.IOperation;
import com.mcwb.common.operation.Operation;

import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly( Side.CLIENT )
public class OpLoadAmmoClient extends Operation< IMag< ? > > implements IAutowirePacketHandler
{
protected int invSlot;

public OpLoadAmmoClient() { super( null, null, null ); }

public IOperation reset( IMag< ? > mag )
{
this.player = MCWBClient.MC.player;
this.contexted = mag;
this.controller = mag.pushAmmoController();
return this;
}

@Override
public IOperation launch( IOperation oldOp )
{
switch( 0 )
{
default:
if( this.contexted.isFull() ) break;

this.invSlot = this.getValidAmmoSlot( InputHandler.CO.down ? 1 : 0 );
if( this.invSlot == -1 ) break;

this.clearProgress();
this.sendToServer( new PacketCodeAssist( Code.LOAD_AMMO, this.invSlot ) );
return this;
}

return NONE;
}

@Override
public IOperation terminate()
{
this.sendToServer( new PacketCode( PacketCode.Code.TERMINATE_OP ) );
return NONE;
}

@Override
public IOperation onInHandStackChange( IItem newItem )
{
if( ( ( IMag< ? > ) newItem ).isFull() )
return this.terminate();

this.contexted = ( IMag< ? > ) newItem;
return this;
}

@Override
protected IOperation onComplete()
{
this.clearProgress();
return this.launch( this );
}

@Override
protected void doHandleEffect()
{
final ItemStack stack = this.player.inventory.getStackInSlot( this.invSlot );
final IItemType type = IItemTypeHost.getTypeOrDefault( stack );
if( !( type instanceof IAmmoType ) ) return;

final IAmmoType ammo = ( IAmmoType ) type;
if( !this.contexted.isAllowed( ammo ) ) return;

this.contexted.pushAmmo( ammo );
// if( !this.player.capabilities.isCreativeMode )
stack.shrink( 1 );
}

protected int getValidAmmoSlot( int offset )
{
final InventoryPlayer inv = this.player.inventory;

int invSlot = -1;
for( int i = 0, size = inv.getSizeInventory(); offset >= 0 && i < size; ++i )
{
final ItemStack stack = inv.getStackInSlot( i );
final IItemType type = IItemTypeHost.getTypeOrDefault( stack );
if( type instanceof IAmmoType && this.contexted.isAllowed( ( IAmmoType ) type ) )
{
invSlot = i;
--offset;
}
}
return invSlot;
}
}
101 changes: 101 additions & 0 deletions src/main/java/com/mcwb/client/player/OpLoadMagClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.mcwb.client.player;

import com.mcwb.client.MCWBClient;
import com.mcwb.common.IAutowirePacketHandler;
import com.mcwb.common.gun.IGun;
import com.mcwb.common.gun.IMag;
import com.mcwb.common.item.IItem;
import com.mcwb.common.item.IItemTypeHost;
import com.mcwb.common.network.PacketCode;
import com.mcwb.common.network.PacketCodeAssist;
import com.mcwb.common.network.PacketCodeAssist.Code;
import com.mcwb.common.operation.IOperation;
import com.mcwb.common.operation.Operation;

import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly( Side.CLIENT )
public class OpLoadMagClient extends Operation< IGun< ? > > implements IAutowirePacketHandler
{
protected int invSlot;

protected IMag< ? > mag;

public OpLoadMagClient() { super( null, null, null ); }

public IOperation reset( IGun< ? > gun )
{
this.player = MCWBClient.MC.player;
this.contexted = gun;
this.controller = gun.loadMagController();
return this;
}

@Override
public IOperation launch( IOperation oldOp )
{
switch( 0 )
{
default:
if( this.contexted.hasMag() ) break;

this.invSlot = this.getValidMagSlot();
if( this.invSlot == -1 ) break;

final ItemStack stack = this.player.inventory.getStackInSlot( this.invSlot );
this.mag = ( IMag< ? > ) IItemTypeHost.getTypeA( stack ).getContexted( stack );

this.clearProgress();
this.sendToServer( new PacketCodeAssist( Code.LOAD_MAG, this.invSlot ) );
return this;
}

return NONE;
}

@Override
public IOperation terminate()
{
this.sendToServer( new PacketCode( PacketCode.Code.TERMINATE_OP ) );
return NONE;
}

@Override
public IOperation onInHandStackChange( IItem newItem )
{
if( ( ( IGun< ? > ) newItem ).hasMag() )
return this.terminate();

this.contexted = ( IGun< ? > ) newItem;
return this;
}

@Override
protected void doHandleEffect()
{
// Calling install will change the state of the mag itself, hence copy before use
// final ItemStack stack = this.player.inventory.getStackInSlot( this.invSlot ).copy();
// final IItem item = IItemTypeHost.getTypeOrDefault( stack ).getContexted( stack );
// if( !( item instanceof IMag< ? > ) ) return;
//
// final IMag< ? > mag = ( IMag< ? > ) item;
// if( this.contexted.isAllowed( mag ) )
// this.contexted.loadMag( mag );
}

protected int getValidMagSlot()
{
final InventoryPlayer inv = this.player.inventory;
for( int i = 0, size = inv.getSizeInventory(); i < size; ++i )
{
final ItemStack stack = inv.getStackInSlot( i );
final IItem item = IItemTypeHost.getTypeOrDefault( stack ).getContexted( stack );
if( item instanceof IMag< ? > && this.contexted.isAllowed( ( IMag< ? > ) item ) )
return i;
}
return -1;
}
}
3 changes: 1 addition & 2 deletions src/main/java/com/mcwb/client/player/OpModifyClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public OpModifyClient() {
return this.renderDelegate != null ? ( T ) this.renderDelegate : original;
}

public OpModifyClient reset()
public IOperation reset()
{
this.player = MCWBClient.MC.player;
this.stack = this.player.inventory.getCurrentItem();
Expand Down Expand Up @@ -381,7 +381,6 @@ public IOperation launch( IOperation oldOp )
return super.launch( oldOp );
}


@Override
public IOperation toggle()
{
Expand Down
Loading

0 comments on commit 527264d

Please sign in to comment.