mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-07 07:50:27 +00:00
Switch to Mojang mappings
ForgeGradle (probably sensibly) yells at me about doing this. However: - There's a reasonable number of mods doing this, which establishes some optimistic precedent. - The licence update in Aug 2020 now allows you to use them for "development purposes". I guess source code counts?? - I'm fairly sure this is also compatible with the CCPL - there's an exception for Minecraft code. The main motivation for this is to make the Fabric port a little easier. Hopefully folks (maybe me in the future, we'll see) will no longer have to deal with mapping hell when merging - only mod loader hell.
This commit is contained in:
parent
c864576619
commit
34b5ede326
@ -75,7 +75,7 @@ minecraft {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mappings channel: 'snapshot', version: "${mappings_version}".toString()
|
mappings channel: 'official', version: project.mc_version
|
||||||
|
|
||||||
accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg')
|
accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||||
}
|
}
|
||||||
|
@ -4,4 +4,3 @@ mod_version=1.95.1
|
|||||||
# Minecraft properties (update mods.toml when changing)
|
# Minecraft properties (update mods.toml when changing)
|
||||||
mc_version=1.15.2
|
mc_version=1.15.2
|
||||||
forge_version=31.1.41
|
forge_version=31.1.41
|
||||||
mappings_version=20200429-1.15.1
|
|
||||||
|
@ -54,7 +54,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
|
|||||||
|
|
||||||
public static InputStream getResourceFile( String domain, String subPath )
|
public static InputStream getResourceFile( String domain, String subPath )
|
||||||
{
|
{
|
||||||
IReloadableResourceManager manager = ServerLifecycleHooks.getCurrentServer().getResourceManager();
|
IReloadableResourceManager manager = ServerLifecycleHooks.getCurrentServer().getResources();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return manager.getResource( new ResourceLocation( domain, subPath ) ).getInputStream();
|
return manager.getResource( new ResourceLocation( domain, subPath ) ).getInputStream();
|
||||||
@ -97,7 +97,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
|
|||||||
@Override
|
@Override
|
||||||
public IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath )
|
public IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath )
|
||||||
{
|
{
|
||||||
IReloadableResourceManager manager = ServerLifecycleHooks.getCurrentServer().getResourceManager();
|
IReloadableResourceManager manager = ServerLifecycleHooks.getCurrentServer().getResources();
|
||||||
ResourceMount mount = ResourceMount.get( domain, subPath, manager );
|
ResourceMount mount = ResourceMount.get( domain, subPath, manager );
|
||||||
return mount.exists( "" ) ? mount : null;
|
return mount.exists( "" ) ? mount : null;
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
|
|||||||
@Override
|
@Override
|
||||||
public LazyOptional<IWiredElement> getWiredElementAt( @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull Direction side )
|
public LazyOptional<IWiredElement> getWiredElementAt( @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull Direction side )
|
||||||
{
|
{
|
||||||
TileEntity tile = world.getTileEntity( pos );
|
TileEntity tile = world.getBlockEntity( pos );
|
||||||
return tile == null ? LazyOptional.empty() : tile.getCapability( CAPABILITY_WIRED_ELEMENT, side );
|
return tile == null ? LazyOptional.empty() : tile.getCapability( CAPABILITY_WIRED_ELEMENT, side );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public final class TransformedModel
|
|||||||
|
|
||||||
public static TransformedModel of( @Nonnull ItemStack item, @Nonnull TransformationMatrix transform )
|
public static TransformedModel of( @Nonnull ItemStack item, @Nonnull TransformationMatrix transform )
|
||||||
{
|
{
|
||||||
IBakedModel model = Minecraft.getInstance().getItemRenderer().getItemModelMesher().getItemModel( item );
|
IBakedModel model = Minecraft.getInstance().getItemRenderer().getItemModelShaper().getItemModel( item );
|
||||||
return new TransformedModel( model, transform );
|
return new TransformedModel( model, transform );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ public abstract class AbstractPocketUpgrade implements IPocketUpgrade
|
|||||||
|
|
||||||
protected AbstractPocketUpgrade( ResourceLocation id, NonNullSupplier<ItemStack> item )
|
protected AbstractPocketUpgrade( ResourceLocation id, NonNullSupplier<ItemStack> item )
|
||||||
{
|
{
|
||||||
this( id, Util.makeTranslationKey( "upgrade", id ) + ".adjective", item );
|
this( id, Util.makeDescriptionId( "upgrade", id ) + ".adjective", item );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractPocketUpgrade( ResourceLocation id, String adjective, ItemStack stack )
|
protected AbstractPocketUpgrade( ResourceLocation id, String adjective, ItemStack stack )
|
||||||
|
@ -37,7 +37,7 @@ public abstract class AbstractTurtleUpgrade implements ITurtleUpgrade
|
|||||||
|
|
||||||
protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, NonNullSupplier<ItemStack> stack )
|
protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, NonNullSupplier<ItemStack> stack )
|
||||||
{
|
{
|
||||||
this( id, type, Util.makeTranslationKey( "upgrade", id ) + ".adjective", stack );
|
this( id, type, Util.makeDescriptionId( "upgrade", id ) + ".adjective", stack );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, String adjective, ItemStack stack )
|
protected AbstractTurtleUpgrade( ResourceLocation id, TurtleUpgradeType type, String adjective, ItemStack stack )
|
||||||
|
@ -78,7 +78,7 @@ public final class ClientRegistry
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onTextureStitchEvent( TextureStitchEvent.Pre event )
|
public static void onTextureStitchEvent( TextureStitchEvent.Pre event )
|
||||||
{
|
{
|
||||||
if( !event.getMap().getTextureLocation().equals( PlayerContainer.LOCATION_BLOCKS_TEXTURE ) ) return;
|
if( !event.getMap().location().equals( PlayerContainer.BLOCK_ATLAS ) ) return;
|
||||||
|
|
||||||
for( String extra : EXTRA_TEXTURES )
|
for( String extra : EXTRA_TEXTURES )
|
||||||
{
|
{
|
||||||
@ -96,10 +96,10 @@ public final class ClientRegistry
|
|||||||
for( String modelName : EXTRA_MODELS )
|
for( String modelName : EXTRA_MODELS )
|
||||||
{
|
{
|
||||||
ResourceLocation location = new ResourceLocation( ComputerCraft.MOD_ID, "item/" + modelName );
|
ResourceLocation location = new ResourceLocation( ComputerCraft.MOD_ID, "item/" + modelName );
|
||||||
IUnbakedModel model = loader.getUnbakedModel( location );
|
IUnbakedModel model = loader.getModel( location );
|
||||||
model.getTextures( loader::getUnbakedModel, new HashSet<>() );
|
model.getMaterials( loader::getModel, new HashSet<>() );
|
||||||
|
|
||||||
IBakedModel baked = model.bakeModel( loader, ModelLoader.defaultTextureGetter(), SimpleModelTransform.IDENTITY, location );
|
IBakedModel baked = model.bake( loader, ModelLoader.defaultTextureGetter(), SimpleModelTransform.IDENTITY, location );
|
||||||
if( baked != null )
|
if( baked != null )
|
||||||
{
|
{
|
||||||
registry.put( new ModelResourceLocation( new ResourceLocation( ComputerCraft.MOD_ID, modelName ), "inventory" ), baked );
|
registry.put( new ModelResourceLocation( new ResourceLocation( ComputerCraft.MOD_ID, modelName ), "inventory" ), baked );
|
||||||
|
@ -29,7 +29,7 @@ public class ClientTableFormatter implements TableFormatter
|
|||||||
|
|
||||||
private static FontRenderer renderer()
|
private static FontRenderer renderer()
|
||||||
{
|
{
|
||||||
return Minecraft.getInstance().fontRenderer;
|
return Minecraft.getInstance().font;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -41,7 +41,7 @@ public class ClientTableFormatter implements TableFormatter
|
|||||||
|
|
||||||
FontRenderer renderer = renderer();
|
FontRenderer renderer = renderer();
|
||||||
|
|
||||||
float spaceWidth = renderer.getStringWidth( " " );
|
float spaceWidth = renderer.width( " " );
|
||||||
int spaces = MathHelper.floor( extraWidth / spaceWidth );
|
int spaces = MathHelper.floor( extraWidth / spaceWidth );
|
||||||
int extra = extraWidth - (int) (spaces * spaceWidth);
|
int extra = extraWidth - (int) (spaces * spaceWidth);
|
||||||
|
|
||||||
@ -57,32 +57,32 @@ public class ClientTableFormatter implements TableFormatter
|
|||||||
@Override
|
@Override
|
||||||
public int getWidth( ITextComponent component )
|
public int getWidth( ITextComponent component )
|
||||||
{
|
{
|
||||||
return renderer().getStringWidth( component.getFormattedText() );
|
return renderer().width( component.getColoredString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeLine( int id, ITextComponent component )
|
public void writeLine( int id, ITextComponent component )
|
||||||
{
|
{
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
NewChatGui chat = mc.ingameGUI.getChatGUI();
|
NewChatGui chat = mc.gui.getChat();
|
||||||
|
|
||||||
// Trim the text if it goes over the allowed length
|
// Trim the text if it goes over the allowed length
|
||||||
int maxWidth = MathHelper.floor( chat.getChatWidth() / chat.getScale() );
|
int maxWidth = MathHelper.floor( chat.getWidth() / chat.getScale() );
|
||||||
List<ITextComponent> list = RenderComponentsUtil.splitText( component, maxWidth, mc.fontRenderer, false, false );
|
List<ITextComponent> list = RenderComponentsUtil.wrapComponents( component, maxWidth, mc.font, false, false );
|
||||||
if( !list.isEmpty() ) chat.printChatMessageWithOptionalDeletion( list.get( 0 ), id );
|
if( !list.isEmpty() ) chat.addMessage( list.get( 0 ), id );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int display( TableBuilder table )
|
public int display( TableBuilder table )
|
||||||
{
|
{
|
||||||
NewChatGui chat = Minecraft.getInstance().ingameGUI.getChatGUI();
|
NewChatGui chat = Minecraft.getInstance().gui.getChat();
|
||||||
|
|
||||||
int lastHeight = lastHeights.get( table.getId() );
|
int lastHeight = lastHeights.get( table.getId() );
|
||||||
|
|
||||||
int height = TableFormatter.super.display( table );
|
int height = TableFormatter.super.display( table );
|
||||||
lastHeights.put( table.getId(), height );
|
lastHeights.put( table.getId(), height );
|
||||||
|
|
||||||
for( int i = height; i < lastHeight; i++ ) chat.deleteChatLine( i + table.getId() );
|
for( int i = height; i < lastHeight; i++ ) chat.removeById( i + table.getId() );
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,22 +62,22 @@ public final class FixedWidthFontRenderer
|
|||||||
int xStart = 1 + column * (FONT_WIDTH + 2);
|
int xStart = 1 + column * (FONT_WIDTH + 2);
|
||||||
int yStart = 1 + row * (FONT_HEIGHT + 2);
|
int yStart = 1 + row * (FONT_HEIGHT + 2);
|
||||||
|
|
||||||
buffer.pos( transform, x, y, 0f ).color( r, g, b, 1.0f ).tex( xStart / WIDTH, yStart / WIDTH ).endVertex();
|
buffer.vertex( transform, x, y, 0f ).color( r, g, b, 1.0f ).uv( xStart / WIDTH, yStart / WIDTH ).endVertex();
|
||||||
buffer.pos( transform, x, y + FONT_HEIGHT, 0f ).color( r, g, b, 1.0f ).tex( xStart / WIDTH, (yStart + FONT_HEIGHT) / WIDTH ).endVertex();
|
buffer.vertex( transform, x, y + FONT_HEIGHT, 0f ).color( r, g, b, 1.0f ).uv( xStart / WIDTH, (yStart + FONT_HEIGHT) / WIDTH ).endVertex();
|
||||||
buffer.pos( transform, x + FONT_WIDTH, y, 0f ).color( r, g, b, 1.0f ).tex( (xStart + FONT_WIDTH) / WIDTH, yStart / WIDTH ).endVertex();
|
buffer.vertex( transform, x + FONT_WIDTH, y, 0f ).color( r, g, b, 1.0f ).uv( (xStart + FONT_WIDTH) / WIDTH, yStart / WIDTH ).endVertex();
|
||||||
buffer.pos( transform, x + FONT_WIDTH, y, 0f ).color( r, g, b, 1.0f ).tex( (xStart + FONT_WIDTH) / WIDTH, yStart / WIDTH ).endVertex();
|
buffer.vertex( transform, x + FONT_WIDTH, y, 0f ).color( r, g, b, 1.0f ).uv( (xStart + FONT_WIDTH) / WIDTH, yStart / WIDTH ).endVertex();
|
||||||
buffer.pos( transform, x, y + FONT_HEIGHT, 0f ).color( r, g, b, 1.0f ).tex( xStart / WIDTH, (yStart + FONT_HEIGHT) / WIDTH ).endVertex();
|
buffer.vertex( transform, x, y + FONT_HEIGHT, 0f ).color( r, g, b, 1.0f ).uv( xStart / WIDTH, (yStart + FONT_HEIGHT) / WIDTH ).endVertex();
|
||||||
buffer.pos( transform, x + FONT_WIDTH, y + FONT_HEIGHT, 0f ).color( r, g, b, 1.0f ).tex( (xStart + FONT_WIDTH) / WIDTH, (yStart + FONT_HEIGHT) / WIDTH ).endVertex();
|
buffer.vertex( transform, x + FONT_WIDTH, y + FONT_HEIGHT, 0f ).color( r, g, b, 1.0f ).uv( (xStart + FONT_WIDTH) / WIDTH, (yStart + FONT_HEIGHT) / WIDTH ).endVertex();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void drawQuad( Matrix4f transform, IVertexBuilder buffer, float x, float y, float width, float height, float r, float g, float b )
|
private static void drawQuad( Matrix4f transform, IVertexBuilder buffer, float x, float y, float width, float height, float r, float g, float b )
|
||||||
{
|
{
|
||||||
buffer.pos( transform, x, y, 0 ).color( r, g, b, 1.0f ).tex( BACKGROUND_START, BACKGROUND_START ).endVertex();
|
buffer.vertex( transform, x, y, 0 ).color( r, g, b, 1.0f ).uv( BACKGROUND_START, BACKGROUND_START ).endVertex();
|
||||||
buffer.pos( transform, x, y + height, 0 ).color( r, g, b, 1.0f ).tex( BACKGROUND_START, BACKGROUND_END ).endVertex();
|
buffer.vertex( transform, x, y + height, 0 ).color( r, g, b, 1.0f ).uv( BACKGROUND_START, BACKGROUND_END ).endVertex();
|
||||||
buffer.pos( transform, x + width, y, 0 ).color( r, g, b, 1.0f ).tex( BACKGROUND_END, BACKGROUND_START ).endVertex();
|
buffer.vertex( transform, x + width, y, 0 ).color( r, g, b, 1.0f ).uv( BACKGROUND_END, BACKGROUND_START ).endVertex();
|
||||||
buffer.pos( transform, x + width, y, 0 ).color( r, g, b, 1.0f ).tex( BACKGROUND_END, BACKGROUND_START ).endVertex();
|
buffer.vertex( transform, x + width, y, 0 ).color( r, g, b, 1.0f ).uv( BACKGROUND_END, BACKGROUND_START ).endVertex();
|
||||||
buffer.pos( transform, x, y + height, 0 ).color( r, g, b, 1.0f ).tex( BACKGROUND_START, BACKGROUND_END ).endVertex();
|
buffer.vertex( transform, x, y + height, 0 ).color( r, g, b, 1.0f ).uv( BACKGROUND_START, BACKGROUND_END ).endVertex();
|
||||||
buffer.pos( transform, x + width, y + height, 0 ).color( r, g, b, 1.0f ).tex( BACKGROUND_END, BACKGROUND_END ).endVertex();
|
buffer.vertex( transform, x + width, y + height, 0 ).color( r, g, b, 1.0f ).uv( BACKGROUND_END, BACKGROUND_END ).endVertex();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void drawQuad( Matrix4f transform, IVertexBuilder buffer, float x, float y, float width, float height, Palette palette, boolean greyscale, char colourIndex )
|
private static void drawQuad( Matrix4f transform, IVertexBuilder buffer, float x, float y, float width, float height, Palette palette, boolean greyscale, char colourIndex )
|
||||||
@ -178,9 +178,9 @@ public final class FixedWidthFontRenderer
|
|||||||
{
|
{
|
||||||
bindFont();
|
bindFont();
|
||||||
|
|
||||||
IRenderTypeBuffer.Impl renderer = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource();
|
IRenderTypeBuffer.Impl renderer = Minecraft.getInstance().renderBuffers().bufferSource();
|
||||||
drawString( IDENTITY, ((IRenderTypeBuffer) renderer).getBuffer( TYPE ), x, y, text, textColour, backgroundColour, palette, greyscale, leftMarginSize, rightMarginSize );
|
drawString( IDENTITY, ((IRenderTypeBuffer) renderer).getBuffer( TYPE ), x, y, text, textColour, backgroundColour, palette, greyscale, leftMarginSize, rightMarginSize );
|
||||||
renderer.finish();
|
renderer.endBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawTerminalWithoutCursor(
|
public static void drawTerminalWithoutCursor(
|
||||||
@ -263,10 +263,10 @@ public final class FixedWidthFontRenderer
|
|||||||
{
|
{
|
||||||
bindFont();
|
bindFont();
|
||||||
|
|
||||||
IRenderTypeBuffer.Impl renderer = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource();
|
IRenderTypeBuffer.Impl renderer = Minecraft.getInstance().renderBuffers().bufferSource();
|
||||||
IVertexBuilder buffer = renderer.getBuffer( TYPE );
|
IVertexBuilder buffer = renderer.getBuffer( TYPE );
|
||||||
drawTerminal( transform, buffer, x, y, terminal, greyscale, topMarginSize, bottomMarginSize, leftMarginSize, rightMarginSize );
|
drawTerminal( transform, buffer, x, y, terminal, greyscale, topMarginSize, bottomMarginSize, leftMarginSize, rightMarginSize );
|
||||||
renderer.finish( TYPE );
|
renderer.endBatch( TYPE );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawTerminal(
|
public static void drawTerminal(
|
||||||
@ -287,9 +287,9 @@ public final class FixedWidthFontRenderer
|
|||||||
{
|
{
|
||||||
bindFont();
|
bindFont();
|
||||||
|
|
||||||
IRenderTypeBuffer.Impl renderer = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource();
|
IRenderTypeBuffer.Impl renderer = Minecraft.getInstance().renderBuffers().bufferSource();
|
||||||
drawEmptyTerminal( transform, renderer, x, y, width, height );
|
drawEmptyTerminal( transform, renderer, x, y, width, height );
|
||||||
renderer.finish();
|
renderer.endBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawEmptyTerminal( float x, float y, float width, float height )
|
public static void drawEmptyTerminal( float x, float y, float width, float height )
|
||||||
@ -305,7 +305,7 @@ public final class FixedWidthFontRenderer
|
|||||||
|
|
||||||
private static void bindFont()
|
private static void bindFont()
|
||||||
{
|
{
|
||||||
Minecraft.getInstance().getTextureManager().bindTexture( FONT );
|
Minecraft.getInstance().getTextureManager().bind( FONT );
|
||||||
RenderSystem.texParameter( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP );
|
RenderSystem.texParameter( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,26 +315,26 @@ public final class FixedWidthFontRenderer
|
|||||||
|
|
||||||
private static final VertexFormat FORMAT = DefaultVertexFormats.POSITION_COLOR_TEX;
|
private static final VertexFormat FORMAT = DefaultVertexFormats.POSITION_COLOR_TEX;
|
||||||
|
|
||||||
static final RenderType MAIN = RenderType.makeType(
|
static final RenderType MAIN = RenderType.create(
|
||||||
"terminal_font", FORMAT, GL_MODE, 1024,
|
"terminal_font", FORMAT, GL_MODE, 1024,
|
||||||
false, false, // useDelegate, needsSorting
|
false, false, // useDelegate, needsSorting
|
||||||
RenderType.State.getBuilder()
|
RenderType.State.builder()
|
||||||
.texture( new RenderState.TextureState( FONT, false, false ) ) // blur, minimap
|
.setTextureState( new RenderState.TextureState( FONT, false, false ) ) // blur, minimap
|
||||||
.alpha( DEFAULT_ALPHA )
|
.setAlphaState( DEFAULT_ALPHA )
|
||||||
.lightmap( LIGHTMAP_DISABLED )
|
.setLightmapState( NO_LIGHTMAP )
|
||||||
.writeMask( COLOR_WRITE )
|
.setWriteMaskState( COLOR_WRITE )
|
||||||
.build( false )
|
.createCompositeState( false )
|
||||||
);
|
);
|
||||||
|
|
||||||
static final RenderType BLOCKER = RenderType.makeType(
|
static final RenderType BLOCKER = RenderType.create(
|
||||||
"terminal_blocker", FORMAT, GL_MODE, 256,
|
"terminal_blocker", FORMAT, GL_MODE, 256,
|
||||||
false, false, // useDelegate, needsSorting
|
false, false, // useDelegate, needsSorting
|
||||||
RenderType.State.getBuilder()
|
RenderType.State.builder()
|
||||||
.texture( new RenderState.TextureState( FONT, false, false ) ) // blur, minimap
|
.setTextureState( new RenderState.TextureState( FONT, false, false ) ) // blur, minimap
|
||||||
.alpha( DEFAULT_ALPHA )
|
.setAlphaState( DEFAULT_ALPHA )
|
||||||
.writeMask( DEPTH_WRITE )
|
.setWriteMaskState( DEPTH_WRITE )
|
||||||
.lightmap( LIGHTMAP_DISABLED )
|
.setLightmapState( NO_LIGHTMAP )
|
||||||
.build( false )
|
.createCompositeState( false )
|
||||||
);
|
);
|
||||||
|
|
||||||
private Type( String name, Runnable setup, Runnable destroy )
|
private Type( String name, Runnable setup, Runnable destroy )
|
||||||
|
@ -74,18 +74,18 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Containe
|
|||||||
@Override
|
@Override
|
||||||
protected void init()
|
protected void init()
|
||||||
{
|
{
|
||||||
minecraft.keyboardListener.enableRepeatEvents( true );
|
minecraft.keyboardHandler.setSendRepeatsToGui( true );
|
||||||
|
|
||||||
int termPxWidth = termWidth * FixedWidthFontRenderer.FONT_WIDTH;
|
int termPxWidth = termWidth * FixedWidthFontRenderer.FONT_WIDTH;
|
||||||
int termPxHeight = termHeight * FixedWidthFontRenderer.FONT_HEIGHT;
|
int termPxHeight = termHeight * FixedWidthFontRenderer.FONT_HEIGHT;
|
||||||
|
|
||||||
xSize = termPxWidth + MARGIN * 2 + BORDER * 2;
|
imageWidth = termPxWidth + MARGIN * 2 + BORDER * 2;
|
||||||
ySize = termPxHeight + MARGIN * 2 + BORDER * 2;
|
imageHeight = termPxHeight + MARGIN * 2 + BORDER * 2;
|
||||||
|
|
||||||
super.init();
|
super.init();
|
||||||
|
|
||||||
terminal = new WidgetTerminal( minecraft, () -> computer, termWidth, termHeight, MARGIN, MARGIN, MARGIN, MARGIN );
|
terminal = new WidgetTerminal( minecraft, () -> computer, termWidth, termHeight, MARGIN, MARGIN, MARGIN, MARGIN );
|
||||||
terminalWrapper = new WidgetWrapper( terminal, MARGIN + BORDER + guiLeft, MARGIN + BORDER + guiTop, termPxWidth, termPxHeight );
|
terminalWrapper = new WidgetWrapper( terminal, MARGIN + BORDER + leftPos, MARGIN + BORDER + topPos, termPxWidth, termPxHeight );
|
||||||
|
|
||||||
children.add( terminalWrapper );
|
children.add( terminalWrapper );
|
||||||
setFocused( terminalWrapper );
|
setFocused( terminalWrapper );
|
||||||
@ -97,7 +97,7 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Containe
|
|||||||
super.removed();
|
super.removed();
|
||||||
children.remove( terminal );
|
children.remove( terminal );
|
||||||
terminal = null;
|
terminal = null;
|
||||||
minecraft.keyboardListener.enableRepeatEvents( false );
|
minecraft.keyboardHandler.setSendRepeatsToGui( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -120,14 +120,14 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Containe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY )
|
public void renderBg( float partialTicks, int mouseX, int mouseY )
|
||||||
{
|
{
|
||||||
// Draw terminal
|
// Draw terminal
|
||||||
terminal.draw( terminalWrapper.getX(), terminalWrapper.getY() );
|
terminal.draw( terminalWrapper.getX(), terminalWrapper.getY() );
|
||||||
|
|
||||||
// Draw a border around the terminal
|
// Draw a border around the terminal
|
||||||
RenderSystem.color4f( 1, 1, 1, 1 );
|
RenderSystem.color4f( 1, 1, 1, 1 );
|
||||||
minecraft.getTextureManager().bindTexture( ComputerBorderRenderer.getTexture( family ) );
|
minecraft.getTextureManager().bind( ComputerBorderRenderer.getTexture( family ) );
|
||||||
ComputerBorderRenderer.render(
|
ComputerBorderRenderer.render(
|
||||||
terminalWrapper.getX() - MARGIN, terminalWrapper.getY() - MARGIN, getBlitOffset(),
|
terminalWrapper.getX() - MARGIN, terminalWrapper.getY() - MARGIN, getBlitOffset(),
|
||||||
terminalWrapper.getWidth() + MARGIN * 2, terminalWrapper.getHeight() + MARGIN * 2
|
terminalWrapper.getWidth() + MARGIN * 2, terminalWrapper.getHeight() + MARGIN * 2
|
||||||
@ -139,7 +139,7 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Containe
|
|||||||
{
|
{
|
||||||
renderBackground();
|
renderBackground();
|
||||||
super.render( mouseX, mouseY, partialTicks );
|
super.render( mouseX, mouseY, partialTicks );
|
||||||
renderHoveredToolTip( mouseX, mouseY );
|
renderTooltip( mouseX, mouseY );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,19 +22,19 @@ public class GuiDiskDrive extends ContainerScreen<ContainerDiskDrive>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerForegroundLayer( int mouseX, int mouseY )
|
protected void renderLabels( int mouseX, int mouseY )
|
||||||
{
|
{
|
||||||
String title = this.title.getFormattedText();
|
String title = this.title.getColoredString();
|
||||||
font.drawString( title, (xSize - font.getStringWidth( title )) / 2.0f, 6, 0x404040 );
|
font.draw( title, (imageWidth - font.width( title )) / 2.0f, 6, 0x404040 );
|
||||||
font.drawString( title, 8, ySize - 96 + 2, 0x404040 );
|
font.draw( title, 8, imageHeight - 96 + 2, 0x404040 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY )
|
protected void renderBg( float partialTicks, int mouseX, int mouseY )
|
||||||
{
|
{
|
||||||
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||||
minecraft.getTextureManager().bindTexture( BACKGROUND );
|
minecraft.getTextureManager().bind( BACKGROUND );
|
||||||
blit( guiLeft, guiTop, 0, 0, xSize, ySize );
|
blit( leftPos, topPos, 0, 0, imageWidth, imageHeight );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -42,6 +42,6 @@ public class GuiDiskDrive extends ContainerScreen<ContainerDiskDrive>
|
|||||||
{
|
{
|
||||||
renderBackground();
|
renderBackground();
|
||||||
super.render( mouseX, mouseY, partialTicks );
|
super.render( mouseX, mouseY, partialTicks );
|
||||||
renderHoveredToolTip( mouseX, mouseY );
|
renderTooltip( mouseX, mouseY );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,21 +23,21 @@ public class GuiPrinter extends ContainerScreen<ContainerPrinter>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerForegroundLayer( int mouseX, int mouseY )
|
protected void renderLabels( int mouseX, int mouseY )
|
||||||
{
|
{
|
||||||
String title = getTitle().getFormattedText();
|
String title = getTitle().getColoredString();
|
||||||
font.drawString( title, (xSize - font.getStringWidth( title )) / 2.0f, 6, 0x404040 );
|
font.draw( title, (imageWidth - font.width( title )) / 2.0f, 6, 0x404040 );
|
||||||
font.drawString( I18n.format( "container.inventory" ), 8, ySize - 96 + 2, 0x404040 );
|
font.draw( I18n.get( "container.inventory" ), 8, imageHeight - 96 + 2, 0x404040 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY )
|
protected void renderBg( float partialTicks, int mouseX, int mouseY )
|
||||||
{
|
{
|
||||||
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||||
minecraft.getTextureManager().bindTexture( BACKGROUND );
|
minecraft.getTextureManager().bind( BACKGROUND );
|
||||||
blit( guiLeft, guiTop, 0, 0, xSize, ySize );
|
blit( leftPos, topPos, 0, 0, imageWidth, imageHeight );
|
||||||
|
|
||||||
if( getContainer().isPrinting() ) blit( guiLeft + 34, guiTop + 21, 176, 0, 25, 45 );
|
if( getMenu().isPrinting() ) blit( leftPos + 34, topPos + 21, 176, 0, 25, 45 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -45,6 +45,6 @@ public class GuiPrinter extends ContainerScreen<ContainerPrinter>
|
|||||||
{
|
{
|
||||||
renderBackground();
|
renderBackground();
|
||||||
super.render( mouseX, mouseY, partialTicks );
|
super.render( mouseX, mouseY, partialTicks );
|
||||||
renderHoveredToolTip( mouseX, mouseY );
|
renderTooltip( mouseX, mouseY );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class GuiPrintout extends ContainerScreen<ContainerHeldItem>
|
|||||||
{
|
{
|
||||||
super( container, player, title );
|
super( container, player, title );
|
||||||
|
|
||||||
ySize = Y_SIZE;
|
imageHeight = Y_SIZE;
|
||||||
|
|
||||||
String[] text = ItemPrintout.getText( container.getStack() );
|
String[] text = ItemPrintout.getText( container.getStack() );
|
||||||
m_text = new TextBuffer[text.length];
|
m_text = new TextBuffer[text.length];
|
||||||
@ -91,16 +91,16 @@ public class GuiPrintout extends ContainerScreen<ContainerHeldItem>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY )
|
public void renderBg( float partialTicks, int mouseX, int mouseY )
|
||||||
{
|
{
|
||||||
// Draw the printout
|
// Draw the printout
|
||||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||||
RenderSystem.enableDepthTest();
|
RenderSystem.enableDepthTest();
|
||||||
|
|
||||||
IRenderTypeBuffer.Impl renderer = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource();
|
IRenderTypeBuffer.Impl renderer = Minecraft.getInstance().renderBuffers().bufferSource();
|
||||||
drawBorder( IDENTITY, renderer, guiLeft, guiTop, getBlitOffset(), m_page, m_pages, m_book );
|
drawBorder( IDENTITY, renderer, leftPos, topPos, getBlitOffset(), m_page, m_pages, m_book );
|
||||||
drawText( IDENTITY, renderer, guiLeft + X_TEXT_MARGIN, guiTop + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * m_page, m_text, m_colours );
|
drawText( IDENTITY, renderer, leftPos + X_TEXT_MARGIN, topPos + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * m_page, m_text, m_colours );
|
||||||
renderer.finish();
|
renderer.endBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -112,6 +112,6 @@ public class GuiPrintout extends ContainerScreen<ContainerHeldItem>
|
|||||||
setBlitOffset( getBlitOffset() + 1 );
|
setBlitOffset( getBlitOffset() + 1 );
|
||||||
|
|
||||||
super.render( mouseX, mouseY, partialTicks );
|
super.render( mouseX, mouseY, partialTicks );
|
||||||
renderHoveredToolTip( mouseX, mouseY );
|
renderTooltip( mouseX, mouseY );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,15 +39,15 @@ public class GuiTurtle extends ContainerScreen<ContainerTurtle>
|
|||||||
m_family = container.getFamily();
|
m_family = container.getFamily();
|
||||||
m_computer = (ClientComputer) container.getComputer();
|
m_computer = (ClientComputer) container.getComputer();
|
||||||
|
|
||||||
xSize = 254;
|
imageWidth = 254;
|
||||||
ySize = 217;
|
imageHeight = 217;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init()
|
protected void init()
|
||||||
{
|
{
|
||||||
super.init();
|
super.init();
|
||||||
minecraft.keyboardListener.enableRepeatEvents( true );
|
minecraft.keyboardHandler.setSendRepeatsToGui( true );
|
||||||
|
|
||||||
int termPxWidth = ComputerCraft.turtleTermWidth * FixedWidthFontRenderer.FONT_WIDTH;
|
int termPxWidth = ComputerCraft.turtleTermWidth * FixedWidthFontRenderer.FONT_WIDTH;
|
||||||
int termPxHeight = ComputerCraft.turtleTermHeight * FixedWidthFontRenderer.FONT_HEIGHT;
|
int termPxHeight = ComputerCraft.turtleTermHeight * FixedWidthFontRenderer.FONT_HEIGHT;
|
||||||
@ -58,7 +58,7 @@ public class GuiTurtle extends ContainerScreen<ContainerTurtle>
|
|||||||
ComputerCraft.turtleTermHeight,
|
ComputerCraft.turtleTermHeight,
|
||||||
2, 2, 2, 2
|
2, 2, 2, 2
|
||||||
);
|
);
|
||||||
terminalWrapper = new WidgetWrapper( terminal, 2 + 8 + guiLeft, 2 + 8 + guiTop, termPxWidth, termPxHeight );
|
terminalWrapper = new WidgetWrapper( terminal, 2 + 8 + leftPos, 2 + 8 + topPos, termPxWidth, termPxHeight );
|
||||||
|
|
||||||
children.add( terminalWrapper );
|
children.add( terminalWrapper );
|
||||||
setFocused( terminalWrapper );
|
setFocused( terminalWrapper );
|
||||||
@ -70,7 +70,7 @@ public class GuiTurtle extends ContainerScreen<ContainerTurtle>
|
|||||||
super.removed();
|
super.removed();
|
||||||
children.remove( terminal );
|
children.remove( terminal );
|
||||||
terminal = null;
|
terminal = null;
|
||||||
minecraft.keyboardListener.enableRepeatEvents( false );
|
minecraft.keyboardHandler.setSendRepeatsToGui( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -101,13 +101,13 @@ public class GuiTurtle extends ContainerScreen<ContainerTurtle>
|
|||||||
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||||
int slotX = slot % 4;
|
int slotX = slot % 4;
|
||||||
int slotY = slot / 4;
|
int slotY = slot / 4;
|
||||||
minecraft.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL );
|
minecraft.getTextureManager().bind( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL );
|
||||||
blit( guiLeft + ContainerTurtle.TURTLE_START_X - 2 + slotX * 18, guiTop + ContainerTurtle.PLAYER_START_Y - 2 + slotY * 18, 0, 217, 24, 24 );
|
blit( leftPos + ContainerTurtle.TURTLE_START_X - 2 + slotX * 18, topPos + ContainerTurtle.PLAYER_START_Y - 2 + slotY * 18, 0, 217, 24, 24 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY )
|
protected void renderBg( float partialTicks, int mouseX, int mouseY )
|
||||||
{
|
{
|
||||||
// Draw term
|
// Draw term
|
||||||
boolean advanced = m_family == ComputerFamily.ADVANCED;
|
boolean advanced = m_family == ComputerFamily.ADVANCED;
|
||||||
@ -115,8 +115,8 @@ public class GuiTurtle extends ContainerScreen<ContainerTurtle>
|
|||||||
|
|
||||||
// Draw border/inventory
|
// Draw border/inventory
|
||||||
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||||
minecraft.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL );
|
minecraft.getTextureManager().bind( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL );
|
||||||
blit( guiLeft, guiTop, 0, 0, xSize, ySize );
|
blit( leftPos, topPos, 0, 0, imageWidth, imageHeight );
|
||||||
|
|
||||||
drawSelectionSlot( advanced );
|
drawSelectionSlot( advanced );
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ public class GuiTurtle extends ContainerScreen<ContainerTurtle>
|
|||||||
{
|
{
|
||||||
renderBackground();
|
renderBackground();
|
||||||
super.render( mouseX, mouseY, partialTicks );
|
super.render( mouseX, mouseY, partialTicks );
|
||||||
renderHoveredToolTip( mouseX, mouseY );
|
renderTooltip( mouseX, mouseY );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -91,7 +91,7 @@ public class WidgetTerminal implements IGuiEventListener
|
|||||||
|
|
||||||
case GLFW.GLFW_KEY_V:
|
case GLFW.GLFW_KEY_V:
|
||||||
// Ctrl+V for paste
|
// Ctrl+V for paste
|
||||||
String clipboard = client.keyboardListener.getClipboardString();
|
String clipboard = client.keyboardHandler.getClipboard();
|
||||||
if( clipboard != null )
|
if( clipboard != null )
|
||||||
{
|
{
|
||||||
// Clip to the first occurrence of \r or \n
|
// Clip to the first occurrence of \r or \n
|
||||||
@ -111,7 +111,7 @@ public class WidgetTerminal implements IGuiEventListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Filter the string
|
// Filter the string
|
||||||
clipboard = SharedConstants.filterAllowedCharacters( clipboard );
|
clipboard = SharedConstants.filterText( clipboard );
|
||||||
if( !clipboard.isEmpty() )
|
if( !clipboard.isEmpty() )
|
||||||
{
|
{
|
||||||
// Clip to 512 characters and queue the event
|
// Clip to 512 characters and queue the event
|
||||||
|
@ -35,12 +35,12 @@ public final class ComputerCraftProxyClient
|
|||||||
registerContainers();
|
registerContainers();
|
||||||
|
|
||||||
// While turtles themselves are not transparent, their upgrades may be.
|
// While turtles themselves are not transparent, their upgrades may be.
|
||||||
RenderTypeLookup.setRenderLayer( Registry.ModBlocks.TURTLE_NORMAL.get(), RenderType.getTranslucent() );
|
RenderTypeLookup.setRenderLayer( Registry.ModBlocks.TURTLE_NORMAL.get(), RenderType.translucent() );
|
||||||
RenderTypeLookup.setRenderLayer( Registry.ModBlocks.TURTLE_ADVANCED.get(), RenderType.getTranslucent() );
|
RenderTypeLookup.setRenderLayer( Registry.ModBlocks.TURTLE_ADVANCED.get(), RenderType.translucent() );
|
||||||
|
|
||||||
// Monitors' textures have transparent fronts and so count as cutouts.
|
// Monitors' textures have transparent fronts and so count as cutouts.
|
||||||
RenderTypeLookup.setRenderLayer( Registry.ModBlocks.MONITOR_NORMAL.get(), RenderType.getCutout() );
|
RenderTypeLookup.setRenderLayer( Registry.ModBlocks.MONITOR_NORMAL.get(), RenderType.cutout() );
|
||||||
RenderTypeLookup.setRenderLayer( Registry.ModBlocks.MONITOR_ADVANCED.get(), RenderType.getCutout() );
|
RenderTypeLookup.setRenderLayer( Registry.ModBlocks.MONITOR_ADVANCED.get(), RenderType.cutout() );
|
||||||
|
|
||||||
// Setup TESRs
|
// Setup TESRs
|
||||||
ClientRegistry.bindTileEntityRenderer( Registry.ModTiles.MONITOR_NORMAL.get(), TileEntityMonitorRenderer::new );
|
ClientRegistry.bindTileEntityRenderer( Registry.ModTiles.MONITOR_NORMAL.get(), TileEntityMonitorRenderer::new );
|
||||||
@ -55,15 +55,15 @@ public final class ComputerCraftProxyClient
|
|||||||
{
|
{
|
||||||
// My IDE doesn't think so, but we do actually need these generics.
|
// My IDE doesn't think so, but we do actually need these generics.
|
||||||
|
|
||||||
ScreenManager.<ContainerComputer, GuiComputer<ContainerComputer>>registerFactory( Registry.ModContainers.COMPUTER.get(), GuiComputer::create );
|
ScreenManager.<ContainerComputer, GuiComputer<ContainerComputer>>register( Registry.ModContainers.COMPUTER.get(), GuiComputer::create );
|
||||||
ScreenManager.<ContainerPocketComputer, GuiComputer<ContainerPocketComputer>>registerFactory( Registry.ModContainers.POCKET_COMPUTER.get(), GuiComputer::createPocket );
|
ScreenManager.<ContainerPocketComputer, GuiComputer<ContainerPocketComputer>>register( Registry.ModContainers.POCKET_COMPUTER.get(), GuiComputer::createPocket );
|
||||||
ScreenManager.registerFactory( Registry.ModContainers.TURTLE.get(), GuiTurtle::new );
|
ScreenManager.register( Registry.ModContainers.TURTLE.get(), GuiTurtle::new );
|
||||||
|
|
||||||
ScreenManager.registerFactory( Registry.ModContainers.PRINTER.get(), GuiPrinter::new );
|
ScreenManager.register( Registry.ModContainers.PRINTER.get(), GuiPrinter::new );
|
||||||
ScreenManager.registerFactory( Registry.ModContainers.DISK_DRIVE.get(), GuiDiskDrive::new );
|
ScreenManager.register( Registry.ModContainers.DISK_DRIVE.get(), GuiDiskDrive::new );
|
||||||
ScreenManager.registerFactory( Registry.ModContainers.PRINTOUT.get(), GuiPrintout::new );
|
ScreenManager.register( Registry.ModContainers.PRINTOUT.get(), GuiPrintout::new );
|
||||||
|
|
||||||
ScreenManager.<ContainerViewComputer, GuiComputer<ContainerViewComputer>>registerFactory( Registry.ModContainers.VIEW_COMPUTER.get(), GuiComputer::createView );
|
ScreenManager.<ContainerViewComputer, GuiComputer<ContainerViewComputer>>register( Registry.ModContainers.VIEW_COMPUTER.get(), GuiComputer::createView );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT )
|
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT )
|
||||||
@ -72,7 +72,7 @@ public final class ComputerCraftProxyClient
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onWorldUnload( WorldEvent.Unload event )
|
public static void onWorldUnload( WorldEvent.Unload event )
|
||||||
{
|
{
|
||||||
if( event.getWorld().isRemote() )
|
if( event.getWorld().isClientSide() )
|
||||||
{
|
{
|
||||||
ClientMonitor.destroyAll();
|
ClientMonitor.destroyAll();
|
||||||
}
|
}
|
||||||
|
@ -45,35 +45,35 @@ public final class CableHighlightRenderer
|
|||||||
public static void drawHighlight( DrawHighlightEvent.HighlightBlock event )
|
public static void drawHighlight( DrawHighlightEvent.HighlightBlock event )
|
||||||
{
|
{
|
||||||
BlockRayTraceResult hit = event.getTarget();
|
BlockRayTraceResult hit = event.getTarget();
|
||||||
BlockPos pos = hit.getPos();
|
BlockPos pos = hit.getBlockPos();
|
||||||
World world = event.getInfo().getRenderViewEntity().getEntityWorld();
|
World world = event.getInfo().getEntity().getCommandSenderWorld();
|
||||||
ActiveRenderInfo info = event.getInfo();
|
ActiveRenderInfo info = event.getInfo();
|
||||||
|
|
||||||
BlockState state = world.getBlockState( pos );
|
BlockState state = world.getBlockState( pos );
|
||||||
|
|
||||||
// We only care about instances with both cable and modem.
|
// We only care about instances with both cable and modem.
|
||||||
if( state.getBlock() != Registry.ModBlocks.CABLE.get() || state.get( BlockCable.MODEM ).getFacing() == null || !state.get( BlockCable.CABLE ) )
|
if( state.getBlock() != Registry.ModBlocks.CABLE.get() || state.getValue( BlockCable.MODEM ).getFacing() == null || !state.getValue( BlockCable.CABLE ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setCanceled( true );
|
event.setCanceled( true );
|
||||||
|
|
||||||
VoxelShape shape = WorldUtil.isVecInside( CableShapes.getModemShape( state ), hit.getHitVec().subtract( pos.getX(), pos.getY(), pos.getZ() ) )
|
VoxelShape shape = WorldUtil.isVecInside( CableShapes.getModemShape( state ), hit.getLocation().subtract( pos.getX(), pos.getY(), pos.getZ() ) )
|
||||||
? CableShapes.getModemShape( state )
|
? CableShapes.getModemShape( state )
|
||||||
: CableShapes.getCableShape( state );
|
: CableShapes.getCableShape( state );
|
||||||
|
|
||||||
Vec3d cameraPos = info.getProjectedView();
|
Vec3d cameraPos = info.getPosition();
|
||||||
double xOffset = pos.getX() - cameraPos.getX();
|
double xOffset = pos.getX() - cameraPos.x();
|
||||||
double yOffset = pos.getY() - cameraPos.getY();
|
double yOffset = pos.getY() - cameraPos.y();
|
||||||
double zOffset = pos.getZ() - cameraPos.getZ();
|
double zOffset = pos.getZ() - cameraPos.z();
|
||||||
|
|
||||||
IVertexBuilder buffer = event.getBuffers().getBuffer( RenderType.getLines() );
|
IVertexBuilder buffer = event.getBuffers().getBuffer( RenderType.lines() );
|
||||||
Matrix4f matrix4f = event.getMatrix().getLast().getMatrix();
|
Matrix4f matrix4f = event.getMatrix().last().pose();
|
||||||
shape.forEachEdge( ( x1, y1, z1, x2, y2, z2 ) -> {
|
shape.forAllEdges( ( x1, y1, z1, x2, y2, z2 ) -> {
|
||||||
buffer.pos( matrix4f, (float) (x1 + xOffset), (float) (y1 + yOffset), (float) (z1 + zOffset) )
|
buffer.vertex( matrix4f, (float) (x1 + xOffset), (float) (y1 + yOffset), (float) (z1 + zOffset) )
|
||||||
.color( 0, 0, 0, 0.4f ).endVertex();
|
.color( 0, 0, 0, 0.4f ).endVertex();
|
||||||
buffer.pos( matrix4f, (float) (x2 + xOffset), (float) (y2 + yOffset), (float) (z2 + zOffset) )
|
buffer.vertex( matrix4f, (float) (x2 + xOffset), (float) (y2 + yOffset), (float) (z2 + zOffset) )
|
||||||
.color( 0, 0, 0, 0.4f ).endVertex();
|
.color( 0, 0, 0, 0.4f ).endVertex();
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
@ -85,13 +85,13 @@ public class ComputerBorderRenderer
|
|||||||
public static void render( int x, int y, int z, int width, int height )
|
public static void render( int x, int y, int z, int width, int height )
|
||||||
{
|
{
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
BufferBuilder buffer = tessellator.getBuffer();
|
BufferBuilder buffer = tessellator.getBuilder();
|
||||||
buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX );
|
buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX );
|
||||||
|
|
||||||
render( IDENTITY, buffer, x, y, z, width, height );
|
render( IDENTITY, buffer, x, y, z, width, height );
|
||||||
|
|
||||||
RenderSystem.enableAlphaTest();
|
RenderSystem.enableAlphaTest();
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void render( Matrix4f transform, IVertexBuilder buffer, int x, int y, int z, int width, int height )
|
public static void render( Matrix4f transform, IVertexBuilder buffer, int x, int y, int z, int width, int height )
|
||||||
@ -166,9 +166,9 @@ public class ComputerBorderRenderer
|
|||||||
|
|
||||||
private void renderTexture( int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight )
|
private void renderTexture( int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight )
|
||||||
{
|
{
|
||||||
builder.pos( transform, x, y + height, z ).color( r, g, b, 1.0f ).tex( u * TEX_SCALE, (v + textureHeight) * TEX_SCALE ).endVertex();
|
builder.vertex( transform, x, y + height, z ).color( r, g, b, 1.0f ).uv( u * TEX_SCALE, (v + textureHeight) * TEX_SCALE ).endVertex();
|
||||||
builder.pos( transform, x + width, y + height, z ).color( r, g, b, 1.0f ).tex( (u + textureWidth) * TEX_SCALE, (v + textureHeight) * TEX_SCALE ).endVertex();
|
builder.vertex( transform, x + width, y + height, z ).color( r, g, b, 1.0f ).uv( (u + textureWidth) * TEX_SCALE, (v + textureHeight) * TEX_SCALE ).endVertex();
|
||||||
builder.pos( transform, x + width, y, z ).color( r, g, b, 1.0f ).tex( (u + textureWidth) * TEX_SCALE, v * TEX_SCALE ).endVertex();
|
builder.vertex( transform, x + width, y, z ).color( r, g, b, 1.0f ).uv( (u + textureWidth) * TEX_SCALE, v * TEX_SCALE ).endVertex();
|
||||||
builder.pos( transform, x, y, z ).color( r, g, b, 1.0f ).tex( u * TEX_SCALE, v * TEX_SCALE ).endVertex();
|
builder.vertex( transform, x, y, z ).color( r, g, b, 1.0f ).uv( u * TEX_SCALE, v * TEX_SCALE ).endVertex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,8 @@ public abstract class ItemMapLikeRenderer
|
|||||||
{
|
{
|
||||||
PlayerEntity player = Minecraft.getInstance().player;
|
PlayerEntity player = Minecraft.getInstance().player;
|
||||||
|
|
||||||
transform.push();
|
transform.pushPose();
|
||||||
if( hand == Hand.MAIN_HAND && player.getHeldItemOffhand().isEmpty() )
|
if( hand == Hand.MAIN_HAND && player.getOffhandItem().isEmpty() )
|
||||||
{
|
{
|
||||||
renderItemFirstPersonCenter( transform, render, lightTexture, pitch, equipProgress, swingProgress, stack );
|
renderItemFirstPersonCenter( transform, render, lightTexture, pitch, equipProgress, swingProgress, stack );
|
||||||
}
|
}
|
||||||
@ -42,11 +42,11 @@ public abstract class ItemMapLikeRenderer
|
|||||||
{
|
{
|
||||||
renderItemFirstPersonSide(
|
renderItemFirstPersonSide(
|
||||||
transform, render, lightTexture,
|
transform, render, lightTexture,
|
||||||
hand == Hand.MAIN_HAND ? player.getPrimaryHand() : player.getPrimaryHand().opposite(),
|
hand == Hand.MAIN_HAND ? player.getMainArm() : player.getMainArm().getOpposite(),
|
||||||
equipProgress, swingProgress, stack
|
equipProgress, swingProgress, stack
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
transform.pop();
|
transform.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,15 +70,15 @@ public abstract class ItemMapLikeRenderer
|
|||||||
// If the player is not invisible then render a single arm
|
// If the player is not invisible then render a single arm
|
||||||
if( !minecraft.player.isInvisible() )
|
if( !minecraft.player.isInvisible() )
|
||||||
{
|
{
|
||||||
transform.push();
|
transform.pushPose();
|
||||||
transform.rotate( Vector3f.ZP.rotationDegrees( offset * 10f ) );
|
transform.mulPose( Vector3f.ZP.rotationDegrees( offset * 10f ) );
|
||||||
minecraft.getFirstPersonRenderer().renderArmFirstPerson( transform, render, combinedLight, equipProgress, swingProgress, side );
|
minecraft.getItemInHandRenderer().renderPlayerArm( transform, render, combinedLight, equipProgress, swingProgress, side );
|
||||||
transform.pop();
|
transform.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup the appropriate transformations. This is just copied from the
|
// Setup the appropriate transformations. This is just copied from the
|
||||||
// corresponding method in ItemRenderer.
|
// corresponding method in ItemRenderer.
|
||||||
transform.push();
|
transform.pushPose();
|
||||||
transform.translate( offset * 0.51f, -0.08f + equipProgress * -1.2f, -0.75f );
|
transform.translate( offset * 0.51f, -0.08f + equipProgress * -1.2f, -0.75f );
|
||||||
float f1 = MathHelper.sqrt( swingProgress );
|
float f1 = MathHelper.sqrt( swingProgress );
|
||||||
float f2 = MathHelper.sin( f1 * (float) Math.PI );
|
float f2 = MathHelper.sin( f1 * (float) Math.PI );
|
||||||
@ -86,12 +86,12 @@ public abstract class ItemMapLikeRenderer
|
|||||||
float f4 = 0.4f * MathHelper.sin( f1 * ((float) Math.PI * 2f) );
|
float f4 = 0.4f * MathHelper.sin( f1 * ((float) Math.PI * 2f) );
|
||||||
float f5 = -0.3f * MathHelper.sin( swingProgress * (float) Math.PI );
|
float f5 = -0.3f * MathHelper.sin( swingProgress * (float) Math.PI );
|
||||||
transform.translate( offset * f3, f4 - 0.3f * f2, f5 );
|
transform.translate( offset * f3, f4 - 0.3f * f2, f5 );
|
||||||
transform.rotate( Vector3f.XP.rotationDegrees( f2 * -45f ) );
|
transform.mulPose( Vector3f.XP.rotationDegrees( f2 * -45f ) );
|
||||||
transform.rotate( Vector3f.YP.rotationDegrees( offset * f2 * -30f ) );
|
transform.mulPose( Vector3f.YP.rotationDegrees( offset * f2 * -30f ) );
|
||||||
|
|
||||||
renderItem( transform, render, stack );
|
renderItem( transform, render, stack );
|
||||||
|
|
||||||
transform.pop();
|
transform.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,7 +109,7 @@ public abstract class ItemMapLikeRenderer
|
|||||||
private void renderItemFirstPersonCenter( MatrixStack transform, IRenderTypeBuffer render, int combinedLight, float pitch, float equipProgress, float swingProgress, ItemStack stack )
|
private void renderItemFirstPersonCenter( MatrixStack transform, IRenderTypeBuffer render, int combinedLight, float pitch, float equipProgress, float swingProgress, ItemStack stack )
|
||||||
{
|
{
|
||||||
Minecraft minecraft = Minecraft.getInstance();
|
Minecraft minecraft = Minecraft.getInstance();
|
||||||
FirstPersonRenderer renderer = minecraft.getFirstPersonRenderer();
|
FirstPersonRenderer renderer = minecraft.getItemInHandRenderer();
|
||||||
|
|
||||||
// Setup the appropriate transformations. This is just copied from the
|
// Setup the appropriate transformations. This is just copied from the
|
||||||
// corresponding method in ItemRenderer.
|
// corresponding method in ItemRenderer.
|
||||||
@ -118,20 +118,20 @@ public abstract class ItemMapLikeRenderer
|
|||||||
float tZ = -0.4f * MathHelper.sin( swingRt * (float) Math.PI );
|
float tZ = -0.4f * MathHelper.sin( swingRt * (float) Math.PI );
|
||||||
transform.translate( 0, -tX / 2, tZ );
|
transform.translate( 0, -tX / 2, tZ );
|
||||||
|
|
||||||
float pitchAngle = renderer.getMapAngleFromPitch( pitch );
|
float pitchAngle = renderer.calculateMapTilt( pitch );
|
||||||
transform.translate( 0, 0.04F + equipProgress * -1.2f + pitchAngle * -0.5f, -0.72f );
|
transform.translate( 0, 0.04F + equipProgress * -1.2f + pitchAngle * -0.5f, -0.72f );
|
||||||
transform.rotate( Vector3f.XP.rotationDegrees( pitchAngle * -85.0f ) );
|
transform.mulPose( Vector3f.XP.rotationDegrees( pitchAngle * -85.0f ) );
|
||||||
if( !minecraft.player.isInvisible() )
|
if( !minecraft.player.isInvisible() )
|
||||||
{
|
{
|
||||||
transform.push();
|
transform.pushPose();
|
||||||
transform.rotate( Vector3f.YP.rotationDegrees( 90.0F ) );
|
transform.mulPose( Vector3f.YP.rotationDegrees( 90.0F ) );
|
||||||
renderer.renderArm( transform, render, combinedLight, HandSide.RIGHT );
|
renderer.renderMapHand( transform, render, combinedLight, HandSide.RIGHT );
|
||||||
renderer.renderArm( transform, render, combinedLight, HandSide.LEFT );
|
renderer.renderMapHand( transform, render, combinedLight, HandSide.LEFT );
|
||||||
transform.pop();
|
transform.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
float rX = MathHelper.sin( swingRt * (float) Math.PI );
|
float rX = MathHelper.sin( swingRt * (float) Math.PI );
|
||||||
transform.rotate( Vector3f.XP.rotationDegrees( rX * 20.0F ) );
|
transform.mulPose( Vector3f.XP.rotationDegrees( rX * 20.0F ) );
|
||||||
transform.scale( 2.0F, 2.0F, 2.0F );
|
transform.scale( 2.0F, 2.0F, 2.0F );
|
||||||
|
|
||||||
renderItem( transform, render, stack );
|
renderItem( transform, render, stack );
|
||||||
|
@ -79,9 +79,9 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
|
|||||||
|
|
||||||
// Setup various transformations. Note that these are partially adapted from the corresponding method
|
// Setup various transformations. Note that these are partially adapted from the corresponding method
|
||||||
// in ItemRenderer
|
// in ItemRenderer
|
||||||
transform.push();
|
transform.pushPose();
|
||||||
transform.rotate( Vector3f.YP.rotationDegrees( 180f ) );
|
transform.mulPose( Vector3f.YP.rotationDegrees( 180f ) );
|
||||||
transform.rotate( Vector3f.ZP.rotationDegrees( 180f ) );
|
transform.mulPose( Vector3f.ZP.rotationDegrees( 180f ) );
|
||||||
transform.scale( 0.5f, 0.5f, 0.5f );
|
transform.scale( 0.5f, 0.5f, 0.5f );
|
||||||
|
|
||||||
float scale = 0.75f / Math.max( width + BORDER * 2, height + BORDER * 2 + LIGHT_HEIGHT );
|
float scale = 0.75f / Math.max( width + BORDER * 2, height + BORDER * 2 + LIGHT_HEIGHT );
|
||||||
@ -93,7 +93,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
|
|||||||
ComputerFamily family = item.getFamily();
|
ComputerFamily family = item.getFamily();
|
||||||
int frameColour = item.getColour( stack );
|
int frameColour = item.getColour( stack );
|
||||||
|
|
||||||
Matrix4f matrix = transform.getLast().getMatrix();
|
Matrix4f matrix = transform.last().pose();
|
||||||
renderFrame( matrix, family, frameColour, width, height );
|
renderFrame( matrix, family, frameColour, width, height );
|
||||||
|
|
||||||
// Render the light
|
// Render the light
|
||||||
@ -110,26 +110,26 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
|
|||||||
FixedWidthFontRenderer.drawEmptyTerminal( matrix, 0, 0, width, height );
|
FixedWidthFontRenderer.drawEmptyTerminal( matrix, 0, 0, width, height );
|
||||||
}
|
}
|
||||||
|
|
||||||
transform.pop();
|
transform.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void renderFrame( Matrix4f transform, ComputerFamily family, int colour, int width, int height )
|
private static void renderFrame( Matrix4f transform, ComputerFamily family, int colour, int width, int height )
|
||||||
{
|
{
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
Minecraft.getInstance().getTextureManager()
|
Minecraft.getInstance().getTextureManager()
|
||||||
.bindTexture( colour != -1 ? ComputerBorderRenderer.BACKGROUND_COLOUR : ComputerBorderRenderer.getTexture( family ) );
|
.bind( colour != -1 ? ComputerBorderRenderer.BACKGROUND_COLOUR : ComputerBorderRenderer.getTexture( family ) );
|
||||||
|
|
||||||
float r = ((colour >>> 16) & 0xFF) / 255.0f;
|
float r = ((colour >>> 16) & 0xFF) / 255.0f;
|
||||||
float g = ((colour >>> 8) & 0xFF) / 255.0f;
|
float g = ((colour >>> 8) & 0xFF) / 255.0f;
|
||||||
float b = (colour & 0xFF) / 255.0f;
|
float b = (colour & 0xFF) / 255.0f;
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
BufferBuilder buffer = tessellator.getBuffer();
|
BufferBuilder buffer = tessellator.getBuilder();
|
||||||
buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX );
|
buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX );
|
||||||
|
|
||||||
ComputerBorderRenderer.render( transform, buffer, 0, 0, 0, width, height, LIGHT_HEIGHT, r, g, b );
|
ComputerBorderRenderer.render( transform, buffer, 0, 0, 0, width, height, LIGHT_HEIGHT, r, g, b );
|
||||||
|
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void renderLight( Matrix4f transform, int colour, int width, int height )
|
private static void renderLight( Matrix4f transform, int colour, int width, int height )
|
||||||
@ -141,14 +141,14 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
|
|||||||
float b = (colour & 0xFF) / 255.0f;
|
float b = (colour & 0xFF) / 255.0f;
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
BufferBuilder buffer = tessellator.getBuffer();
|
BufferBuilder buffer = tessellator.getBuilder();
|
||||||
buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR );
|
buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR );
|
||||||
buffer.pos( transform, width - LIGHT_HEIGHT * 2, height + LIGHT_HEIGHT + BORDER / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
buffer.vertex( transform, width - LIGHT_HEIGHT * 2, height + LIGHT_HEIGHT + BORDER / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
||||||
buffer.pos( transform, width, height + LIGHT_HEIGHT + BORDER / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
buffer.vertex( transform, width, height + LIGHT_HEIGHT + BORDER / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
||||||
buffer.pos( transform, width, height + BORDER / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
buffer.vertex( transform, width, height + BORDER / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
||||||
buffer.pos( transform, width - LIGHT_HEIGHT * 2, height + BORDER / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
buffer.vertex( transform, width - LIGHT_HEIGHT * 2, height + BORDER / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
||||||
|
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
RenderSystem.enableTexture();
|
RenderSystem.enableTexture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer
|
|||||||
@Override
|
@Override
|
||||||
protected void renderItem( MatrixStack transform, IRenderTypeBuffer render, ItemStack stack )
|
protected void renderItem( MatrixStack transform, IRenderTypeBuffer render, ItemStack stack )
|
||||||
{
|
{
|
||||||
transform.rotate( Vector3f.XP.rotationDegrees( 180f ) );
|
transform.mulPose( Vector3f.XP.rotationDegrees( 180f ) );
|
||||||
transform.scale( 0.42f, 0.42f, -0.42f );
|
transform.scale( 0.42f, 0.42f, -0.42f );
|
||||||
transform.translate( -0.5f, -0.48f, 0.0f );
|
transform.translate( -0.5f, -0.48f, 0.0f );
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer
|
|||||||
|
|
||||||
// Move a little bit forward to ensure we're not clipping with the frame
|
// Move a little bit forward to ensure we're not clipping with the frame
|
||||||
transform.translate( 0.0f, 0.0f, -0.001f );
|
transform.translate( 0.0f, 0.0f, -0.001f );
|
||||||
transform.rotate( Vector3f.ZP.rotationDegrees( 180f ) );
|
transform.mulPose( Vector3f.ZP.rotationDegrees( 180f ) );
|
||||||
transform.scale( 0.95f, 0.95f, -0.95f );
|
transform.scale( 0.95f, 0.95f, -0.95f );
|
||||||
transform.translate( -0.5f, -0.5f, 0.0f );
|
transform.translate( -0.5f, -0.5f, 0.0f );
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer
|
|||||||
transform.scale( scale, scale, scale );
|
transform.scale( scale, scale, scale );
|
||||||
transform.translate( (max - width) / 2.0, (max - height) / 2.0, 0.0 );
|
transform.translate( (max - width) / 2.0, (max - height) / 2.0, 0.0 );
|
||||||
|
|
||||||
Matrix4f matrix = transform.getLast().getMatrix();
|
Matrix4f matrix = transform.last().pose();
|
||||||
drawBorder( matrix, render, 0, 0, -0.01f, 0, pages, book );
|
drawBorder( matrix, render, 0, 0, -0.01f, 0, pages, book );
|
||||||
drawText( matrix, render,
|
drawText( matrix, render,
|
||||||
X_TEXT_MARGIN, Y_TEXT_MARGIN, 0, ItemPrintout.getText( stack ), ItemPrintout.getColours( stack )
|
X_TEXT_MARGIN, Y_TEXT_MARGIN, 0, ItemPrintout.getText( stack ), ItemPrintout.getColours( stack )
|
||||||
|
@ -40,12 +40,12 @@ public final class MonitorHighlightRenderer
|
|||||||
public static void drawHighlight( DrawHighlightEvent.HighlightBlock event )
|
public static void drawHighlight( DrawHighlightEvent.HighlightBlock event )
|
||||||
{
|
{
|
||||||
// Preserve normal behaviour when crouching.
|
// Preserve normal behaviour when crouching.
|
||||||
if( event.getInfo().getRenderViewEntity().isCrouching() ) return;
|
if( event.getInfo().getEntity().isCrouching() ) return;
|
||||||
|
|
||||||
World world = event.getInfo().getRenderViewEntity().getEntityWorld();
|
World world = event.getInfo().getEntity().getCommandSenderWorld();
|
||||||
BlockPos pos = event.getTarget().getPos();
|
BlockPos pos = event.getTarget().getBlockPos();
|
||||||
|
|
||||||
TileEntity tile = world.getTileEntity( pos );
|
TileEntity tile = world.getBlockEntity( pos );
|
||||||
if( !(tile instanceof TileMonitor) ) return;
|
if( !(tile instanceof TileMonitor) ) return;
|
||||||
|
|
||||||
TileMonitor monitor = (TileMonitor) tile;
|
TileMonitor monitor = (TileMonitor) tile;
|
||||||
@ -61,13 +61,13 @@ public final class MonitorHighlightRenderer
|
|||||||
if( monitor.getYIndex() != monitor.getHeight() - 1 ) faces.remove( monitor.getDown() );
|
if( monitor.getYIndex() != monitor.getHeight() - 1 ) faces.remove( monitor.getDown() );
|
||||||
|
|
||||||
MatrixStack transformStack = event.getMatrix();
|
MatrixStack transformStack = event.getMatrix();
|
||||||
Vec3d cameraPos = event.getInfo().getProjectedView();
|
Vec3d cameraPos = event.getInfo().getPosition();
|
||||||
transformStack.push();
|
transformStack.pushPose();
|
||||||
transformStack.translate( pos.getX() - cameraPos.getX(), pos.getY() - cameraPos.getY(), pos.getZ() - cameraPos.getZ() );
|
transformStack.translate( pos.getX() - cameraPos.x(), pos.getY() - cameraPos.y(), pos.getZ() - cameraPos.z() );
|
||||||
|
|
||||||
// I wish I could think of a better way to do this
|
// I wish I could think of a better way to do this
|
||||||
IVertexBuilder buffer = event.getBuffers().getBuffer( RenderType.getLines() );
|
IVertexBuilder buffer = event.getBuffers().getBuffer( RenderType.lines() );
|
||||||
Matrix4f transform = transformStack.getLast().getMatrix();
|
Matrix4f transform = transformStack.last().pose();
|
||||||
if( faces.contains( NORTH ) || faces.contains( WEST ) ) line( buffer, transform, 0, 0, 0, UP );
|
if( faces.contains( NORTH ) || faces.contains( WEST ) ) line( buffer, transform, 0, 0, 0, UP );
|
||||||
if( faces.contains( SOUTH ) || faces.contains( WEST ) ) line( buffer, transform, 0, 0, 1, UP );
|
if( faces.contains( SOUTH ) || faces.contains( WEST ) ) line( buffer, transform, 0, 0, 1, UP );
|
||||||
if( faces.contains( NORTH ) || faces.contains( EAST ) ) line( buffer, transform, 1, 0, 0, UP );
|
if( faces.contains( NORTH ) || faces.contains( EAST ) ) line( buffer, transform, 1, 0, 0, UP );
|
||||||
@ -81,16 +81,16 @@ public final class MonitorHighlightRenderer
|
|||||||
if( faces.contains( WEST ) || faces.contains( UP ) ) line( buffer, transform, 0, 1, 0, SOUTH );
|
if( faces.contains( WEST ) || faces.contains( UP ) ) line( buffer, transform, 0, 1, 0, SOUTH );
|
||||||
if( faces.contains( EAST ) || faces.contains( UP ) ) line( buffer, transform, 1, 1, 0, SOUTH );
|
if( faces.contains( EAST ) || faces.contains( UP ) ) line( buffer, transform, 1, 1, 0, SOUTH );
|
||||||
|
|
||||||
transformStack.pop();
|
transformStack.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void line( IVertexBuilder buffer, Matrix4f transform, float x, float y, float z, Direction direction )
|
private static void line( IVertexBuilder buffer, Matrix4f transform, float x, float y, float z, Direction direction )
|
||||||
{
|
{
|
||||||
buffer.pos( transform, x, y, z ).color( 0, 0, 0, 0.4f ).endVertex();
|
buffer.vertex( transform, x, y, z ).color( 0, 0, 0, 0.4f ).endVertex();
|
||||||
buffer.pos( transform,
|
buffer.vertex( transform,
|
||||||
x + direction.getXOffset(),
|
x + direction.getStepX(),
|
||||||
y + direction.getYOffset(),
|
y + direction.getStepY(),
|
||||||
z + direction.getZOffset()
|
z + direction.getStepZ()
|
||||||
).color( 0, 0, 0, 0.4f ).endVertex();
|
).color( 0, 0, 0, 0.4f ).endVertex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class MonitorTextureBufferShader
|
|||||||
static void setupUniform( Matrix4f transform, int width, int height, Palette palette, boolean greyscale )
|
static void setupUniform( Matrix4f transform, int width, int height, Palette palette, boolean greyscale )
|
||||||
{
|
{
|
||||||
MATRIX_BUFFER.rewind();
|
MATRIX_BUFFER.rewind();
|
||||||
transform.write( MATRIX_BUFFER );
|
transform.store( MATRIX_BUFFER );
|
||||||
MATRIX_BUFFER.rewind();
|
MATRIX_BUFFER.rewind();
|
||||||
RenderSystem.glUniformMatrix4( uniformMv, false, MATRIX_BUFFER );
|
RenderSystem.glUniformMatrix4( uniformMv, false, MATRIX_BUFFER );
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class MonitorTextureBufferShader
|
|||||||
{
|
{
|
||||||
if( initialised )
|
if( initialised )
|
||||||
{
|
{
|
||||||
if( ok ) GlStateManager.useProgram( program );
|
if( ok ) GlStateManager._glUseProgram( program );
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,14 +94,14 @@ class MonitorTextureBufferShader
|
|||||||
int vertexShader = loadShader( GL20.GL_VERTEX_SHADER, "assets/computercraft/shaders/monitor.vert" );
|
int vertexShader = loadShader( GL20.GL_VERTEX_SHADER, "assets/computercraft/shaders/monitor.vert" );
|
||||||
int fragmentShader = loadShader( GL20.GL_FRAGMENT_SHADER, "assets/computercraft/shaders/monitor.frag" );
|
int fragmentShader = loadShader( GL20.GL_FRAGMENT_SHADER, "assets/computercraft/shaders/monitor.frag" );
|
||||||
|
|
||||||
program = GlStateManager.createProgram();
|
program = GlStateManager.glCreateProgram();
|
||||||
GlStateManager.attachShader( program, vertexShader );
|
GlStateManager.glAttachShader( program, vertexShader );
|
||||||
GlStateManager.attachShader( program, fragmentShader );
|
GlStateManager.glAttachShader( program, fragmentShader );
|
||||||
GL20.glBindAttribLocation( program, 0, "v_pos" );
|
GL20.glBindAttribLocation( program, 0, "v_pos" );
|
||||||
|
|
||||||
GlStateManager.linkProgram( program );
|
GlStateManager.glLinkProgram( program );
|
||||||
boolean ok = GlStateManager.getProgram( program, GL20.GL_LINK_STATUS ) != 0;
|
boolean ok = GlStateManager.glGetProgrami( program, GL20.GL_LINK_STATUS ) != 0;
|
||||||
String log = GlStateManager.getProgramInfoLog( program, Short.MAX_VALUE ).trim();
|
String log = GlStateManager.glGetProgramInfoLog( program, Short.MAX_VALUE ).trim();
|
||||||
if( !Strings.isNullOrEmpty( log ) )
|
if( !Strings.isNullOrEmpty( log ) )
|
||||||
{
|
{
|
||||||
ComputerCraft.log.warn( "Problems when linking monitor shader: {}", log );
|
ComputerCraft.log.warn( "Problems when linking monitor shader: {}", log );
|
||||||
@ -109,8 +109,8 @@ class MonitorTextureBufferShader
|
|||||||
|
|
||||||
GL20.glDetachShader( program, vertexShader );
|
GL20.glDetachShader( program, vertexShader );
|
||||||
GL20.glDetachShader( program, fragmentShader );
|
GL20.glDetachShader( program, fragmentShader );
|
||||||
GlStateManager.deleteShader( vertexShader );
|
GlStateManager.glDeleteShader( vertexShader );
|
||||||
GlStateManager.deleteShader( fragmentShader );
|
GlStateManager.glDeleteShader( fragmentShader );
|
||||||
|
|
||||||
if( !ok ) return false;
|
if( !ok ) return false;
|
||||||
|
|
||||||
@ -137,13 +137,13 @@ class MonitorTextureBufferShader
|
|||||||
if( stream == null ) throw new IllegalArgumentException( "Cannot find " + path );
|
if( stream == null ) throw new IllegalArgumentException( "Cannot find " + path );
|
||||||
String contents = TextureUtil.readResourceAsString( stream );
|
String contents = TextureUtil.readResourceAsString( stream );
|
||||||
|
|
||||||
int shader = GlStateManager.createShader( kind );
|
int shader = GlStateManager.glCreateShader( kind );
|
||||||
|
|
||||||
GlStateManager.shaderSource( shader, contents );
|
GlStateManager.glShaderSource( shader, contents );
|
||||||
GlStateManager.compileShader( shader );
|
GlStateManager.glCompileShader( shader );
|
||||||
|
|
||||||
boolean ok = GlStateManager.getShader( shader, GL20.GL_COMPILE_STATUS ) != 0;
|
boolean ok = GlStateManager.glGetShaderi( shader, GL20.GL_COMPILE_STATUS ) != 0;
|
||||||
String log = GlStateManager.getShaderInfoLog( shader, Short.MAX_VALUE ).trim();
|
String log = GlStateManager.glGetShaderInfoLog( shader, Short.MAX_VALUE ).trim();
|
||||||
if( !Strings.isNullOrEmpty( log ) )
|
if( !Strings.isNullOrEmpty( log ) )
|
||||||
{
|
{
|
||||||
ComputerCraft.log.warn( "Problems when loading monitor shader {}: {}", path, log );
|
ComputerCraft.log.warn( "Problems when loading monitor shader {}: {}", path, log );
|
||||||
@ -155,7 +155,7 @@ class MonitorTextureBufferShader
|
|||||||
|
|
||||||
private static int getUniformLocation( int program, String name )
|
private static int getUniformLocation( int program, String name )
|
||||||
{
|
{
|
||||||
int uniform = GlStateManager.getUniformLocation( program, name );
|
int uniform = GlStateManager._glGetUniformLocation( program, name );
|
||||||
if( uniform == -1 ) throw new IllegalStateException( "Cannot find uniform " + name );
|
if( uniform == -1 ) throw new IllegalStateException( "Cannot find uniform " + name );
|
||||||
return uniform;
|
return uniform;
|
||||||
}
|
}
|
||||||
|
@ -146,18 +146,18 @@ public final class PrintoutRenderer
|
|||||||
|
|
||||||
private static void drawTexture( Matrix4f matrix, IVertexBuilder buffer, float x, float y, float z, float u, float v, float width, float height )
|
private static void drawTexture( Matrix4f matrix, IVertexBuilder buffer, float x, float y, float z, float u, float v, float width, float height )
|
||||||
{
|
{
|
||||||
buffer.pos( matrix, x, y + height, z ).tex( u / BG_SIZE, (v + height) / BG_SIZE ).endVertex();
|
buffer.vertex( matrix, x, y + height, z ).uv( u / BG_SIZE, (v + height) / BG_SIZE ).endVertex();
|
||||||
buffer.pos( matrix, x + width, y + height, z ).tex( (u + width) / BG_SIZE, (v + height) / BG_SIZE ).endVertex();
|
buffer.vertex( matrix, x + width, y + height, z ).uv( (u + width) / BG_SIZE, (v + height) / BG_SIZE ).endVertex();
|
||||||
buffer.pos( matrix, x + width, y, z ).tex( (u + width) / BG_SIZE, v / BG_SIZE ).endVertex();
|
buffer.vertex( matrix, x + width, y, z ).uv( (u + width) / BG_SIZE, v / BG_SIZE ).endVertex();
|
||||||
buffer.pos( matrix, x, y, z ).tex( u / BG_SIZE, v / BG_SIZE ).endVertex();
|
buffer.vertex( matrix, x, y, z ).uv( u / BG_SIZE, v / BG_SIZE ).endVertex();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void drawTexture( Matrix4f matrix, IVertexBuilder buffer, float x, float y, float z, float width, float height, float u, float v, float tWidth, float tHeight )
|
private static void drawTexture( Matrix4f matrix, IVertexBuilder buffer, float x, float y, float z, float width, float height, float u, float v, float tWidth, float tHeight )
|
||||||
{
|
{
|
||||||
buffer.pos( matrix, x, y + height, z ).tex( u / BG_SIZE, (v + tHeight) / BG_SIZE ).endVertex();
|
buffer.vertex( matrix, x, y + height, z ).uv( u / BG_SIZE, (v + tHeight) / BG_SIZE ).endVertex();
|
||||||
buffer.pos( matrix, x + width, y + height, z ).tex( (u + tWidth) / BG_SIZE, (v + tHeight) / BG_SIZE ).endVertex();
|
buffer.vertex( matrix, x + width, y + height, z ).uv( (u + tWidth) / BG_SIZE, (v + tHeight) / BG_SIZE ).endVertex();
|
||||||
buffer.pos( matrix, x + width, y, z ).tex( (u + tWidth) / BG_SIZE, v / BG_SIZE ).endVertex();
|
buffer.vertex( matrix, x + width, y, z ).uv( (u + tWidth) / BG_SIZE, v / BG_SIZE ).endVertex();
|
||||||
buffer.pos( matrix, x, y, z ).tex( u / BG_SIZE, v / BG_SIZE ).endVertex();
|
buffer.vertex( matrix, x, y, z ).uv( u / BG_SIZE, v / BG_SIZE ).endVertex();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float offsetAt( int page )
|
public static float offsetAt( int page )
|
||||||
@ -167,14 +167,14 @@ public final class PrintoutRenderer
|
|||||||
|
|
||||||
private static final class Type extends RenderState
|
private static final class Type extends RenderState
|
||||||
{
|
{
|
||||||
static final RenderType TYPE = RenderType.makeType(
|
static final RenderType TYPE = RenderType.create(
|
||||||
"printout_background", DefaultVertexFormats.POSITION_TEX, GL11.GL_QUADS, 1024,
|
"printout_background", DefaultVertexFormats.POSITION_TEX, GL11.GL_QUADS, 1024,
|
||||||
false, false, // useDelegate, needsSorting
|
false, false, // useDelegate, needsSorting
|
||||||
RenderType.State.getBuilder()
|
RenderType.State.builder()
|
||||||
.texture( new RenderState.TextureState( BG, false, false ) ) // blur, minimap
|
.setTextureState( new RenderState.TextureState( BG, false, false ) ) // blur, minimap
|
||||||
.alpha( DEFAULT_ALPHA )
|
.setAlphaState( DEFAULT_ALPHA )
|
||||||
.lightmap( LIGHTMAP_DISABLED )
|
.setLightmapState( NO_LIGHTMAP )
|
||||||
.build( false )
|
.createCompositeState( false )
|
||||||
);
|
);
|
||||||
|
|
||||||
private Type( String name, Runnable setup, Runnable destroy )
|
private Type( String name, Runnable setup, Runnable destroy )
|
||||||
|
@ -58,7 +58,7 @@ public class TileEntityMonitorRenderer extends TileEntityRenderer<TileMonitor>
|
|||||||
|
|
||||||
if( originTerminal == null ) return;
|
if( originTerminal == null ) return;
|
||||||
TileMonitor origin = originTerminal.getOrigin();
|
TileMonitor origin = originTerminal.getOrigin();
|
||||||
BlockPos monitorPos = monitor.getPos();
|
BlockPos monitorPos = monitor.getBlockPos();
|
||||||
|
|
||||||
// Ensure each monitor terminal is rendered only once. We allow rendering a specific tile
|
// Ensure each monitor terminal is rendered only once. We allow rendering a specific tile
|
||||||
// multiple times in a single frame to ensure compatibility with shaders which may run a
|
// multiple times in a single frame to ensure compatibility with shaders which may run a
|
||||||
@ -72,24 +72,24 @@ public class TileEntityMonitorRenderer extends TileEntityRenderer<TileMonitor>
|
|||||||
originTerminal.lastRenderFrame = renderFrame;
|
originTerminal.lastRenderFrame = renderFrame;
|
||||||
originTerminal.lastRenderPos = monitorPos;
|
originTerminal.lastRenderPos = monitorPos;
|
||||||
|
|
||||||
BlockPos originPos = origin.getPos();
|
BlockPos originPos = origin.getBlockPos();
|
||||||
|
|
||||||
// Determine orientation
|
// Determine orientation
|
||||||
Direction dir = origin.getDirection();
|
Direction dir = origin.getDirection();
|
||||||
Direction front = origin.getFront();
|
Direction front = origin.getFront();
|
||||||
float yaw = dir.getHorizontalAngle();
|
float yaw = dir.toYRot();
|
||||||
float pitch = DirectionUtil.toPitchAngle( front );
|
float pitch = DirectionUtil.toPitchAngle( front );
|
||||||
|
|
||||||
// Setup initial transform
|
// Setup initial transform
|
||||||
transform.push();
|
transform.pushPose();
|
||||||
transform.translate(
|
transform.translate(
|
||||||
originPos.getX() - monitorPos.getX() + 0.5,
|
originPos.getX() - monitorPos.getX() + 0.5,
|
||||||
originPos.getY() - monitorPos.getY() + 0.5,
|
originPos.getY() - monitorPos.getY() + 0.5,
|
||||||
originPos.getZ() - monitorPos.getZ() + 0.5
|
originPos.getZ() - monitorPos.getZ() + 0.5
|
||||||
);
|
);
|
||||||
|
|
||||||
transform.rotate( Vector3f.YN.rotationDegrees( yaw ) );
|
transform.mulPose( Vector3f.YN.rotationDegrees( yaw ) );
|
||||||
transform.rotate( Vector3f.XP.rotationDegrees( pitch ) );
|
transform.mulPose( Vector3f.XP.rotationDegrees( pitch ) );
|
||||||
transform.translate(
|
transform.translate(
|
||||||
-0.5 + TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN,
|
-0.5 + TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN,
|
||||||
origin.getHeight() - 0.5 - (TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN) + 0,
|
origin.getHeight() - 0.5 - (TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN) + 0,
|
||||||
@ -107,10 +107,10 @@ public class TileEntityMonitorRenderer extends TileEntityRenderer<TileMonitor>
|
|||||||
int pixelWidth = width * FONT_WIDTH, pixelHeight = height * FONT_HEIGHT;
|
int pixelWidth = width * FONT_WIDTH, pixelHeight = height * FONT_HEIGHT;
|
||||||
double xScale = xSize / pixelWidth;
|
double xScale = xSize / pixelWidth;
|
||||||
double yScale = ySize / pixelHeight;
|
double yScale = ySize / pixelHeight;
|
||||||
transform.push();
|
transform.pushPose();
|
||||||
transform.scale( (float) xScale, (float) -yScale, 1.0f );
|
transform.scale( (float) xScale, (float) -yScale, 1.0f );
|
||||||
|
|
||||||
Matrix4f matrix = transform.getLast().getMatrix();
|
Matrix4f matrix = transform.last().pose();
|
||||||
|
|
||||||
// Sneaky hack here: we get a buffer now in order to flush existing ones and set up the appropriate
|
// Sneaky hack here: we get a buffer now in order to flush existing ones and set up the appropriate
|
||||||
// render state. I've no clue how well this'll work in future versions of Minecraft, but it does the trick
|
// render state. I've no clue how well this'll work in future versions of Minecraft, but it does the trick
|
||||||
@ -124,24 +124,24 @@ public class TileEntityMonitorRenderer extends TileEntityRenderer<TileMonitor>
|
|||||||
// reasonable.
|
// reasonable.
|
||||||
FixedWidthFontRenderer.drawCursor( matrix, buffer, 0, 0, terminal, !originTerminal.isColour() );
|
FixedWidthFontRenderer.drawCursor( matrix, buffer, 0, 0, terminal, !originTerminal.isColour() );
|
||||||
|
|
||||||
transform.pop();
|
transform.popPose();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FixedWidthFontRenderer.drawEmptyTerminal(
|
FixedWidthFontRenderer.drawEmptyTerminal(
|
||||||
transform.getLast().getMatrix(), renderer,
|
transform.last().pose(), renderer,
|
||||||
-MARGIN, MARGIN,
|
-MARGIN, MARGIN,
|
||||||
(float) (xSize + 2 * MARGIN), (float) -(ySize + MARGIN * 2)
|
(float) (xSize + 2 * MARGIN), (float) -(ySize + MARGIN * 2)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
FixedWidthFontRenderer.drawBlocker(
|
FixedWidthFontRenderer.drawBlocker(
|
||||||
transform.getLast().getMatrix(), renderer,
|
transform.last().pose(), renderer,
|
||||||
(float) -TileMonitor.RENDER_MARGIN, (float) TileMonitor.RENDER_MARGIN,
|
(float) -TileMonitor.RENDER_MARGIN, (float) TileMonitor.RENDER_MARGIN,
|
||||||
(float) (xSize + 2 * TileMonitor.RENDER_MARGIN), (float) -(ySize + TileMonitor.RENDER_MARGIN * 2)
|
(float) (xSize + 2 * TileMonitor.RENDER_MARGIN), (float) -(ySize + TileMonitor.RENDER_MARGIN * 2)
|
||||||
);
|
);
|
||||||
|
|
||||||
transform.pop();
|
transform.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void renderTerminal( Matrix4f matrix, ClientMonitor monitor, float xMargin, float yMargin )
|
private static void renderTerminal( Matrix4f matrix, ClientMonitor monitor, float xMargin, float yMargin )
|
||||||
@ -166,7 +166,7 @@ public class TileEntityMonitorRenderer extends TileEntityRenderer<TileMonitor>
|
|||||||
int size = width * height * 3;
|
int size = width * height * 3;
|
||||||
if( tboContents == null || tboContents.capacity() < size )
|
if( tboContents == null || tboContents.capacity() < size )
|
||||||
{
|
{
|
||||||
tboContents = GLAllocation.createDirectByteBuffer( size );
|
tboContents = GLAllocation.createByteBuffer( size );
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteBuffer monitorBuffer = tboContents;
|
ByteBuffer monitorBuffer = tboContents;
|
||||||
@ -183,28 +183,28 @@ public class TileEntityMonitorRenderer extends TileEntityRenderer<TileMonitor>
|
|||||||
}
|
}
|
||||||
monitorBuffer.flip();
|
monitorBuffer.flip();
|
||||||
|
|
||||||
GlStateManager.bindBuffer( GL31.GL_TEXTURE_BUFFER, monitor.tboBuffer );
|
GlStateManager._glBindBuffer( GL31.GL_TEXTURE_BUFFER, monitor.tboBuffer );
|
||||||
GlStateManager.bufferData( GL31.GL_TEXTURE_BUFFER, monitorBuffer, GL20.GL_STATIC_DRAW );
|
GlStateManager._glBufferData( GL31.GL_TEXTURE_BUFFER, monitorBuffer, GL20.GL_STATIC_DRAW );
|
||||||
GlStateManager.bindBuffer( GL31.GL_TEXTURE_BUFFER, 0 );
|
GlStateManager._glBindBuffer( GL31.GL_TEXTURE_BUFFER, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nobody knows what they're doing!
|
// Nobody knows what they're doing!
|
||||||
GlStateManager.activeTexture( MonitorTextureBufferShader.TEXTURE_INDEX );
|
GlStateManager._activeTexture( MonitorTextureBufferShader.TEXTURE_INDEX );
|
||||||
GL11.glBindTexture( GL31.GL_TEXTURE_BUFFER, monitor.tboTexture );
|
GL11.glBindTexture( GL31.GL_TEXTURE_BUFFER, monitor.tboTexture );
|
||||||
GlStateManager.activeTexture( GL13.GL_TEXTURE0 );
|
GlStateManager._activeTexture( GL13.GL_TEXTURE0 );
|
||||||
|
|
||||||
MonitorTextureBufferShader.setupUniform( matrix, width, height, terminal.getPalette(), !monitor.isColour() );
|
MonitorTextureBufferShader.setupUniform( matrix, width, height, terminal.getPalette(), !monitor.isColour() );
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
BufferBuilder buffer = tessellator.getBuffer();
|
BufferBuilder buffer = tessellator.getBuilder();
|
||||||
buffer.begin( GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION );
|
buffer.begin( GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION );
|
||||||
buffer.pos( -xMargin, -yMargin, 0 ).endVertex();
|
buffer.vertex( -xMargin, -yMargin, 0 ).endVertex();
|
||||||
buffer.pos( -xMargin, pixelHeight + yMargin, 0 ).endVertex();
|
buffer.vertex( -xMargin, pixelHeight + yMargin, 0 ).endVertex();
|
||||||
buffer.pos( pixelWidth + xMargin, -yMargin, 0 ).endVertex();
|
buffer.vertex( pixelWidth + xMargin, -yMargin, 0 ).endVertex();
|
||||||
buffer.pos( pixelWidth + xMargin, pixelHeight + yMargin, 0 ).endVertex();
|
buffer.vertex( pixelWidth + xMargin, pixelHeight + yMargin, 0 ).endVertex();
|
||||||
tessellator.draw();
|
tessellator.end();
|
||||||
|
|
||||||
GlStateManager.useProgram( 0 );
|
GlStateManager._glUseProgram( 0 );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,22 +214,22 @@ public class TileEntityMonitorRenderer extends TileEntityRenderer<TileMonitor>
|
|||||||
if( redraw )
|
if( redraw )
|
||||||
{
|
{
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
BufferBuilder builder = tessellator.getBuffer();
|
BufferBuilder builder = tessellator.getBuilder();
|
||||||
builder.begin( FixedWidthFontRenderer.TYPE.getDrawMode(), FixedWidthFontRenderer.TYPE.getVertexFormat() );
|
builder.begin( FixedWidthFontRenderer.TYPE.mode(), FixedWidthFontRenderer.TYPE.format() );
|
||||||
FixedWidthFontRenderer.drawTerminalWithoutCursor(
|
FixedWidthFontRenderer.drawTerminalWithoutCursor(
|
||||||
IDENTITY, builder, 0, 0,
|
IDENTITY, builder, 0, 0,
|
||||||
terminal, !monitor.isColour(), yMargin, yMargin, xMargin, xMargin
|
terminal, !monitor.isColour(), yMargin, yMargin, xMargin, xMargin
|
||||||
);
|
);
|
||||||
|
|
||||||
builder.finishDrawing();
|
builder.end();
|
||||||
vbo.upload( builder );
|
vbo.upload( builder );
|
||||||
}
|
}
|
||||||
|
|
||||||
vbo.bindBuffer();
|
vbo.bind();
|
||||||
FixedWidthFontRenderer.TYPE.getVertexFormat().setupBufferState( 0L );
|
FixedWidthFontRenderer.TYPE.format().setupBufferState( 0L );
|
||||||
vbo.draw( matrix, FixedWidthFontRenderer.TYPE.getDrawMode() );
|
vbo.draw( matrix, FixedWidthFontRenderer.TYPE.mode() );
|
||||||
VertexBuffer.unbindBuffer();
|
VertexBuffer.unbind();
|
||||||
FixedWidthFontRenderer.TYPE.getVertexFormat().clearBufferState();
|
FixedWidthFontRenderer.TYPE.format().clearBufferState();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,31 +72,31 @@ public class TileEntityTurtleRenderer extends TileEntityRenderer<TileTurtle>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render( @Nonnull TileTurtle turtle, float partialTicks, @Nonnull MatrixStack transform, @Nonnull IRenderTypeBuffer renderer, int lightmapCoord, int overlayLight )
|
public void render( @Nonnull TileTurtle turtle, float partialTicks, @Nonnull MatrixStack transform, @Nonnull IRenderTypeBuffer buffers, int lightmapCoord, int overlayLight )
|
||||||
{
|
{
|
||||||
// Render the label
|
// Render the label
|
||||||
String label = turtle.createProxy().getLabel();
|
String label = turtle.createProxy().getLabel();
|
||||||
RayTraceResult hit = renderDispatcher.cameraHitResult;
|
RayTraceResult hit = renderer.cameraHitResult;
|
||||||
if( label != null && hit.getType() == RayTraceResult.Type.BLOCK && turtle.getPos().equals( ((BlockRayTraceResult) hit).getPos() ) )
|
if( label != null && hit.getType() == RayTraceResult.Type.BLOCK && turtle.getBlockPos().equals( ((BlockRayTraceResult) hit).getBlockPos() ) )
|
||||||
{
|
{
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
FontRenderer font = renderDispatcher.fontRenderer;
|
FontRenderer font = renderer.font;
|
||||||
|
|
||||||
transform.push();
|
transform.pushPose();
|
||||||
transform.translate( 0.5, 1.2, 0.5 );
|
transform.translate( 0.5, 1.2, 0.5 );
|
||||||
transform.rotate( mc.getRenderManager().getCameraOrientation() );
|
transform.mulPose( mc.getEntityRenderDispatcher().cameraOrientation() );
|
||||||
transform.scale( -0.025f, -0.025f, 0.025f );
|
transform.scale( -0.025f, -0.025f, 0.025f );
|
||||||
|
|
||||||
Matrix4f matrix = transform.getLast().getMatrix();
|
Matrix4f matrix = transform.last().pose();
|
||||||
int opacity = (int) (mc.gameSettings.getTextBackgroundOpacity( 0.25f ) * 255) << 24;
|
int opacity = (int) (mc.options.getBackgroundOpacity( 0.25f ) * 255) << 24;
|
||||||
float width = -font.getStringWidth( label ) / 2.0f;
|
float width = -font.width( label ) / 2.0f;
|
||||||
font.renderString( label, width, (float) 0, 0x20ffffff, false, matrix, renderer, true, opacity, lightmapCoord );
|
font.drawInBatch( label, width, (float) 0, 0x20ffffff, false, matrix, buffers, true, opacity, lightmapCoord );
|
||||||
font.renderString( label, width, (float) 0, 0xffffffff, false, matrix, renderer, false, 0, lightmapCoord );
|
font.drawInBatch( label, width, (float) 0, 0xffffffff, false, matrix, buffers, false, 0, lightmapCoord );
|
||||||
|
|
||||||
transform.pop();
|
transform.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
transform.push();
|
transform.pushPose();
|
||||||
|
|
||||||
// Setup the transform.
|
// Setup the transform.
|
||||||
Vec3d offset = turtle.getRenderOffset( partialTicks );
|
Vec3d offset = turtle.getRenderOffset( partialTicks );
|
||||||
@ -104,7 +104,7 @@ public class TileEntityTurtleRenderer extends TileEntityRenderer<TileTurtle>
|
|||||||
transform.translate( offset.x, offset.y, offset.z );
|
transform.translate( offset.x, offset.y, offset.z );
|
||||||
|
|
||||||
transform.translate( 0.5f, 0.5f, 0.5f );
|
transform.translate( 0.5f, 0.5f, 0.5f );
|
||||||
transform.rotate( Vector3f.YP.rotationDegrees( 180.0f - yaw ) );
|
transform.mulPose( Vector3f.YP.rotationDegrees( 180.0f - yaw ) );
|
||||||
if( label != null && (label.equals( "Dinnerbone" ) || label.equals( "Grumm" )) )
|
if( label != null && (label.equals( "Dinnerbone" ) || label.equals( "Grumm" )) )
|
||||||
{
|
{
|
||||||
// Flip the model
|
// Flip the model
|
||||||
@ -117,7 +117,7 @@ public class TileEntityTurtleRenderer extends TileEntityRenderer<TileTurtle>
|
|||||||
ComputerFamily family = turtle.getFamily();
|
ComputerFamily family = turtle.getFamily();
|
||||||
ResourceLocation overlay = turtle.getOverlay();
|
ResourceLocation overlay = turtle.getOverlay();
|
||||||
|
|
||||||
IVertexBuilder buffer = renderer.getBuffer( Atlases.getTranslucentCullBlockType() );
|
IVertexBuilder buffer = buffers.getBuffer( Atlases.translucentCullBlockSheet() );
|
||||||
renderModel( transform, buffer, lightmapCoord, overlayLight, getTurtleModel( family, colour != -1 ), colour == -1 ? null : new int[] { colour } );
|
renderModel( transform, buffer, lightmapCoord, overlayLight, getTurtleModel( family, colour != -1 ), colour == -1 ? null : new int[] { colour } );
|
||||||
|
|
||||||
// Render the overlay
|
// Render the overlay
|
||||||
@ -131,31 +131,31 @@ public class TileEntityTurtleRenderer extends TileEntityRenderer<TileTurtle>
|
|||||||
renderUpgrade( transform, buffer, lightmapCoord, overlayLight, turtle, TurtleSide.LEFT, partialTicks );
|
renderUpgrade( transform, buffer, lightmapCoord, overlayLight, turtle, TurtleSide.LEFT, partialTicks );
|
||||||
renderUpgrade( transform, buffer, lightmapCoord, overlayLight, turtle, TurtleSide.RIGHT, partialTicks );
|
renderUpgrade( transform, buffer, lightmapCoord, overlayLight, turtle, TurtleSide.RIGHT, partialTicks );
|
||||||
|
|
||||||
transform.pop();
|
transform.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderUpgrade( @Nonnull MatrixStack transform, @Nonnull IVertexBuilder renderer, int lightmapCoord, int overlayLight, TileTurtle turtle, TurtleSide side, float f )
|
private void renderUpgrade( @Nonnull MatrixStack transform, @Nonnull IVertexBuilder renderer, int lightmapCoord, int overlayLight, TileTurtle turtle, TurtleSide side, float f )
|
||||||
{
|
{
|
||||||
ITurtleUpgrade upgrade = turtle.getUpgrade( side );
|
ITurtleUpgrade upgrade = turtle.getUpgrade( side );
|
||||||
if( upgrade == null ) return;
|
if( upgrade == null ) return;
|
||||||
transform.push();
|
transform.pushPose();
|
||||||
|
|
||||||
float toolAngle = turtle.getToolRenderAngle( side, f );
|
float toolAngle = turtle.getToolRenderAngle( side, f );
|
||||||
transform.translate( 0.0f, 0.5f, 0.5f );
|
transform.translate( 0.0f, 0.5f, 0.5f );
|
||||||
transform.rotate( Vector3f.XN.rotationDegrees( toolAngle ) );
|
transform.mulPose( Vector3f.XN.rotationDegrees( toolAngle ) );
|
||||||
transform.translate( 0.0f, -0.5f, -0.5f );
|
transform.translate( 0.0f, -0.5f, -0.5f );
|
||||||
|
|
||||||
TransformedModel model = upgrade.getModel( turtle.getAccess(), side );
|
TransformedModel model = upgrade.getModel( turtle.getAccess(), side );
|
||||||
model.getMatrix().push( transform );
|
model.getMatrix().push( transform );
|
||||||
renderModel( transform, renderer, lightmapCoord, overlayLight, model.getModel(), null );
|
renderModel( transform, renderer, lightmapCoord, overlayLight, model.getModel(), null );
|
||||||
transform.pop();
|
transform.popPose();
|
||||||
|
|
||||||
transform.pop();
|
transform.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderModel( @Nonnull MatrixStack transform, @Nonnull IVertexBuilder renderer, int lightmapCoord, int overlayLight, ModelResourceLocation modelLocation, int[] tints )
|
private void renderModel( @Nonnull MatrixStack transform, @Nonnull IVertexBuilder renderer, int lightmapCoord, int overlayLight, ModelResourceLocation modelLocation, int[] tints )
|
||||||
{
|
{
|
||||||
ModelManager modelManager = Minecraft.getInstance().getItemRenderer().getItemModelMesher().getModelManager();
|
ModelManager modelManager = Minecraft.getInstance().getItemRenderer().getItemModelShaper().getModelManager();
|
||||||
renderModel( transform, renderer, lightmapCoord, overlayLight, modelManager.getModel( modelLocation ), tints );
|
renderModel( transform, renderer, lightmapCoord, overlayLight, modelManager.getModel( modelLocation ), tints );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,12 +171,12 @@ public class TileEntityTurtleRenderer extends TileEntityRenderer<TileTurtle>
|
|||||||
|
|
||||||
private static void renderQuads( @Nonnull MatrixStack transform, @Nonnull IVertexBuilder buffer, int lightmapCoord, int overlayLight, List<BakedQuad> quads, int[] tints )
|
private static void renderQuads( @Nonnull MatrixStack transform, @Nonnull IVertexBuilder buffer, int lightmapCoord, int overlayLight, List<BakedQuad> quads, int[] tints )
|
||||||
{
|
{
|
||||||
MatrixStack.Entry matrix = transform.getLast();
|
MatrixStack.Entry matrix = transform.last();
|
||||||
|
|
||||||
for( BakedQuad bakedquad : quads )
|
for( BakedQuad bakedquad : quads )
|
||||||
{
|
{
|
||||||
int tint = -1;
|
int tint = -1;
|
||||||
if( tints != null && bakedquad.hasTintIndex() )
|
if( tints != null && bakedquad.isTinted() )
|
||||||
{
|
{
|
||||||
int idx = bakedquad.getTintIndex();
|
int idx = bakedquad.getTintIndex();
|
||||||
if( idx >= 0 && idx < tints.length ) tint = tints[bakedquad.getTintIndex()];
|
if( idx >= 0 && idx < tints.length ) tint = tints[bakedquad.getTintIndex()];
|
||||||
|
@ -43,7 +43,7 @@ public final class TurtleModelLoader implements IModelLoader<TurtleModelLoader.T
|
|||||||
@Override
|
@Override
|
||||||
public TurtleModel read( @Nonnull JsonDeserializationContext deserializationContext, @Nonnull JsonObject modelContents )
|
public TurtleModel read( @Nonnull JsonDeserializationContext deserializationContext, @Nonnull JsonObject modelContents )
|
||||||
{
|
{
|
||||||
ResourceLocation model = new ResourceLocation( JSONUtils.getString( modelContents, "model" ) );
|
ResourceLocation model = new ResourceLocation( JSONUtils.getAsString( modelContents, "model" ) );
|
||||||
return new TurtleModel( model );
|
return new TurtleModel( model );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,8 +60,8 @@ public final class TurtleModelLoader implements IModelLoader<TurtleModelLoader.T
|
|||||||
public Collection<Material> getTextures( IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
|
public Collection<Material> getTextures( IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
|
||||||
{
|
{
|
||||||
Set<Material> materials = new HashSet<>();
|
Set<Material> materials = new HashSet<>();
|
||||||
materials.addAll( modelGetter.apply( family ).getTextures( modelGetter, missingTextureErrors ) );
|
materials.addAll( modelGetter.apply( family ).getMaterials( modelGetter, missingTextureErrors ) );
|
||||||
materials.addAll( modelGetter.apply( COLOUR_TURTLE_MODEL ).getTextures( modelGetter, missingTextureErrors ) );
|
materials.addAll( modelGetter.apply( COLOUR_TURTLE_MODEL ).getMaterials( modelGetter, missingTextureErrors ) );
|
||||||
return materials;
|
return materials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,9 +90,9 @@ public class TurtleMultiModel implements IBakedModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAmbientOcclusion()
|
public boolean useAmbientOcclusion()
|
||||||
{
|
{
|
||||||
return m_baseModel.isAmbientOcclusion();
|
return m_baseModel.useAmbientOcclusion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -102,31 +102,31 @@ public class TurtleMultiModel implements IBakedModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBuiltInRenderer()
|
public boolean isCustomRenderer()
|
||||||
{
|
{
|
||||||
return m_baseModel.isBuiltInRenderer();
|
return m_baseModel.isCustomRenderer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean func_230044_c_()
|
public boolean usesBlockLight()
|
||||||
{
|
{
|
||||||
return m_baseModel.func_230044_c_();
|
return m_baseModel.usesBlockLight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public TextureAtlasSprite getParticleTexture()
|
public TextureAtlasSprite getParticleIcon()
|
||||||
{
|
{
|
||||||
return m_baseModel.getParticleTexture();
|
return m_baseModel.getParticleIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public net.minecraft.client.renderer.model.ItemCameraTransforms getItemCameraTransforms()
|
public net.minecraft.client.renderer.model.ItemCameraTransforms getTransforms()
|
||||||
{
|
{
|
||||||
return m_baseModel.getItemCameraTransforms();
|
return m_baseModel.getTransforms();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -23,7 +23,7 @@ public class TurtlePlayerRenderer extends EntityRenderer<TurtlePlayer>
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation getEntityTexture( @Nonnull TurtlePlayer entity )
|
public ResourceLocation getTextureLocation( @Nonnull TurtlePlayer entity )
|
||||||
{
|
{
|
||||||
return ComputerBorderRenderer.BACKGROUND_NORMAL;
|
return ComputerBorderRenderer.BACKGROUND_NORMAL;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class TurtleSmartItemModel implements IBakedModel
|
|||||||
stack.translate( 0, 0, 1 );
|
stack.translate( 0, 0, 1 );
|
||||||
|
|
||||||
identity = TransformationMatrix.identity();
|
identity = TransformationMatrix.identity();
|
||||||
flip = new TransformationMatrix( stack.getLast().getMatrix() );
|
flip = new TransformationMatrix( stack.last().pose() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TurtleModelCombination
|
private static class TurtleModelCombination
|
||||||
@ -109,7 +109,7 @@ public class TurtleSmartItemModel implements IBakedModel
|
|||||||
{
|
{
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public IBakedModel getModelWithOverrides( @Nonnull IBakedModel originalModel, @Nonnull ItemStack stack, @Nullable World world, @Nullable LivingEntity entity )
|
public IBakedModel resolve( @Nonnull IBakedModel originalModel, @Nonnull ItemStack stack, @Nullable World world, @Nullable LivingEntity entity )
|
||||||
{
|
{
|
||||||
ItemTurtle turtle = (ItemTurtle) stack.getItem();
|
ItemTurtle turtle = (ItemTurtle) stack.getItem();
|
||||||
int colour = turtle.getColour( stack );
|
int colour = turtle.getColour( stack );
|
||||||
@ -138,7 +138,7 @@ public class TurtleSmartItemModel implements IBakedModel
|
|||||||
private IBakedModel buildModel( TurtleModelCombination combo )
|
private IBakedModel buildModel( TurtleModelCombination combo )
|
||||||
{
|
{
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
ModelManager modelManager = mc.getItemRenderer().getItemModelMesher().getModelManager();
|
ModelManager modelManager = mc.getItemRenderer().getItemModelShaper().getModelManager();
|
||||||
ModelResourceLocation overlayModelLocation = TileEntityTurtleRenderer.getTurtleOverlayModel( combo.m_overlay, combo.m_christmas );
|
ModelResourceLocation overlayModelLocation = TileEntityTurtleRenderer.getTurtleOverlayModel( combo.m_overlay, combo.m_christmas );
|
||||||
|
|
||||||
IBakedModel baseModel = combo.m_colour ? colourModel : familyModel;
|
IBakedModel baseModel = combo.m_colour ? colourModel : familyModel;
|
||||||
@ -166,9 +166,9 @@ public class TurtleSmartItemModel implements IBakedModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAmbientOcclusion()
|
public boolean useAmbientOcclusion()
|
||||||
{
|
{
|
||||||
return familyModel.isAmbientOcclusion();
|
return familyModel.useAmbientOcclusion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -178,31 +178,31 @@ public class TurtleSmartItemModel implements IBakedModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBuiltInRenderer()
|
public boolean isCustomRenderer()
|
||||||
{
|
{
|
||||||
return familyModel.isBuiltInRenderer();
|
return familyModel.isCustomRenderer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean func_230044_c_()
|
public boolean usesBlockLight()
|
||||||
{
|
{
|
||||||
return familyModel.func_230044_c_();
|
return familyModel.usesBlockLight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public TextureAtlasSprite getParticleTexture()
|
public TextureAtlasSprite getParticleIcon()
|
||||||
{
|
{
|
||||||
return familyModel.getParticleTexture();
|
return familyModel.getParticleIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public ItemCameraTransforms getItemCameraTransforms()
|
public ItemCameraTransforms getTransforms()
|
||||||
{
|
{
|
||||||
return familyModel.getItemCameraTransforms();
|
return familyModel.getTransforms();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@ import javax.annotation.Nonnull;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import dan200.computercraft.core.apis.IAPIEnvironment.IPeripheralChangeListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the "environment" that a {@link Computer} exists in.
|
* Represents the "environment" that a {@link Computer} exists in.
|
||||||
*
|
*
|
||||||
|
@ -104,7 +104,7 @@ public final class ResourceMount implements IMount
|
|||||||
{
|
{
|
||||||
boolean hasAny = false;
|
boolean hasAny = false;
|
||||||
FileEntry newRoot = new FileEntry( new ResourceLocation( namespace, subPath ) );
|
FileEntry newRoot = new FileEntry( new ResourceLocation( namespace, subPath ) );
|
||||||
for( ResourceLocation file : manager.getAllResourceLocations( subPath, s -> true ) )
|
for( ResourceLocation file : manager.listResources( subPath, s -> true ) )
|
||||||
{
|
{
|
||||||
if( !file.getNamespace().equals( namespace ) ) continue;
|
if( !file.getNamespace().equals( namespace ) ) continue;
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ public final class ResourceMount implements IMount
|
|||||||
|
|
||||||
synchronized void add( IReloadableResourceManager manager, ResourceMount mount )
|
synchronized void add( IReloadableResourceManager manager, ResourceMount mount )
|
||||||
{
|
{
|
||||||
if( managers.add( manager ) ) manager.addReloadListener( this );
|
if( managers.add( manager ) ) manager.registerReloadListener( this );
|
||||||
mounts.add( mount );
|
mounts.add( mount );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class BlockModelProvider extends BlockStateProvider
|
|||||||
private void registerComputer( BlockComputer block )
|
private void registerComputer( BlockComputer block )
|
||||||
{
|
{
|
||||||
VariantBlockStateBuilder builder = getVariantBuilder( block );
|
VariantBlockStateBuilder builder = getVariantBuilder( block );
|
||||||
for( ComputerState state : BlockComputer.STATE.getAllowedValues() )
|
for( ComputerState state : BlockComputer.STATE.getPossibleValues() )
|
||||||
{
|
{
|
||||||
BlockModelBuilder model = models()
|
BlockModelBuilder model = models()
|
||||||
.getBuilder( suffix( block, "_" + state ) )
|
.getBuilder( suffix( block, "_" + state ) )
|
||||||
@ -61,7 +61,7 @@ public class BlockModelProvider extends BlockStateProvider
|
|||||||
.texture( "side", suffix( block, "_side" ) )
|
.texture( "side", suffix( block, "_side" ) )
|
||||||
.texture( "front", suffix( block, "_front" + toSuffix( state ) ) );
|
.texture( "front", suffix( block, "_front" + toSuffix( state ) ) );
|
||||||
|
|
||||||
for( Direction facing : BlockComputer.FACING.getAllowedValues() )
|
for( Direction facing : BlockComputer.FACING.getPossibleValues() )
|
||||||
{
|
{
|
||||||
builder.partialState()
|
builder.partialState()
|
||||||
.with( BlockComputer.STATE, state )
|
.with( BlockComputer.STATE, state )
|
||||||
@ -92,14 +92,14 @@ public class BlockModelProvider extends BlockStateProvider
|
|||||||
registerMonitorModel( name, "_ud", 21, 6, 0, 37 );
|
registerMonitorModel( name, "_ud", 21, 6, 0, 37 );
|
||||||
|
|
||||||
VariantBlockStateBuilder builder = getVariantBuilder( block );
|
VariantBlockStateBuilder builder = getVariantBuilder( block );
|
||||||
for( MonitorEdgeState edge : BlockMonitor.STATE.getAllowedValues() )
|
for( MonitorEdgeState edge : BlockMonitor.STATE.getPossibleValues() )
|
||||||
{
|
{
|
||||||
String suffix = edge == MonitorEdgeState.NONE ? "" : "_" + edge.getName();
|
String suffix = edge == MonitorEdgeState.NONE ? "" : "_" + edge.getSerializedName();
|
||||||
ModelFile model = models().getBuilder( suffix( block, suffix ) );
|
ModelFile model = models().getBuilder( suffix( block, suffix ) );
|
||||||
|
|
||||||
for( Direction facing : BlockMonitor.FACING.getAllowedValues() )
|
for( Direction facing : BlockMonitor.FACING.getPossibleValues() )
|
||||||
{
|
{
|
||||||
for( Direction orientation : BlockMonitor.ORIENTATION.getAllowedValues() )
|
for( Direction orientation : BlockMonitor.ORIENTATION.getPossibleValues() )
|
||||||
{
|
{
|
||||||
builder.partialState()
|
builder.partialState()
|
||||||
.with( BlockMonitor.STATE, edge )
|
.with( BlockMonitor.STATE, edge )
|
||||||
@ -137,7 +137,7 @@ public class BlockModelProvider extends BlockStateProvider
|
|||||||
|
|
||||||
private static int toYAngle( Direction direction )
|
private static int toYAngle( Direction direction )
|
||||||
{
|
{
|
||||||
return ((int) direction.getHorizontalAngle() + 180) % 360;
|
return ((int) direction.toYRot() + 180) % 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String toSuffix( ComputerState state )
|
private static String toSuffix( ComputerState state )
|
||||||
|
@ -40,17 +40,17 @@ public abstract class LootTableProvider implements IDataProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void act( @Nonnull DirectoryCache cache )
|
public void run( @Nonnull DirectoryCache cache )
|
||||||
{
|
{
|
||||||
Map<ResourceLocation, LootTable> tables = new HashMap<>();
|
Map<ResourceLocation, LootTable> tables = new HashMap<>();
|
||||||
ValidationTracker validation = new ValidationTracker( LootParameterSets.GENERIC, x -> null, tables::get );
|
ValidationTracker validation = new ValidationTracker( LootParameterSets.ALL_PARAMS, x -> null, tables::get );
|
||||||
|
|
||||||
registerLoot( ( id, table ) -> {
|
registerLoot( ( id, table ) -> {
|
||||||
if( tables.containsKey( id ) ) validation.addProblem( "Duplicate loot tables for " + id );
|
if( tables.containsKey( id ) ) validation.reportProblem( "Duplicate loot tables for " + id );
|
||||||
tables.put( id, table );
|
tables.put( id, table );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
tables.forEach( ( key, value ) -> LootTableManager.func_227508_a_( validation, key, value ) );
|
tables.forEach( ( key, value ) -> LootTableManager.validate( validation, key, value ) );
|
||||||
|
|
||||||
Multimap<String, String> problems = validation.getProblems();
|
Multimap<String, String> problems = validation.getProblems();
|
||||||
if( !problems.isEmpty() )
|
if( !problems.isEmpty() )
|
||||||
@ -64,7 +64,7 @@ public abstract class LootTableProvider implements IDataProvider
|
|||||||
Path path = getPath( key );
|
Path path = getPath( key );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IDataProvider.save( GSON, cache, LootTableManager.toJson( value ), path );
|
IDataProvider.save( GSON, cache, LootTableManager.serialize( value ), path );
|
||||||
}
|
}
|
||||||
catch( IOException e )
|
catch( IOException e )
|
||||||
{
|
{
|
||||||
|
@ -47,8 +47,8 @@ public class LootTables extends LootTableProvider
|
|||||||
computerDrop( add, Registry.ModBlocks.TURTLE_ADVANCED );
|
computerDrop( add, Registry.ModBlocks.TURTLE_ADVANCED );
|
||||||
|
|
||||||
add.accept( ComputerCraftProxyCommon.ForgeHandlers.LOOT_TREASURE_DISK, LootTable
|
add.accept( ComputerCraftProxyCommon.ForgeHandlers.LOOT_TREASURE_DISK, LootTable
|
||||||
.builder()
|
.lootTable()
|
||||||
.setParameterSet( LootParameterSets.GENERIC )
|
.setParamSet( LootParameterSets.ALL_PARAMS )
|
||||||
.build() );
|
.build() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,13 +56,13 @@ public class LootTables extends LootTableProvider
|
|||||||
{
|
{
|
||||||
Block block = wrapper.get();
|
Block block = wrapper.get();
|
||||||
add.accept( block.getLootTable(), LootTable
|
add.accept( block.getLootTable(), LootTable
|
||||||
.builder()
|
.lootTable()
|
||||||
.setParameterSet( LootParameterSets.BLOCK )
|
.setParamSet( LootParameterSets.BLOCK )
|
||||||
.addLootPool( LootPool.builder()
|
.withPool( LootPool.lootPool()
|
||||||
.name( "main" )
|
.name( "main" )
|
||||||
.rolls( ConstantRange.of( 1 ) )
|
.setRolls( ConstantRange.exactly( 1 ) )
|
||||||
.addEntry( ItemLootEntry.builder( block ) )
|
.add( ItemLootEntry.lootTableItem( block ) )
|
||||||
.acceptCondition( SurvivesExplosion.builder() )
|
.when( SurvivesExplosion.survivesExplosion() )
|
||||||
).build() );
|
).build() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,16 +70,16 @@ public class LootTables extends LootTableProvider
|
|||||||
{
|
{
|
||||||
Block block = wrapper.get();
|
Block block = wrapper.get();
|
||||||
add.accept( block.getLootTable(), LootTable
|
add.accept( block.getLootTable(), LootTable
|
||||||
.builder()
|
.lootTable()
|
||||||
.setParameterSet( LootParameterSets.BLOCK )
|
.setParamSet( LootParameterSets.BLOCK )
|
||||||
.addLootPool( LootPool.builder()
|
.withPool( LootPool.lootPool()
|
||||||
.name( "main" )
|
.name( "main" )
|
||||||
.rolls( ConstantRange.of( 1 ) )
|
.setRolls( ConstantRange.exactly( 1 ) )
|
||||||
.addEntry( DynamicLootEntry.func_216162_a( new ResourceLocation( ComputerCraft.MOD_ID, "computer" ) ) )
|
.add( DynamicLootEntry.dynamicEntry( new ResourceLocation( ComputerCraft.MOD_ID, "computer" ) ) )
|
||||||
.acceptCondition( Alternative.builder(
|
.when( Alternative.alternative(
|
||||||
BlockNamedEntityLootCondition.builder(),
|
BlockNamedEntityLootCondition.builder(),
|
||||||
HasComputerIdLootCondition.builder(),
|
HasComputerIdLootCondition.builder(),
|
||||||
PlayerCreativeLootCondition.builder().inverted()
|
PlayerCreativeLootCondition.builder().invert()
|
||||||
) )
|
) )
|
||||||
).build() );
|
).build() );
|
||||||
}
|
}
|
||||||
|
@ -50,42 +50,42 @@ public final class RecipeWrapper implements IFinishedRecipe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize( @Nonnull JsonObject jsonObject )
|
public void serializeRecipeData( @Nonnull JsonObject jsonObject )
|
||||||
{
|
{
|
||||||
recipe.serialize( jsonObject );
|
recipe.serializeRecipeData( jsonObject );
|
||||||
|
|
||||||
if( resultData != null )
|
if( resultData != null )
|
||||||
{
|
{
|
||||||
JsonObject object = JSONUtils.getJsonObject( jsonObject, "result" );
|
JsonObject object = JSONUtils.getAsJsonObject( jsonObject, "result" );
|
||||||
object.addProperty( "nbt", resultData.toString() );
|
object.addProperty( "nbt", resultData.toString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation getID()
|
public ResourceLocation getId()
|
||||||
{
|
{
|
||||||
return recipe.getID();
|
return recipe.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public IRecipeSerializer<?> getSerializer()
|
public IRecipeSerializer<?> getType()
|
||||||
{
|
{
|
||||||
return serializer;
|
return serializer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public JsonObject getAdvancementJson()
|
public JsonObject serializeAdvancement()
|
||||||
{
|
{
|
||||||
return recipe.getAdvancementJson();
|
return recipe.serializeAdvancement();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation getAdvancementID()
|
public ResourceLocation getAdvancementId()
|
||||||
{
|
{
|
||||||
return recipe.getAdvancementID();
|
return recipe.getAdvancementId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public class Recipes extends RecipeProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerRecipes( @Nonnull Consumer<IFinishedRecipe> add )
|
protected void buildShapelessRecipes( @Nonnull Consumer<IFinishedRecipe> add )
|
||||||
{
|
{
|
||||||
basicRecipes( add );
|
basicRecipes( add );
|
||||||
diskColours( add );
|
diskColours( add );
|
||||||
@ -57,13 +57,13 @@ public class Recipes extends RecipeProvider
|
|||||||
for( Colour colour : Colour.VALUES )
|
for( Colour colour : Colour.VALUES )
|
||||||
{
|
{
|
||||||
ShapelessRecipeBuilder
|
ShapelessRecipeBuilder
|
||||||
.shapelessRecipe( Registry.ModItems.DISK.get() )
|
.shapeless( Registry.ModItems.DISK.get() )
|
||||||
.addIngredient( Tags.Items.DUSTS_REDSTONE )
|
.requires( Tags.Items.DUSTS_REDSTONE )
|
||||||
.addIngredient( Items.PAPER )
|
.requires( Items.PAPER )
|
||||||
.addIngredient( DyeItem.getItem( ofColour( colour ) ) )
|
.requires( DyeItem.byColor( ofColour( colour ) ) )
|
||||||
.setGroup( "computercraft:disk" )
|
.group( "computercraft:disk" )
|
||||||
.addCriterion( "has_drive", inventoryChange( Registry.ModBlocks.DISK_DRIVE.get() ) )
|
.unlocks( "has_drive", inventoryChange( Registry.ModBlocks.DISK_DRIVE.get() ) )
|
||||||
.build( RecipeWrapper.wrap(
|
.save( RecipeWrapper.wrap(
|
||||||
ImpostorShapelessRecipe.SERIALIZER, add,
|
ImpostorShapelessRecipe.SERIALIZER, add,
|
||||||
x -> x.putInt( IColouredItem.NBT_COLOUR, colour.getHex() )
|
x -> x.putInt( IColouredItem.NBT_COLOUR, colour.getHex() )
|
||||||
), new ResourceLocation( ComputerCraft.MOD_ID, "disk_" + (colour.ordinal() + 1) ) );
|
), new ResourceLocation( ComputerCraft.MOD_ID, "disk_" + (colour.ordinal() + 1) ) );
|
||||||
@ -87,14 +87,14 @@ public class Recipes extends RecipeProvider
|
|||||||
TurtleUpgrades.getVanillaUpgrades().forEach( upgrade -> {
|
TurtleUpgrades.getVanillaUpgrades().forEach( upgrade -> {
|
||||||
ItemStack result = TurtleItemFactory.create( -1, null, -1, family, null, upgrade, -1, null );
|
ItemStack result = TurtleItemFactory.create( -1, null, -1, family, null, upgrade, -1, null );
|
||||||
ShapedRecipeBuilder
|
ShapedRecipeBuilder
|
||||||
.shapedRecipe( result.getItem() )
|
.shaped( result.getItem() )
|
||||||
.setGroup( String.format( "%s:turtle_%s", ComputerCraft.MOD_ID, nameId ) )
|
.group( String.format( "%s:turtle_%s", ComputerCraft.MOD_ID, nameId ) )
|
||||||
.patternLine( "#T" )
|
.pattern( "#T" )
|
||||||
.key( '#', base.getItem() )
|
.define( '#', base.getItem() )
|
||||||
.key( 'T', upgrade.getCraftingItem().getItem() )
|
.define( 'T', upgrade.getCraftingItem().getItem() )
|
||||||
.addCriterion( "has_items",
|
.unlocks( "has_items",
|
||||||
inventoryChange( base.getItem(), upgrade.getCraftingItem().getItem() ) )
|
inventoryChange( base.getItem(), upgrade.getCraftingItem().getItem() ) )
|
||||||
.build(
|
.save(
|
||||||
RecipeWrapper.wrap( ImpostorRecipe.SERIALIZER, add, result.getTag() ),
|
RecipeWrapper.wrap( ImpostorRecipe.SERIALIZER, add, result.getTag() ),
|
||||||
new ResourceLocation( ComputerCraft.MOD_ID, String.format( "turtle_%s/%s/%s",
|
new ResourceLocation( ComputerCraft.MOD_ID, String.format( "turtle_%s/%s/%s",
|
||||||
nameId, upgrade.getUpgradeID().getNamespace(), upgrade.getUpgradeID().getPath()
|
nameId, upgrade.getUpgradeID().getNamespace(), upgrade.getUpgradeID().getPath()
|
||||||
@ -121,15 +121,15 @@ public class Recipes extends RecipeProvider
|
|||||||
PocketUpgrades.getVanillaUpgrades().forEach( upgrade -> {
|
PocketUpgrades.getVanillaUpgrades().forEach( upgrade -> {
|
||||||
ItemStack result = PocketComputerItemFactory.create( -1, null, -1, family, null );
|
ItemStack result = PocketComputerItemFactory.create( -1, null, -1, family, null );
|
||||||
ShapedRecipeBuilder
|
ShapedRecipeBuilder
|
||||||
.shapedRecipe( result.getItem() )
|
.shaped( result.getItem() )
|
||||||
.setGroup( String.format( "%s:pocket_%s", ComputerCraft.MOD_ID, nameId ) )
|
.group( String.format( "%s:pocket_%s", ComputerCraft.MOD_ID, nameId ) )
|
||||||
.patternLine( "#" )
|
.pattern( "#" )
|
||||||
.patternLine( "P" )
|
.pattern( "P" )
|
||||||
.key( '#', base.getItem() )
|
.define( '#', base.getItem() )
|
||||||
.key( 'P', upgrade.getCraftingItem().getItem() )
|
.define( 'P', upgrade.getCraftingItem().getItem() )
|
||||||
.addCriterion( "has_items",
|
.unlocks( "has_items",
|
||||||
inventoryChange( base.getItem(), upgrade.getCraftingItem().getItem() ) )
|
inventoryChange( base.getItem(), upgrade.getCraftingItem().getItem() ) )
|
||||||
.build(
|
.save(
|
||||||
RecipeWrapper.wrap( ImpostorRecipe.SERIALIZER, add, result.getTag() ),
|
RecipeWrapper.wrap( ImpostorRecipe.SERIALIZER, add, result.getTag() ),
|
||||||
new ResourceLocation( ComputerCraft.MOD_ID, String.format( "pocket_%s/%s/%s",
|
new ResourceLocation( ComputerCraft.MOD_ID, String.format( "pocket_%s/%s/%s",
|
||||||
nameId, upgrade.getUpgradeID().getNamespace(), upgrade.getUpgradeID().getPath()
|
nameId, upgrade.getUpgradeID().getNamespace(), upgrade.getUpgradeID().getPath()
|
||||||
@ -142,167 +142,167 @@ public class Recipes extends RecipeProvider
|
|||||||
private void basicRecipes( @Nonnull Consumer<IFinishedRecipe> add )
|
private void basicRecipes( @Nonnull Consumer<IFinishedRecipe> add )
|
||||||
{
|
{
|
||||||
ShapedRecipeBuilder
|
ShapedRecipeBuilder
|
||||||
.shapedRecipe( Registry.ModItems.CABLE.get(), 6 )
|
.shaped( Registry.ModItems.CABLE.get(), 6 )
|
||||||
.patternLine( " # " )
|
.pattern( " # " )
|
||||||
.patternLine( "#R#" )
|
.pattern( "#R#" )
|
||||||
.patternLine( " # " )
|
.pattern( " # " )
|
||||||
.key( '#', Tags.Items.STONE )
|
.define( '#', Tags.Items.STONE )
|
||||||
.key( 'R', Tags.Items.DUSTS_REDSTONE )
|
.define( 'R', Tags.Items.DUSTS_REDSTONE )
|
||||||
.addCriterion( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||||
.addCriterion( "has_modem", inventoryChange( CCTags.COMPUTER ) )
|
.unlocks( "has_modem", inventoryChange( CCTags.COMPUTER ) )
|
||||||
.build( add );
|
.save( add );
|
||||||
|
|
||||||
ShapedRecipeBuilder
|
ShapedRecipeBuilder
|
||||||
.shapedRecipe( Registry.ModBlocks.COMPUTER_NORMAL.get() )
|
.shaped( Registry.ModBlocks.COMPUTER_NORMAL.get() )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.patternLine( "#R#" )
|
.pattern( "#R#" )
|
||||||
.patternLine( "#G#" )
|
.pattern( "#G#" )
|
||||||
.key( '#', Tags.Items.STONE )
|
.define( '#', Tags.Items.STONE )
|
||||||
.key( 'R', Tags.Items.DUSTS_REDSTONE )
|
.define( 'R', Tags.Items.DUSTS_REDSTONE )
|
||||||
.key( 'G', Tags.Items.GLASS_PANES )
|
.define( 'G', Tags.Items.GLASS_PANES )
|
||||||
.addCriterion( "has_redstone", inventoryChange( Tags.Items.DUSTS_REDSTONE ) )
|
.unlocks( "has_redstone", inventoryChange( Tags.Items.DUSTS_REDSTONE ) )
|
||||||
.build( add );
|
.save( add );
|
||||||
|
|
||||||
ShapedRecipeBuilder
|
ShapedRecipeBuilder
|
||||||
.shapedRecipe( Registry.ModBlocks.COMPUTER_ADVANCED.get() )
|
.shaped( Registry.ModBlocks.COMPUTER_ADVANCED.get() )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.patternLine( "#R#" )
|
.pattern( "#R#" )
|
||||||
.patternLine( "#G#" )
|
.pattern( "#G#" )
|
||||||
.key( '#', Tags.Items.INGOTS_GOLD )
|
.define( '#', Tags.Items.INGOTS_GOLD )
|
||||||
.key( 'R', Tags.Items.DUSTS_REDSTONE )
|
.define( 'R', Tags.Items.DUSTS_REDSTONE )
|
||||||
.key( 'G', Tags.Items.GLASS_PANES )
|
.define( 'G', Tags.Items.GLASS_PANES )
|
||||||
.addCriterion( "has_components", inventoryChange( Items.REDSTONE, Items.GOLD_INGOT ) )
|
.unlocks( "has_components", inventoryChange( Items.REDSTONE, Items.GOLD_INGOT ) )
|
||||||
.build( add );
|
.save( add );
|
||||||
|
|
||||||
ShapedRecipeBuilder
|
ShapedRecipeBuilder
|
||||||
.shapedRecipe( Registry.ModBlocks.COMPUTER_COMMAND.get() )
|
.shaped( Registry.ModBlocks.COMPUTER_COMMAND.get() )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.patternLine( "#R#" )
|
.pattern( "#R#" )
|
||||||
.patternLine( "#G#" )
|
.pattern( "#G#" )
|
||||||
.key( '#', Tags.Items.INGOTS_GOLD )
|
.define( '#', Tags.Items.INGOTS_GOLD )
|
||||||
.key( 'R', Blocks.COMMAND_BLOCK )
|
.define( 'R', Blocks.COMMAND_BLOCK )
|
||||||
.key( 'G', Tags.Items.GLASS_PANES )
|
.define( 'G', Tags.Items.GLASS_PANES )
|
||||||
.addCriterion( "has_components", inventoryChange( Blocks.COMMAND_BLOCK ) )
|
.unlocks( "has_components", inventoryChange( Blocks.COMMAND_BLOCK ) )
|
||||||
.build( add );
|
.save( add );
|
||||||
|
|
||||||
ShapedRecipeBuilder
|
ShapedRecipeBuilder
|
||||||
.shapedRecipe( Registry.ModBlocks.DISK_DRIVE.get() )
|
.shaped( Registry.ModBlocks.DISK_DRIVE.get() )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.patternLine( "#R#" )
|
.pattern( "#R#" )
|
||||||
.patternLine( "#R#" )
|
.pattern( "#R#" )
|
||||||
.key( '#', Tags.Items.STONE )
|
.define( '#', Tags.Items.STONE )
|
||||||
.key( 'R', Tags.Items.DUSTS_REDSTONE )
|
.define( 'R', Tags.Items.DUSTS_REDSTONE )
|
||||||
.addCriterion( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||||
.build( add );
|
.save( add );
|
||||||
|
|
||||||
ShapedRecipeBuilder
|
ShapedRecipeBuilder
|
||||||
.shapedRecipe( Registry.ModBlocks.MONITOR_NORMAL.get() )
|
.shaped( Registry.ModBlocks.MONITOR_NORMAL.get() )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.patternLine( "#G#" )
|
.pattern( "#G#" )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.key( '#', Tags.Items.STONE )
|
.define( '#', Tags.Items.STONE )
|
||||||
.key( 'G', Tags.Items.GLASS_PANES )
|
.define( 'G', Tags.Items.GLASS_PANES )
|
||||||
.addCriterion( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||||
.build( add );
|
.save( add );
|
||||||
|
|
||||||
ShapedRecipeBuilder
|
ShapedRecipeBuilder
|
||||||
.shapedRecipe( Registry.ModBlocks.MONITOR_ADVANCED.get(), 4 )
|
.shaped( Registry.ModBlocks.MONITOR_ADVANCED.get(), 4 )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.patternLine( "#G#" )
|
.pattern( "#G#" )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.key( '#', Tags.Items.INGOTS_GOLD )
|
.define( '#', Tags.Items.INGOTS_GOLD )
|
||||||
.key( 'G', Tags.Items.GLASS_PANES )
|
.define( 'G', Tags.Items.GLASS_PANES )
|
||||||
.addCriterion( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||||
.build( add );
|
.save( add );
|
||||||
|
|
||||||
ShapedRecipeBuilder
|
ShapedRecipeBuilder
|
||||||
.shapedRecipe( Registry.ModItems.POCKET_COMPUTER_NORMAL.get() )
|
.shaped( Registry.ModItems.POCKET_COMPUTER_NORMAL.get() )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.patternLine( "#A#" )
|
.pattern( "#A#" )
|
||||||
.patternLine( "#G#" )
|
.pattern( "#G#" )
|
||||||
.key( '#', Tags.Items.STONE )
|
.define( '#', Tags.Items.STONE )
|
||||||
.key( 'A', Items.GOLDEN_APPLE )
|
.define( 'A', Items.GOLDEN_APPLE )
|
||||||
.key( 'G', Tags.Items.GLASS_PANES )
|
.define( 'G', Tags.Items.GLASS_PANES )
|
||||||
.addCriterion( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||||
.addCriterion( "has_apple", inventoryChange( Items.GOLDEN_APPLE ) )
|
.unlocks( "has_apple", inventoryChange( Items.GOLDEN_APPLE ) )
|
||||||
.build( add );
|
.save( add );
|
||||||
|
|
||||||
ShapedRecipeBuilder
|
ShapedRecipeBuilder
|
||||||
.shapedRecipe( Registry.ModItems.POCKET_COMPUTER_ADVANCED.get() )
|
.shaped( Registry.ModItems.POCKET_COMPUTER_ADVANCED.get() )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.patternLine( "#A#" )
|
.pattern( "#A#" )
|
||||||
.patternLine( "#G#" )
|
.pattern( "#G#" )
|
||||||
.key( '#', Tags.Items.INGOTS_GOLD )
|
.define( '#', Tags.Items.INGOTS_GOLD )
|
||||||
.key( 'A', Items.GOLDEN_APPLE )
|
.define( 'A', Items.GOLDEN_APPLE )
|
||||||
.key( 'G', Tags.Items.GLASS_PANES )
|
.define( 'G', Tags.Items.GLASS_PANES )
|
||||||
.addCriterion( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||||
.addCriterion( "has_apple", inventoryChange( Items.GOLDEN_APPLE ) )
|
.unlocks( "has_apple", inventoryChange( Items.GOLDEN_APPLE ) )
|
||||||
.build( add );
|
.save( add );
|
||||||
|
|
||||||
ShapedRecipeBuilder
|
ShapedRecipeBuilder
|
||||||
.shapedRecipe( Registry.ModBlocks.PRINTER.get() )
|
.shaped( Registry.ModBlocks.PRINTER.get() )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.patternLine( "#R#" )
|
.pattern( "#R#" )
|
||||||
.patternLine( "#D#" )
|
.pattern( "#D#" )
|
||||||
.key( '#', Tags.Items.STONE )
|
.define( '#', Tags.Items.STONE )
|
||||||
.key( 'R', Tags.Items.DUSTS_REDSTONE )
|
.define( 'R', Tags.Items.DUSTS_REDSTONE )
|
||||||
.key( 'D', Tags.Items.DYES )
|
.define( 'D', Tags.Items.DYES )
|
||||||
.addCriterion( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||||
.build( add );
|
.save( add );
|
||||||
|
|
||||||
ShapedRecipeBuilder
|
ShapedRecipeBuilder
|
||||||
.shapedRecipe( Registry.ModBlocks.SPEAKER.get() )
|
.shaped( Registry.ModBlocks.SPEAKER.get() )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.patternLine( "#N#" )
|
.pattern( "#N#" )
|
||||||
.patternLine( "#R#" )
|
.pattern( "#R#" )
|
||||||
.key( '#', Tags.Items.STONE )
|
.define( '#', Tags.Items.STONE )
|
||||||
.key( 'N', Blocks.NOTE_BLOCK )
|
.define( 'N', Blocks.NOTE_BLOCK )
|
||||||
.key( 'R', Tags.Items.DUSTS_REDSTONE )
|
.define( 'R', Tags.Items.DUSTS_REDSTONE )
|
||||||
.addCriterion( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||||
.build( add );
|
.save( add );
|
||||||
|
|
||||||
ShapedRecipeBuilder
|
ShapedRecipeBuilder
|
||||||
.shapedRecipe( Registry.ModItems.WIRED_MODEM.get() )
|
.shaped( Registry.ModItems.WIRED_MODEM.get() )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.patternLine( "#R#" )
|
.pattern( "#R#" )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.key( '#', Tags.Items.STONE )
|
.define( '#', Tags.Items.STONE )
|
||||||
.key( 'R', Tags.Items.DUSTS_REDSTONE )
|
.define( 'R', Tags.Items.DUSTS_REDSTONE )
|
||||||
.addCriterion( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||||
.addCriterion( "has_cable", inventoryChange( Registry.ModItems.CABLE.get() ) )
|
.unlocks( "has_cable", inventoryChange( Registry.ModItems.CABLE.get() ) )
|
||||||
.build( add );
|
.save( add );
|
||||||
|
|
||||||
ShapelessRecipeBuilder
|
ShapelessRecipeBuilder
|
||||||
.shapelessRecipe( Registry.ModBlocks.WIRED_MODEM_FULL.get() )
|
.shapeless( Registry.ModBlocks.WIRED_MODEM_FULL.get() )
|
||||||
.addIngredient( Registry.ModItems.WIRED_MODEM.get() )
|
.requires( Registry.ModItems.WIRED_MODEM.get() )
|
||||||
.addCriterion( "has_modem", inventoryChange( CCTags.WIRED_MODEM ) )
|
.unlocks( "has_modem", inventoryChange( CCTags.WIRED_MODEM ) )
|
||||||
.build( add, new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem_full_from" ) );
|
.save( add, new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem_full_from" ) );
|
||||||
ShapelessRecipeBuilder
|
ShapelessRecipeBuilder
|
||||||
.shapelessRecipe( Registry.ModItems.WIRED_MODEM.get() )
|
.shapeless( Registry.ModItems.WIRED_MODEM.get() )
|
||||||
.addIngredient( Registry.ModBlocks.WIRED_MODEM_FULL.get() )
|
.requires( Registry.ModBlocks.WIRED_MODEM_FULL.get() )
|
||||||
.addCriterion( "has_modem", inventoryChange( CCTags.WIRED_MODEM ) )
|
.unlocks( "has_modem", inventoryChange( CCTags.WIRED_MODEM ) )
|
||||||
.build( add, new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem_full_to" ) );
|
.save( add, new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem_full_to" ) );
|
||||||
|
|
||||||
ShapedRecipeBuilder
|
ShapedRecipeBuilder
|
||||||
.shapedRecipe( Registry.ModBlocks.WIRELESS_MODEM_NORMAL.get() )
|
.shaped( Registry.ModBlocks.WIRELESS_MODEM_NORMAL.get() )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.patternLine( "#E#" )
|
.pattern( "#E#" )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.key( '#', Tags.Items.STONE )
|
.define( '#', Tags.Items.STONE )
|
||||||
.key( 'E', Tags.Items.ENDER_PEARLS )
|
.define( 'E', Tags.Items.ENDER_PEARLS )
|
||||||
.addCriterion( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||||
.build( add );
|
.save( add );
|
||||||
|
|
||||||
ShapedRecipeBuilder
|
ShapedRecipeBuilder
|
||||||
.shapedRecipe( Registry.ModBlocks.WIRELESS_MODEM_ADVANCED.get() )
|
.shaped( Registry.ModBlocks.WIRELESS_MODEM_ADVANCED.get() )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.patternLine( "#E#" )
|
.pattern( "#E#" )
|
||||||
.patternLine( "###" )
|
.pattern( "###" )
|
||||||
.key( '#', Tags.Items.INGOTS_GOLD )
|
.define( '#', Tags.Items.INGOTS_GOLD )
|
||||||
.key( 'E', Items.ENDER_EYE )
|
.define( 'E', Items.ENDER_EYE )
|
||||||
.addCriterion( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||||
.addCriterion( "has_wireless", inventoryChange( Registry.ModBlocks.WIRELESS_MODEM_NORMAL.get() ) )
|
.unlocks( "has_wireless", inventoryChange( Registry.ModBlocks.WIRELESS_MODEM_NORMAL.get() ) )
|
||||||
.build( add );
|
.save( add );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DyeColor ofColour( Colour colour )
|
private static DyeColor ofColour( Colour colour )
|
||||||
@ -312,11 +312,11 @@ public class Recipes extends RecipeProvider
|
|||||||
|
|
||||||
private static InventoryChangeTrigger.Instance inventoryChange( Tag<Item> stack )
|
private static InventoryChangeTrigger.Instance inventoryChange( Tag<Item> stack )
|
||||||
{
|
{
|
||||||
return InventoryChangeTrigger.Instance.forItems( ItemPredicate.Builder.create().tag( stack ).build() );
|
return InventoryChangeTrigger.Instance.hasItem( ItemPredicate.Builder.item().of( stack ).build() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static InventoryChangeTrigger.Instance inventoryChange( IItemProvider... stack )
|
private static InventoryChangeTrigger.Instance inventoryChange( IItemProvider... stack )
|
||||||
{
|
{
|
||||||
return InventoryChangeTrigger.Instance.forItems( stack );
|
return InventoryChangeTrigger.Instance.hasItem( stack );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,15 +32,15 @@ public class Tags extends ItemTagsProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerTags()
|
protected void addTags()
|
||||||
{
|
{
|
||||||
getBuilder( COMPUTER )
|
tag( COMPUTER )
|
||||||
.add( Registry.ModItems.COMPUTER_NORMAL.get() )
|
.add( Registry.ModItems.COMPUTER_NORMAL.get() )
|
||||||
.add( Registry.ModItems.COMPUTER_ADVANCED.get() )
|
.add( Registry.ModItems.COMPUTER_ADVANCED.get() )
|
||||||
.add( Registry.ModItems.COMPUTER_COMMAND.get() );
|
.add( Registry.ModItems.COMPUTER_COMMAND.get() );
|
||||||
getBuilder( TURTLE ).add( Registry.ModItems.TURTLE_NORMAL.get(), Registry.ModItems.TURTLE_ADVANCED.get() );
|
tag( TURTLE ).add( Registry.ModItems.TURTLE_NORMAL.get(), Registry.ModItems.TURTLE_ADVANCED.get() );
|
||||||
getBuilder( WIRED_MODEM ).add( Registry.ModItems.WIRED_MODEM.get(), Registry.ModItems.WIRED_MODEM_FULL.get() );
|
tag( WIRED_MODEM ).add( Registry.ModItems.WIRED_MODEM.get(), Registry.ModItems.WIRED_MODEM_FULL.get() );
|
||||||
getBuilder( MONITOR )
|
tag( MONITOR )
|
||||||
.add( Registry.ModItems.MONITOR_NORMAL.get() )
|
.add( Registry.ModItems.MONITOR_NORMAL.get() )
|
||||||
.add( Registry.ModItems.MONITOR_ADVANCED.get() );
|
.add( Registry.ModItems.MONITOR_ADVANCED.get() );
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,12 @@ public final class BundledRedstone
|
|||||||
|
|
||||||
public static int getDefaultOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side )
|
public static int getDefaultOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side )
|
||||||
{
|
{
|
||||||
return World.isValid( pos ) ? DefaultBundledRedstoneProvider.getDefaultBundledRedstoneOutput( world, pos, side ) : -1;
|
return World.isInWorldBounds( pos ) ? DefaultBundledRedstoneProvider.getDefaultBundledRedstoneOutput( world, pos, side ) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getUnmaskedOutput( World world, BlockPos pos, Direction side )
|
private static int getUnmaskedOutput( World world, BlockPos pos, Direction side )
|
||||||
{
|
{
|
||||||
if( !World.isValid( pos ) ) return -1;
|
if( !World.isInWorldBounds( pos ) ) return -1;
|
||||||
|
|
||||||
// Try the providers in order:
|
// Try the providers in order:
|
||||||
int combinedSignal = -1;
|
int combinedSignal = -1;
|
||||||
|
@ -31,6 +31,9 @@ import java.util.stream.Collectors;
|
|||||||
import static net.minecraftforge.common.ForgeConfigSpec.Builder;
|
import static net.minecraftforge.common.ForgeConfigSpec.Builder;
|
||||||
import static net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
|
import static net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.ForgeConfigSpec.Builder;
|
||||||
|
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD )
|
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD )
|
||||||
public final class Config
|
public final class Config
|
||||||
{
|
{
|
||||||
|
@ -40,13 +40,13 @@ public final class Peripherals
|
|||||||
@Nullable
|
@Nullable
|
||||||
public static IPeripheral getPeripheral( World world, BlockPos pos, Direction side, NonNullConsumer<LazyOptional<IPeripheral>> invalidate )
|
public static IPeripheral getPeripheral( World world, BlockPos pos, Direction side, NonNullConsumer<LazyOptional<IPeripheral>> invalidate )
|
||||||
{
|
{
|
||||||
return World.isValid( pos ) && !world.isRemote ? getPeripheralAt( world, pos, side, invalidate ) : null;
|
return World.isInWorldBounds( pos ) && !world.isClientSide ? getPeripheralAt( world, pos, side, invalidate ) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static IPeripheral getPeripheralAt( World world, BlockPos pos, Direction side, NonNullConsumer<LazyOptional<IPeripheral>> invalidate )
|
private static IPeripheral getPeripheralAt( World world, BlockPos pos, Direction side, NonNullConsumer<LazyOptional<IPeripheral>> invalidate )
|
||||||
{
|
{
|
||||||
TileEntity block = world.getTileEntity( pos );
|
TileEntity block = world.getBlockEntity( pos );
|
||||||
if( block != null )
|
if( block != null )
|
||||||
{
|
{
|
||||||
LazyOptional<IPeripheral> peripheral = block.getCapability( CAPABILITY_PERIPHERAL, side );
|
LazyOptional<IPeripheral> peripheral = block.getCapability( CAPABILITY_PERIPHERAL, side );
|
||||||
|
@ -96,17 +96,17 @@ public final class Registry
|
|||||||
|
|
||||||
private static Block.Properties properties()
|
private static Block.Properties properties()
|
||||||
{
|
{
|
||||||
return Block.Properties.create( Material.ROCK ).hardnessAndResistance( 2 );
|
return Block.Properties.of( Material.STONE ).strength( 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Block.Properties turtleProperties()
|
private static Block.Properties turtleProperties()
|
||||||
{
|
{
|
||||||
return Block.Properties.create( Material.ROCK ).hardnessAndResistance( 2.5f );
|
return Block.Properties.of( Material.STONE ).strength( 2.5f );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Block.Properties modemProperties()
|
private static Block.Properties modemProperties()
|
||||||
{
|
{
|
||||||
return Block.Properties.create( Material.ROCK ).hardnessAndResistance( 1.5f );
|
return Block.Properties.of( Material.STONE ).strength( 1.5f );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final RegistryObject<BlockComputer> COMPUTER_NORMAL = BLOCKS.register( "computer_normal",
|
public static final RegistryObject<BlockComputer> COMPUTER_NORMAL = BLOCKS.register( "computer_normal",
|
||||||
@ -115,7 +115,7 @@ public final class Registry
|
|||||||
() -> new BlockComputer( properties(), ComputerFamily.ADVANCED, ModTiles.COMPUTER_ADVANCED ) );
|
() -> new BlockComputer( properties(), ComputerFamily.ADVANCED, ModTiles.COMPUTER_ADVANCED ) );
|
||||||
|
|
||||||
public static final RegistryObject<BlockComputer> COMPUTER_COMMAND = BLOCKS.register( "computer_command", () -> new BlockComputer(
|
public static final RegistryObject<BlockComputer> COMPUTER_COMMAND = BLOCKS.register( "computer_command", () -> new BlockComputer(
|
||||||
Block.Properties.create( Material.ROCK ).hardnessAndResistance( -1, 6000000.0F ),
|
Block.Properties.of( Material.STONE ).strength( -1, 6000000.0F ),
|
||||||
ComputerFamily.COMMAND, ModTiles.COMPUTER_COMMAND
|
ComputerFamily.COMMAND, ModTiles.COMPUTER_COMMAND
|
||||||
) );
|
) );
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ public final class Registry
|
|||||||
|
|
||||||
private static Item.Properties properties()
|
private static Item.Properties properties()
|
||||||
{
|
{
|
||||||
return new Item.Properties().group( mainItemGroup );
|
return new Item.Properties().tab( mainItemGroup );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <B extends Block, I extends Item> RegistryObject<I> ofBlock( RegistryObject<B> parent, BiFunction<B, Item.Properties, I> supplier )
|
private static <B extends Block, I extends Item> RegistryObject<I> ofBlock( RegistryObject<B> parent, BiFunction<B, Item.Properties, I> supplier )
|
||||||
@ -200,24 +200,24 @@ public final class Registry
|
|||||||
public static final RegistryObject<ItemComputer> COMPUTER_COMMAND = ofBlock( ModBlocks.COMPUTER_COMMAND, ItemComputer::new );
|
public static final RegistryObject<ItemComputer> COMPUTER_COMMAND = ofBlock( ModBlocks.COMPUTER_COMMAND, ItemComputer::new );
|
||||||
|
|
||||||
public static final RegistryObject<ItemPocketComputer> POCKET_COMPUTER_NORMAL = ITEMS.register( "pocket_computer_normal",
|
public static final RegistryObject<ItemPocketComputer> POCKET_COMPUTER_NORMAL = ITEMS.register( "pocket_computer_normal",
|
||||||
() -> new ItemPocketComputer( properties().maxStackSize( 1 ), ComputerFamily.NORMAL ) );
|
() -> new ItemPocketComputer( properties().stacksTo( 1 ), ComputerFamily.NORMAL ) );
|
||||||
public static final RegistryObject<ItemPocketComputer> POCKET_COMPUTER_ADVANCED = ITEMS.register( "pocket_computer_advanced",
|
public static final RegistryObject<ItemPocketComputer> POCKET_COMPUTER_ADVANCED = ITEMS.register( "pocket_computer_advanced",
|
||||||
() -> new ItemPocketComputer( properties().maxStackSize( 1 ), ComputerFamily.ADVANCED ) );
|
() -> new ItemPocketComputer( properties().stacksTo( 1 ), ComputerFamily.ADVANCED ) );
|
||||||
|
|
||||||
public static final RegistryObject<ItemTurtle> TURTLE_NORMAL = ofBlock( ModBlocks.TURTLE_NORMAL, ItemTurtle::new );
|
public static final RegistryObject<ItemTurtle> TURTLE_NORMAL = ofBlock( ModBlocks.TURTLE_NORMAL, ItemTurtle::new );
|
||||||
public static final RegistryObject<ItemTurtle> TURTLE_ADVANCED = ofBlock( ModBlocks.TURTLE_ADVANCED, ItemTurtle::new );
|
public static final RegistryObject<ItemTurtle> TURTLE_ADVANCED = ofBlock( ModBlocks.TURTLE_ADVANCED, ItemTurtle::new );
|
||||||
|
|
||||||
public static final RegistryObject<ItemDisk> DISK =
|
public static final RegistryObject<ItemDisk> DISK =
|
||||||
ITEMS.register( "disk", () -> new ItemDisk( properties().maxStackSize( 1 ) ) );
|
ITEMS.register( "disk", () -> new ItemDisk( properties().stacksTo( 1 ) ) );
|
||||||
public static final RegistryObject<ItemTreasureDisk> TREASURE_DISK =
|
public static final RegistryObject<ItemTreasureDisk> TREASURE_DISK =
|
||||||
ITEMS.register( "treasure_disk", () -> new ItemTreasureDisk( properties().maxStackSize( 1 ) ) );
|
ITEMS.register( "treasure_disk", () -> new ItemTreasureDisk( properties().stacksTo( 1 ) ) );
|
||||||
|
|
||||||
public static final RegistryObject<ItemPrintout> PRINTED_PAGE = ITEMS.register( "printed_page",
|
public static final RegistryObject<ItemPrintout> PRINTED_PAGE = ITEMS.register( "printed_page",
|
||||||
() -> new ItemPrintout( properties().maxStackSize( 1 ), ItemPrintout.Type.PAGE ) );
|
() -> new ItemPrintout( properties().stacksTo( 1 ), ItemPrintout.Type.PAGE ) );
|
||||||
public static final RegistryObject<ItemPrintout> PRINTED_PAGES = ITEMS.register( "printed_pages",
|
public static final RegistryObject<ItemPrintout> PRINTED_PAGES = ITEMS.register( "printed_pages",
|
||||||
() -> new ItemPrintout( properties().maxStackSize( 1 ), ItemPrintout.Type.PAGES ) );
|
() -> new ItemPrintout( properties().stacksTo( 1 ), ItemPrintout.Type.PAGES ) );
|
||||||
public static final RegistryObject<ItemPrintout> PRINTED_BOOK = ITEMS.register( "printed_book",
|
public static final RegistryObject<ItemPrintout> PRINTED_BOOK = ITEMS.register( "printed_book",
|
||||||
() -> new ItemPrintout( properties().maxStackSize( 1 ), ItemPrintout.Type.BOOK ) );
|
() -> new ItemPrintout( properties().stacksTo( 1 ), ItemPrintout.Type.BOOK ) );
|
||||||
|
|
||||||
public static final RegistryObject<BlockItem> SPEAKER = ofBlock( ModBlocks.SPEAKER, BlockItem::new );
|
public static final RegistryObject<BlockItem> SPEAKER = ofBlock( ModBlocks.SPEAKER, BlockItem::new );
|
||||||
public static final RegistryObject<BlockItem> DISK_DRIVE = ofBlock( ModBlocks.DISK_DRIVE, BlockItem::new );
|
public static final RegistryObject<BlockItem> DISK_DRIVE = ofBlock( ModBlocks.DISK_DRIVE, BlockItem::new );
|
||||||
@ -284,10 +284,10 @@ public final class Registry
|
|||||||
static final DeferredRegister<EntityType<?>> ENTITIES = new DeferredRegister<>( ForgeRegistries.ENTITIES, ComputerCraft.MOD_ID );
|
static final DeferredRegister<EntityType<?>> ENTITIES = new DeferredRegister<>( ForgeRegistries.ENTITIES, ComputerCraft.MOD_ID );
|
||||||
|
|
||||||
public static final RegistryObject<EntityType<TurtlePlayer>> TURTLE_PLAYER = ENTITIES.register( "turtle_player", () ->
|
public static final RegistryObject<EntityType<TurtlePlayer>> TURTLE_PLAYER = ENTITIES.register( "turtle_player", () ->
|
||||||
EntityType.Builder.<TurtlePlayer>create( EntityClassification.MISC )
|
EntityType.Builder.<TurtlePlayer>createNothing( EntityClassification.MISC )
|
||||||
.disableSerialization()
|
.noSave()
|
||||||
.disableSummoning()
|
.noSummon()
|
||||||
.size( 0, 0 )
|
.sized( 0, 0 )
|
||||||
.build( ComputerCraft.MOD_ID + ":turtle_player" ) );
|
.build( ComputerCraft.MOD_ID + ":turtle_player" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,13 +20,13 @@ public final class TurtlePermissions
|
|||||||
public static boolean isBlockEnterable( World world, BlockPos pos, PlayerEntity player )
|
public static boolean isBlockEnterable( World world, BlockPos pos, PlayerEntity player )
|
||||||
{
|
{
|
||||||
MinecraftServer server = world.getServer();
|
MinecraftServer server = world.getServer();
|
||||||
return server == null || world.isRemote || !server.isBlockProtected( world, pos, player );
|
return server == null || world.isClientSide || !server.isUnderSpawnProtection( world, pos, player );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isBlockEditable( World world, BlockPos pos, PlayerEntity player )
|
public static boolean isBlockEditable( World world, BlockPos pos, PlayerEntity player )
|
||||||
{
|
{
|
||||||
MinecraftServer server = world.getServer();
|
MinecraftServer server = world.getServer();
|
||||||
return server == null || world.isRemote || !server.isBlockProtected( world, pos, player );
|
return server == null || world.isClientSide || !server.isUnderSpawnProtection( world, pos, player );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
@ -75,13 +75,13 @@ public final class CommandComputerCraft
|
|||||||
List<ServerComputer> computers = new ArrayList<>( ComputerCraft.serverComputerRegistry.getComputers() );
|
List<ServerComputer> computers = new ArrayList<>( ComputerCraft.serverComputerRegistry.getComputers() );
|
||||||
|
|
||||||
// Unless we're on a server, limit the number of rows we can send.
|
// Unless we're on a server, limit the number of rows we can send.
|
||||||
World world = source.getWorld();
|
World world = source.getLevel();
|
||||||
BlockPos pos = new BlockPos( source.getPos() );
|
BlockPos pos = new BlockPos( source.getPosition() );
|
||||||
|
|
||||||
computers.sort( ( a, b ) -> {
|
computers.sort( ( a, b ) -> {
|
||||||
if( a.getWorld() == b.getWorld() && a.getWorld() == world )
|
if( a.getWorld() == b.getWorld() && a.getWorld() == world )
|
||||||
{
|
{
|
||||||
return Double.compare( a.getPosition().distanceSq( pos ), b.getPosition().distanceSq( pos ) );
|
return Double.compare( a.getPosition().distSqr( pos ), b.getPosition().distSqr( pos ) );
|
||||||
}
|
}
|
||||||
else if( a.getWorld() == world )
|
else if( a.getWorld() == world )
|
||||||
{
|
{
|
||||||
@ -145,7 +145,7 @@ public final class CommandComputerCraft
|
|||||||
if( computer.isOn() ) shutdown++;
|
if( computer.isOn() ) shutdown++;
|
||||||
computer.shutdown();
|
computer.shutdown();
|
||||||
}
|
}
|
||||||
context.getSource().sendFeedback( translate( "commands.computercraft.shutdown.done", shutdown, computers.size() ), false );
|
context.getSource().sendSuccess( translate( "commands.computercraft.shutdown.done", shutdown, computers.size() ), false );
|
||||||
return shutdown;
|
return shutdown;
|
||||||
} ) )
|
} ) )
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ public final class CommandComputerCraft
|
|||||||
if( !computer.isOn() ) on++;
|
if( !computer.isOn() ) on++;
|
||||||
computer.turnOn();
|
computer.turnOn();
|
||||||
}
|
}
|
||||||
context.getSource().sendFeedback( translate( "commands.computercraft.turn_on.done", on, computers.size() ), false );
|
context.getSource().sendSuccess( translate( "commands.computercraft.turn_on.done", on, computers.size() ), false );
|
||||||
return on;
|
return on;
|
||||||
} ) )
|
} ) )
|
||||||
|
|
||||||
@ -173,20 +173,20 @@ public final class CommandComputerCraft
|
|||||||
|
|
||||||
if( world == null || pos == null ) throw TP_NOT_THERE.create();
|
if( world == null || pos == null ) throw TP_NOT_THERE.create();
|
||||||
|
|
||||||
Entity entity = context.getSource().assertIsEntity();
|
Entity entity = context.getSource().getEntityOrException();
|
||||||
if( !(entity instanceof ServerPlayerEntity) ) throw TP_NOT_PLAYER.create();
|
if( !(entity instanceof ServerPlayerEntity) ) throw TP_NOT_PLAYER.create();
|
||||||
|
|
||||||
ServerPlayerEntity player = (ServerPlayerEntity) entity;
|
ServerPlayerEntity player = (ServerPlayerEntity) entity;
|
||||||
if( player.getEntityWorld() == world )
|
if( player.getCommandSenderWorld() == world )
|
||||||
{
|
{
|
||||||
player.connection.setPlayerLocation(
|
player.connection.teleport(
|
||||||
pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0,
|
pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0,
|
||||||
EnumSet.noneOf( SPlayerPositionLookPacket.Flags.class )
|
EnumSet.noneOf( SPlayerPositionLookPacket.Flags.class )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player.teleport( (ServerWorld) world,
|
player.teleportTo( (ServerWorld) world,
|
||||||
pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0
|
pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ public final class CommandComputerCraft
|
|||||||
.requires( UserLevel.OP )
|
.requires( UserLevel.OP )
|
||||||
.arg( "computer", oneComputer() )
|
.arg( "computer", oneComputer() )
|
||||||
.executes( context -> {
|
.executes( context -> {
|
||||||
ServerPlayerEntity player = context.getSource().asPlayer();
|
ServerPlayerEntity player = context.getSource().getPlayerOrException();
|
||||||
ServerComputer computer = getComputerArgument( context, "computer" );
|
ServerComputer computer = getComputerArgument( context, "computer" );
|
||||||
new ViewComputerContainerData( computer ).open( player, new INamedContainerProvider()
|
new ViewComputerContainerData( computer ).open( player, new INamedContainerProvider()
|
||||||
{
|
{
|
||||||
@ -247,7 +247,7 @@ public final class CommandComputerCraft
|
|||||||
getTimingContext( context.getSource() ).start();
|
getTimingContext( context.getSource() ).start();
|
||||||
|
|
||||||
String stopCommand = "/computercraft track stop";
|
String stopCommand = "/computercraft track stop";
|
||||||
context.getSource().sendFeedback( translate( "commands.computercraft.track.start.stop",
|
context.getSource().sendSuccess( translate( "commands.computercraft.track.start.stop",
|
||||||
link( text( stopCommand ), stopCommand, translate( "commands.computercraft.track.stop.action" ) ) ), false );
|
link( text( stopCommand ), stopCommand, translate( "commands.computercraft.track.stop.action" ) ) ), false );
|
||||||
return 1;
|
return 1;
|
||||||
} ) )
|
} ) )
|
||||||
@ -288,11 +288,11 @@ public final class CommandComputerCraft
|
|||||||
// Append the computer instance
|
// Append the computer instance
|
||||||
if( serverComputer == null )
|
if( serverComputer == null )
|
||||||
{
|
{
|
||||||
out.appendSibling( text( "?" ) );
|
out.append( text( "?" ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
out.appendSibling( link(
|
out.append( link(
|
||||||
text( Integer.toString( serverComputer.getInstanceID() ) ),
|
text( Integer.toString( serverComputer.getInstanceID() ) ),
|
||||||
"/computercraft dump " + serverComputer.getInstanceID(),
|
"/computercraft dump " + serverComputer.getInstanceID(),
|
||||||
translate( "commands.computercraft.dump.action" )
|
translate( "commands.computercraft.dump.action" )
|
||||||
@ -300,20 +300,20 @@ public final class CommandComputerCraft
|
|||||||
}
|
}
|
||||||
|
|
||||||
// And ID
|
// And ID
|
||||||
out.appendText( " (id " + computerId + ")" );
|
out.append( " (id " + computerId + ")" );
|
||||||
|
|
||||||
// And, if we're a player, some useful links
|
// And, if we're a player, some useful links
|
||||||
if( serverComputer != null && UserLevel.OP.test( source ) && isPlayer( source ) )
|
if( serverComputer != null && UserLevel.OP.test( source ) && isPlayer( source ) )
|
||||||
{
|
{
|
||||||
out
|
out
|
||||||
.appendText( " " )
|
.append( " " )
|
||||||
.appendSibling( link(
|
.append( link(
|
||||||
text( "\u261b" ),
|
text( "\u261b" ),
|
||||||
"/computercraft tp " + serverComputer.getInstanceID(),
|
"/computercraft tp " + serverComputer.getInstanceID(),
|
||||||
translate( "commands.computercraft.tp.action" )
|
translate( "commands.computercraft.tp.action" )
|
||||||
) )
|
) )
|
||||||
.appendText( " " )
|
.append( " " )
|
||||||
.appendSibling( link(
|
.append( link(
|
||||||
text( "\u20e2" ),
|
text( "\u20e2" ),
|
||||||
"/computercraft view " + serverComputer.getInstanceID(),
|
"/computercraft view " + serverComputer.getInstanceID(),
|
||||||
translate( "commands.computercraft.view.action" )
|
translate( "commands.computercraft.view.action" )
|
||||||
@ -343,7 +343,7 @@ public final class CommandComputerCraft
|
|||||||
private static TrackingContext getTimingContext( CommandSource source )
|
private static TrackingContext getTimingContext( CommandSource source )
|
||||||
{
|
{
|
||||||
Entity entity = source.getEntity();
|
Entity entity = source.getEntity();
|
||||||
return entity instanceof PlayerEntity ? Tracking.getContext( entity.getUniqueID() ) : Tracking.getContext( SYSTEM_UUID );
|
return entity instanceof PlayerEntity ? Tracking.getContext( entity.getUUID() ) : Tracking.getContext( SYSTEM_UUID );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final List<TrackingField> DEFAULT_FIELDS = Arrays.asList( TrackingField.TASKS, TrackingField.TOTAL_TIME, TrackingField.AVERAGE_TIME, TrackingField.MAX_TIME );
|
private static final List<TrackingField> DEFAULT_FIELDS = Arrays.asList( TrackingField.TASKS, TrackingField.TOTAL_TIME, TrackingField.AVERAGE_TIME, TrackingField.MAX_TIME );
|
||||||
|
@ -38,7 +38,7 @@ public final class CommandCopy
|
|||||||
.then( literal( "copy" ) )
|
.then( literal( "copy" ) )
|
||||||
.then( argument( "message", StringArgumentType.greedyString() ) )
|
.then( argument( "message", StringArgumentType.greedyString() ) )
|
||||||
.executes( context -> {
|
.executes( context -> {
|
||||||
Minecraft.getInstance().keyboardListener.setClipboardString( context.getArgument( "message", String.class ) );
|
Minecraft.getInstance().keyboardHandler.setClipboard( context.getArgument( "message", String.class ) );
|
||||||
return 1;
|
return 1;
|
||||||
} )
|
} )
|
||||||
);
|
);
|
||||||
@ -50,7 +50,7 @@ public final class CommandCopy
|
|||||||
// Emulate the command on the client side
|
// Emulate the command on the client side
|
||||||
if( event.getMessage().startsWith( PREFIX ) )
|
if( event.getMessage().startsWith( PREFIX ) )
|
||||||
{
|
{
|
||||||
Minecraft.getInstance().keyboardListener.setClipboardString( event.getMessage().substring( PREFIX.length() ) );
|
Minecraft.getInstance().keyboardHandler.setClipboard( event.getMessage().substring( PREFIX.length() ) );
|
||||||
event.setCanceled( true );
|
event.setCanceled( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public final class CommandUtils
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ((ISuggestionProvider) source).getSuggestionsFromServer( (CommandContext<ISuggestionProvider>) context, builder );
|
return ((ISuggestionProvider) source).customSuggestion( (CommandContext<ISuggestionProvider>) context, builder );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,12 +61,12 @@ public enum UserLevel implements Predicate<CommandSource>
|
|||||||
MinecraftServer server = source.getServer();
|
MinecraftServer server = source.getServer();
|
||||||
Entity sender = source.getEntity();
|
Entity sender = source.getEntity();
|
||||||
|
|
||||||
if( server.isSinglePlayer() && sender instanceof PlayerEntity &&
|
if( server.isSingleplayer() && sender instanceof PlayerEntity &&
|
||||||
((PlayerEntity) sender).getGameProfile().getName().equalsIgnoreCase( server.getServerModName() ) )
|
((PlayerEntity) sender).getGameProfile().getName().equalsIgnoreCase( server.getServerModName() ) )
|
||||||
{
|
{
|
||||||
if( this == OWNER || this == OWNER_OP ) return true;
|
if( this == OWNER || this == OWNER_OP ) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return source.hasPermissionLevel( toLevel() );
|
return source.hasPermission( toLevel() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,20 +175,20 @@ public final class ComputersArgumentType implements ArgumentType<ComputersArgume
|
|||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write( @Nonnull ComputersArgumentType arg, @Nonnull PacketBuffer buf )
|
public void serializeToNetwork( @Nonnull ComputersArgumentType arg, @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
buf.writeBoolean( arg.requireSome );
|
buf.writeBoolean( arg.requireSome );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ComputersArgumentType read( @Nonnull PacketBuffer buf )
|
public ComputersArgumentType deserializeFromNetwork( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
return buf.readBoolean() ? SOME : MANY;
|
return buf.readBoolean() ? SOME : MANY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write( @Nonnull ComputersArgumentType arg, @Nonnull JsonObject json )
|
public void serializeToJson( @Nonnull ComputersArgumentType arg, @Nonnull JsonObject json )
|
||||||
{
|
{
|
||||||
json.addProperty( "requireSome", arg.requireSome );
|
json.addProperty( "requireSome", arg.requireSome );
|
||||||
}
|
}
|
||||||
|
@ -128,27 +128,27 @@ public final class RepeatArgumentType<T, U> implements ArgumentType<List<T>>
|
|||||||
public static class Serializer implements IArgumentSerializer<RepeatArgumentType<?, ?>>
|
public static class Serializer implements IArgumentSerializer<RepeatArgumentType<?, ?>>
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void write( @Nonnull RepeatArgumentType<?, ?> arg, @Nonnull PacketBuffer buf )
|
public void serializeToNetwork( @Nonnull RepeatArgumentType<?, ?> arg, @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
buf.writeBoolean( arg.flatten );
|
buf.writeBoolean( arg.flatten );
|
||||||
ArgumentTypes.serialize( buf, arg.child );
|
ArgumentTypes.serialize( buf, arg.child );
|
||||||
buf.writeTextComponent( getMessage( arg ) );
|
buf.writeComponent( getMessage( arg ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings( { "unchecked", "rawtypes" } )
|
@SuppressWarnings( { "unchecked", "rawtypes" } )
|
||||||
public RepeatArgumentType<?, ?> read( @Nonnull PacketBuffer buf )
|
public RepeatArgumentType<?, ?> deserializeFromNetwork( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
boolean isList = buf.readBoolean();
|
boolean isList = buf.readBoolean();
|
||||||
ArgumentType<?> child = ArgumentTypes.deserialize( buf );
|
ArgumentType<?> child = ArgumentTypes.deserialize( buf );
|
||||||
ITextComponent message = buf.readTextComponent();
|
ITextComponent message = buf.readComponent();
|
||||||
BiConsumer<List<Object>, ?> appender = isList ? ( list, x ) -> list.addAll( (Collection) x ) : List::add;
|
BiConsumer<List<Object>, ?> appender = isList ? ( list, x ) -> list.addAll( (Collection) x ) : List::add;
|
||||||
return new RepeatArgumentType( child, appender, isList, new SimpleCommandExceptionType( message ) );
|
return new RepeatArgumentType( child, appender, isList, new SimpleCommandExceptionType( message ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write( @Nonnull RepeatArgumentType<?, ?> arg, @Nonnull JsonObject json )
|
public void serializeToJson( @Nonnull RepeatArgumentType<?, ?> arg, @Nonnull JsonObject json )
|
||||||
{
|
{
|
||||||
json.addProperty( "flatten", arg.flatten );
|
json.addProperty( "flatten", arg.flatten );
|
||||||
json.addProperty( "child", "<<cannot serialize>>" ); // TODO: Potentially serialize this using reflection.
|
json.addProperty( "child", "<<cannot serialize>>" ); // TODO: Potentially serialize this using reflection.
|
||||||
|
@ -151,7 +151,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<Command
|
|||||||
@Override
|
@Override
|
||||||
public int run( CommandContext<CommandSource> context )
|
public int run( CommandContext<CommandSource> context )
|
||||||
{
|
{
|
||||||
context.getSource().sendFeedback( getHelp( context, node, id, command ), false );
|
context.getSource().sendSuccess( getHelp( context, node, id, command ), false );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<Command
|
|||||||
private static Command<CommandSource> helpForChild( CommandNode<CommandSource> node, String id, String command )
|
private static Command<CommandSource> helpForChild( CommandNode<CommandSource> node, String id, String command )
|
||||||
{
|
{
|
||||||
return context -> {
|
return context -> {
|
||||||
context.getSource().sendFeedback( getHelp( context, node, id + "." + node.getName().replace( '-', '_' ), command + " " + node.getName() ), false );
|
context.getSource().sendSuccess( getHelp( context, node, id + "." + node.getName().replace( '-', '_' ), command + " " + node.getName() ), false );
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -168,17 +168,17 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<Command
|
|||||||
{
|
{
|
||||||
// An ugly hack to extract usage information from the dispatcher. We generate a temporary node, generate
|
// An ugly hack to extract usage information from the dispatcher. We generate a temporary node, generate
|
||||||
// the shorthand usage, and emit that.
|
// the shorthand usage, and emit that.
|
||||||
CommandDispatcher<CommandSource> dispatcher = context.getSource().getServer().getCommandManager().getDispatcher();
|
CommandDispatcher<CommandSource> dispatcher = context.getSource().getServer().getCommands().getDispatcher();
|
||||||
CommandNode<CommandSource> temp = new LiteralCommandNode<>( "_", null, x -> true, null, null, false );
|
CommandNode<CommandSource> temp = new LiteralCommandNode<>( "_", null, x -> true, null, null, false );
|
||||||
temp.addChild( node );
|
temp.addChild( node );
|
||||||
String usage = dispatcher.getSmartUsage( temp, context.getSource() ).get( node ).substring( node.getName().length() );
|
String usage = dispatcher.getSmartUsage( temp, context.getSource() ).get( node ).substring( node.getName().length() );
|
||||||
|
|
||||||
ITextComponent output = new StringTextComponent( "" )
|
ITextComponent output = new StringTextComponent( "" )
|
||||||
.appendSibling( coloured( "/" + command + usage, HEADER ) )
|
.append( coloured( "/" + command + usage, HEADER ) )
|
||||||
.appendText( " " )
|
.append( " " )
|
||||||
.appendSibling( coloured( translate( "commands." + id + ".synopsis" ), SYNOPSIS ) )
|
.append( coloured( translate( "commands." + id + ".synopsis" ), SYNOPSIS ) )
|
||||||
.appendText( "\n" )
|
.append( "\n" )
|
||||||
.appendSibling( translate( "commands." + id + ".desc" ) );
|
.append( translate( "commands." + id + ".desc" ) );
|
||||||
|
|
||||||
for( CommandNode<CommandSource> child : node.getChildren() )
|
for( CommandNode<CommandSource> child : node.getChildren() )
|
||||||
{
|
{
|
||||||
@ -187,16 +187,16 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<Command
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
output.appendText( "\n" );
|
output.append( "\n" );
|
||||||
|
|
||||||
ITextComponent component = coloured( child.getName(), NAME );
|
ITextComponent component = coloured( child.getName(), NAME );
|
||||||
component.getStyle().setClickEvent( new ClickEvent(
|
component.getStyle().setClickEvent( new ClickEvent(
|
||||||
ClickEvent.Action.SUGGEST_COMMAND,
|
ClickEvent.Action.SUGGEST_COMMAND,
|
||||||
"/" + command + " " + child.getName()
|
"/" + command + " " + child.getName()
|
||||||
) );
|
) );
|
||||||
output.appendSibling( component );
|
output.append( component );
|
||||||
|
|
||||||
output.appendText( " - " ).appendSibling( translate( "commands." + id + "." + child.getName() + ".synopsis" ) );
|
output.append( " - " ).append( translate( "commands." + id + "." + child.getName() + ".synopsis" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
@ -52,7 +52,7 @@ public final class ChatHelpers
|
|||||||
ITextComponent component = new StringTextComponent( "" );
|
ITextComponent component = new StringTextComponent( "" );
|
||||||
for( ITextComponent child : children )
|
for( ITextComponent child : children )
|
||||||
{
|
{
|
||||||
component.appendSibling( child );
|
component.append( child );
|
||||||
}
|
}
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,6 @@ public class ServerTableFormatter implements TableFormatter
|
|||||||
@Override
|
@Override
|
||||||
public void writeLine( int id, ITextComponent component )
|
public void writeLine( int id, ITextComponent component )
|
||||||
{
|
{
|
||||||
source.sendFeedback( component, false );
|
source.sendSuccess( component, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,12 +79,12 @@ public interface TableFormatter
|
|||||||
StringTextComponent line = new StringTextComponent( "" );
|
StringTextComponent line = new StringTextComponent( "" );
|
||||||
for( int i = 0; i < columns - 1; i++ )
|
for( int i = 0; i < columns - 1; i++ )
|
||||||
{
|
{
|
||||||
line.appendSibling( headers[i] );
|
line.append( headers[i] );
|
||||||
ITextComponent padding = getPadding( headers[i], maxWidths[i] );
|
ITextComponent padding = getPadding( headers[i], maxWidths[i] );
|
||||||
if( padding != null ) line.appendSibling( padding );
|
if( padding != null ) line.append( padding );
|
||||||
line.appendSibling( SEPARATOR );
|
line.append( SEPARATOR );
|
||||||
}
|
}
|
||||||
line.appendSibling( headers[columns - 1] );
|
line.append( headers[columns - 1] );
|
||||||
|
|
||||||
writeLine( rowId++, line );
|
writeLine( rowId++, line );
|
||||||
|
|
||||||
@ -100,12 +100,12 @@ public interface TableFormatter
|
|||||||
StringTextComponent line = new StringTextComponent( "" );
|
StringTextComponent line = new StringTextComponent( "" );
|
||||||
for( int i = 0; i < columns - 1; i++ )
|
for( int i = 0; i < columns - 1; i++ )
|
||||||
{
|
{
|
||||||
line.appendSibling( row[i] );
|
line.append( row[i] );
|
||||||
ITextComponent padding = getPadding( row[i], maxWidths[i] );
|
ITextComponent padding = getPadding( row[i], maxWidths[i] );
|
||||||
if( padding != null ) line.appendSibling( padding );
|
if( padding != null ) line.append( padding );
|
||||||
line.appendSibling( SEPARATOR );
|
line.append( SEPARATOR );
|
||||||
}
|
}
|
||||||
line.appendSibling( row[columns - 1] );
|
line.append( row[columns - 1] );
|
||||||
writeLine( rowId++, line );
|
writeLine( rowId++, line );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ import javax.annotation.Nonnull;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block.Properties;
|
||||||
|
|
||||||
public abstract class BlockGeneric extends Block
|
public abstract class BlockGeneric extends Block
|
||||||
{
|
{
|
||||||
private final RegistryObject<? extends TileEntityType<? extends TileGeneric>> type;
|
private final RegistryObject<? extends TileEntityType<? extends TileGeneric>> type;
|
||||||
@ -36,22 +38,22 @@ public abstract class BlockGeneric extends Block
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public final void onReplaced( @Nonnull BlockState block, @Nonnull World world, @Nonnull BlockPos pos, BlockState replace, boolean bool )
|
public final void onRemove( @Nonnull BlockState block, @Nonnull World world, @Nonnull BlockPos pos, BlockState replace, boolean bool )
|
||||||
{
|
{
|
||||||
if( block.getBlock() == replace.getBlock() ) return;
|
if( block.getBlock() == replace.getBlock() ) return;
|
||||||
|
|
||||||
TileEntity tile = world.getTileEntity( pos );
|
TileEntity tile = world.getBlockEntity( pos );
|
||||||
super.onReplaced( block, world, pos, replace, bool );
|
super.onRemove( block, world, pos, replace, bool );
|
||||||
world.removeTileEntity( pos );
|
world.removeBlockEntity( pos );
|
||||||
if( tile instanceof TileGeneric ) ((TileGeneric) tile).destroy();
|
if( tile instanceof TileGeneric ) ((TileGeneric) tile).destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public final ActionResultType onBlockActivated( @Nonnull BlockState state, World world, @Nonnull BlockPos pos, @Nonnull PlayerEntity player, @Nonnull Hand hand, @Nonnull BlockRayTraceResult hit )
|
public final ActionResultType use( @Nonnull BlockState state, World world, @Nonnull BlockPos pos, @Nonnull PlayerEntity player, @Nonnull Hand hand, @Nonnull BlockRayTraceResult hit )
|
||||||
{
|
{
|
||||||
TileEntity tile = world.getTileEntity( pos );
|
TileEntity tile = world.getBlockEntity( pos );
|
||||||
return tile instanceof TileGeneric ? ((TileGeneric) tile).onActivate( player, hand, hit ) : ActionResultType.PASS;
|
return tile instanceof TileGeneric ? ((TileGeneric) tile).onActivate( player, hand, hit ) : ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,14 +61,14 @@ public abstract class BlockGeneric extends Block
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public final void neighborChanged( @Nonnull BlockState state, World world, @Nonnull BlockPos pos, @Nonnull Block neighbourBlock, @Nonnull BlockPos neighbourPos, boolean isMoving )
|
public final void neighborChanged( @Nonnull BlockState state, World world, @Nonnull BlockPos pos, @Nonnull Block neighbourBlock, @Nonnull BlockPos neighbourPos, boolean isMoving )
|
||||||
{
|
{
|
||||||
TileEntity tile = world.getTileEntity( pos );
|
TileEntity tile = world.getBlockEntity( pos );
|
||||||
if( tile instanceof TileGeneric ) ((TileGeneric) tile).onNeighbourChange( neighbourPos );
|
if( tile instanceof TileGeneric ) ((TileGeneric) tile).onNeighbourChange( neighbourPos );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onNeighborChange( BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbour )
|
public final void onNeighborChange( BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbour )
|
||||||
{
|
{
|
||||||
TileEntity tile = world.getTileEntity( pos );
|
TileEntity tile = world.getBlockEntity( pos );
|
||||||
if( tile instanceof TileGeneric ) ((TileGeneric) tile).onNeighbourTileEntityChange( neighbour );
|
if( tile instanceof TileGeneric ) ((TileGeneric) tile).onNeighbourTileEntityChange( neighbour );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +76,7 @@ public abstract class BlockGeneric extends Block
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public void tick( @Nonnull BlockState state, ServerWorld world, @Nonnull BlockPos pos, @Nonnull Random rand )
|
public void tick( @Nonnull BlockState state, ServerWorld world, @Nonnull BlockPos pos, @Nonnull Random rand )
|
||||||
{
|
{
|
||||||
TileEntity te = world.getTileEntity( pos );
|
TileEntity te = world.getBlockEntity( pos );
|
||||||
if( te instanceof TileGeneric ) ((TileGeneric) te).blockTick();
|
if( te instanceof TileGeneric ) ((TileGeneric) te).blockTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,9 +30,9 @@ public final class ColourableRecipe extends SpecialRecipe
|
|||||||
{
|
{
|
||||||
boolean hasColourable = false;
|
boolean hasColourable = false;
|
||||||
boolean hasDye = false;
|
boolean hasDye = false;
|
||||||
for( int i = 0; i < inv.getSizeInventory(); i++ )
|
for( int i = 0; i < inv.getContainerSize(); i++ )
|
||||||
{
|
{
|
||||||
ItemStack stack = inv.getStackInSlot( i );
|
ItemStack stack = inv.getItem( i );
|
||||||
if( stack.isEmpty() ) continue;
|
if( stack.isEmpty() ) continue;
|
||||||
|
|
||||||
if( stack.getItem() instanceof IColouredItem )
|
if( stack.getItem() instanceof IColouredItem )
|
||||||
@ -55,15 +55,15 @@ public final class ColourableRecipe extends SpecialRecipe
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getCraftingResult( @Nonnull CraftingInventory inv )
|
public ItemStack assemble( @Nonnull CraftingInventory inv )
|
||||||
{
|
{
|
||||||
ItemStack colourable = ItemStack.EMPTY;
|
ItemStack colourable = ItemStack.EMPTY;
|
||||||
|
|
||||||
ColourTracker tracker = new ColourTracker();
|
ColourTracker tracker = new ColourTracker();
|
||||||
|
|
||||||
for( int i = 0; i < inv.getSizeInventory(); i++ )
|
for( int i = 0; i < inv.getContainerSize(); i++ )
|
||||||
{
|
{
|
||||||
ItemStack stack = inv.getStackInSlot( i );
|
ItemStack stack = inv.getItem( i );
|
||||||
|
|
||||||
if( stack.isEmpty() ) continue;
|
if( stack.isEmpty() ) continue;
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ public final class ColourableRecipe extends SpecialRecipe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canFit( int x, int y )
|
public boolean canCraftInDimensions( int x, int y )
|
||||||
{
|
{
|
||||||
return x >= 2 && y >= 2;
|
return x >= 2 && y >= 2;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public class ContainerHeldItem extends Container
|
|||||||
super( type, id );
|
super( type, id );
|
||||||
|
|
||||||
this.hand = hand;
|
this.hand = hand;
|
||||||
stack = player.getHeldItem( hand ).copy();
|
stack = player.getItemInHand( hand ).copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ContainerHeldItem createPrintout( int id, PlayerInventory inventory, HeldItemContainerData data )
|
public static ContainerHeldItem createPrintout( int id, PlayerInventory inventory, HeldItemContainerData data )
|
||||||
@ -44,11 +44,11 @@ public class ContainerHeldItem extends Container
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteractWith( @Nonnull PlayerEntity player )
|
public boolean stillValid( @Nonnull PlayerEntity player )
|
||||||
{
|
{
|
||||||
if( !player.isAlive() ) return false;
|
if( !player.isAlive() ) return false;
|
||||||
|
|
||||||
ItemStack stack = player.getHeldItem( hand );
|
ItemStack stack = player.getItemInHand( hand );
|
||||||
return stack == this.stack || !stack.isEmpty() && !this.stack.isEmpty() && stack.getItem() == this.stack.getItem();
|
return stack == this.stack || !stack.isEmpty() && !this.stack.isEmpty() && stack.getItem() == this.stack.getItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ public class ContainerHeldItem extends Container
|
|||||||
public Factory( ContainerType<ContainerHeldItem> type, ItemStack stack, Hand hand )
|
public Factory( ContainerType<ContainerHeldItem> type, ItemStack stack, Hand hand )
|
||||||
{
|
{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.name = stack.getDisplayName();
|
this.name = stack.getHoverName();
|
||||||
this.hand = hand;
|
this.hand = hand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,10 +32,10 @@ public abstract class TileGeneric extends TileEntity
|
|||||||
|
|
||||||
public final void updateBlock()
|
public final void updateBlock()
|
||||||
{
|
{
|
||||||
markDirty();
|
setChanged();
|
||||||
BlockPos pos = getPos();
|
BlockPos pos = getBlockPos();
|
||||||
BlockState state = getBlockState();
|
BlockState state = getBlockState();
|
||||||
getWorld().notifyBlockUpdate( pos, state, state, 3 );
|
getLevel().sendBlockUpdated( pos, state, state, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -63,13 +63,13 @@ public abstract class TileGeneric extends TileEntity
|
|||||||
|
|
||||||
public boolean isUsable( PlayerEntity player, boolean ignoreRange )
|
public boolean isUsable( PlayerEntity player, boolean ignoreRange )
|
||||||
{
|
{
|
||||||
if( player == null || !player.isAlive() || getWorld().getTileEntity( getPos() ) != this ) return false;
|
if( player == null || !player.isAlive() || getLevel().getBlockEntity( getBlockPos() ) != this ) return false;
|
||||||
if( ignoreRange ) return true;
|
if( ignoreRange ) return true;
|
||||||
|
|
||||||
double range = getInteractRange( player );
|
double range = getInteractRange( player );
|
||||||
BlockPos pos = getPos();
|
BlockPos pos = getBlockPos();
|
||||||
return player.getEntityWorld() == getWorld() &&
|
return player.getCommandSenderWorld() == getLevel() &&
|
||||||
player.getDistanceSq( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ) <= range * range;
|
player.distanceToSqr( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ) <= range * range;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeDescription( @Nonnull CompoundNBT nbt )
|
protected void writeDescription( @Nonnull CompoundNBT nbt )
|
||||||
@ -86,13 +86,13 @@ public abstract class TileGeneric extends TileEntity
|
|||||||
{
|
{
|
||||||
CompoundNBT nbt = new CompoundNBT();
|
CompoundNBT nbt = new CompoundNBT();
|
||||||
writeDescription( nbt );
|
writeDescription( nbt );
|
||||||
return new SUpdateTileEntityPacket( pos, 0, nbt );
|
return new SUpdateTileEntityPacket( worldPosition, 0, nbt );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onDataPacket( NetworkManager net, SUpdateTileEntityPacket packet )
|
public final void onDataPacket( NetworkManager net, SUpdateTileEntityPacket packet )
|
||||||
{
|
{
|
||||||
if( packet.getTileEntityType() == 0 ) readDescription( packet.getNbtCompound() );
|
if( packet.getType() == 0 ) readDescription( packet.getTag() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -48,18 +48,18 @@ public class CommandAPI implements ILuaAPI
|
|||||||
|
|
||||||
private Object[] doCommand( String command )
|
private Object[] doCommand( String command )
|
||||||
{
|
{
|
||||||
MinecraftServer server = computer.getWorld().getServer();
|
MinecraftServer server = computer.getLevel().getServer();
|
||||||
if( server == null || !server.isCommandBlockEnabled() )
|
if( server == null || !server.isCommandBlockEnabled() )
|
||||||
{
|
{
|
||||||
return new Object[] { false, createOutput( "Command blocks disabled by server" ) };
|
return new Object[] { false, createOutput( "Command blocks disabled by server" ) };
|
||||||
}
|
}
|
||||||
|
|
||||||
Commands commandManager = server.getCommandManager();
|
Commands commandManager = server.getCommands();
|
||||||
TileCommandComputer.CommandReceiver receiver = computer.getReceiver();
|
TileCommandComputer.CommandReceiver receiver = computer.getReceiver();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
receiver.clearOutput();
|
receiver.clearOutput();
|
||||||
int result = commandManager.handleCommand( computer.getSource(), command );
|
int result = commandManager.performCommand( computer.getSource(), command );
|
||||||
return new Object[] { result > 0, receiver.copyOutput(), result };
|
return new Object[] { result > 0, receiver.copyOutput(), result };
|
||||||
}
|
}
|
||||||
catch( Throwable t )
|
catch( Throwable t )
|
||||||
@ -75,8 +75,8 @@ public class CommandAPI implements ILuaAPI
|
|||||||
BlockState state = world.getBlockState( pos );
|
BlockState state = world.getBlockState( pos );
|
||||||
Map<String, Object> table = BlockData.fill( new HashMap<>(), state );
|
Map<String, Object> table = BlockData.fill( new HashMap<>(), state );
|
||||||
|
|
||||||
TileEntity tile = world.getTileEntity( pos );
|
TileEntity tile = world.getBlockEntity( pos );
|
||||||
if( tile != null ) table.put( "nbt", NBTUtil.toLua( tile.write( new CompoundNBT() ) ) );
|
if( tile != null ) table.put( "nbt", NBTUtil.toLua( tile.save( new CompoundNBT() ) ) );
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
@ -139,10 +139,10 @@ public class CommandAPI implements ILuaAPI
|
|||||||
@LuaFunction( mainThread = true )
|
@LuaFunction( mainThread = true )
|
||||||
public final List<String> list( IArguments args ) throws LuaException
|
public final List<String> list( IArguments args ) throws LuaException
|
||||||
{
|
{
|
||||||
MinecraftServer server = computer.getWorld().getServer();
|
MinecraftServer server = computer.getLevel().getServer();
|
||||||
|
|
||||||
if( server == null ) return Collections.emptyList();
|
if( server == null ) return Collections.emptyList();
|
||||||
CommandNode<CommandSource> node = server.getCommandManager().getDispatcher().getRoot();
|
CommandNode<CommandSource> node = server.getCommands().getDispatcher().getRoot();
|
||||||
for( int j = 0; j < args.count(); j++ )
|
for( int j = 0; j < args.count(); j++ )
|
||||||
{
|
{
|
||||||
String name = args.getString( j );
|
String name = args.getString( j );
|
||||||
@ -171,7 +171,7 @@ public class CommandAPI implements ILuaAPI
|
|||||||
public final Object[] getBlockPosition()
|
public final Object[] getBlockPosition()
|
||||||
{
|
{
|
||||||
// This is probably safe to do on the Lua thread. Probably.
|
// This is probably safe to do on the Lua thread. Probably.
|
||||||
BlockPos pos = computer.getPos();
|
BlockPos pos = computer.getBlockPos();
|
||||||
return new Object[] { pos.getX(), pos.getY(), pos.getZ() };
|
return new Object[] { pos.getX(), pos.getY(), pos.getZ() };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ public class CommandAPI implements ILuaAPI
|
|||||||
public final List<Map<?, ?>> getBlockInfos( int minX, int minY, int minZ, int maxX, int maxY, int maxZ ) throws LuaException
|
public final List<Map<?, ?>> getBlockInfos( int minX, int minY, int minZ, int maxX, int maxY, int maxZ ) throws LuaException
|
||||||
{
|
{
|
||||||
// Get the details of the block
|
// Get the details of the block
|
||||||
World world = computer.getWorld();
|
World world = computer.getLevel();
|
||||||
BlockPos min = new BlockPos(
|
BlockPos min = new BlockPos(
|
||||||
Math.min( minX, maxX ),
|
Math.min( minX, maxX ),
|
||||||
Math.min( minY, maxY ),
|
Math.min( minY, maxY ),
|
||||||
@ -209,7 +209,7 @@ public class CommandAPI implements ILuaAPI
|
|||||||
Math.max( minY, maxY ),
|
Math.max( minY, maxY ),
|
||||||
Math.max( minZ, maxZ )
|
Math.max( minZ, maxZ )
|
||||||
);
|
);
|
||||||
if( !World.isValid( min ) || !World.isValid( max ) )
|
if( !World.isInWorldBounds( min ) || !World.isInWorldBounds( max ) )
|
||||||
{
|
{
|
||||||
throw new LuaException( "Co-ordinates out of range" );
|
throw new LuaException( "Co-ordinates out of range" );
|
||||||
}
|
}
|
||||||
@ -250,9 +250,9 @@ public class CommandAPI implements ILuaAPI
|
|||||||
public final Map<?, ?> getBlockInfo( int x, int y, int z ) throws LuaException
|
public final Map<?, ?> getBlockInfo( int x, int y, int z ) throws LuaException
|
||||||
{
|
{
|
||||||
// Get the details of the block
|
// Get the details of the block
|
||||||
World world = computer.getWorld();
|
World world = computer.getLevel();
|
||||||
BlockPos position = new BlockPos( x, y, z );
|
BlockPos position = new BlockPos( x, y, z );
|
||||||
if( World.isValid( position ) )
|
if( World.isInWorldBounds( position ) )
|
||||||
{
|
{
|
||||||
return getBlockInfo( world, position );
|
return getBlockInfo( world, position );
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@ import net.minecraftforge.fml.RegistryObject;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block.Properties;
|
||||||
|
|
||||||
public class BlockComputer extends BlockComputerBase<TileComputer>
|
public class BlockComputer extends BlockComputerBase<TileComputer>
|
||||||
{
|
{
|
||||||
public static final EnumProperty<ComputerState> STATE = EnumProperty.create( "state", ComputerState.class );
|
public static final EnumProperty<ComputerState> STATE = EnumProperty.create( "state", ComputerState.class );
|
||||||
@ -31,14 +33,14 @@ public class BlockComputer extends BlockComputerBase<TileComputer>
|
|||||||
public BlockComputer( Properties settings, ComputerFamily family, RegistryObject<? extends TileEntityType<? extends TileComputer>> type )
|
public BlockComputer( Properties settings, ComputerFamily family, RegistryObject<? extends TileEntityType<? extends TileComputer>> type )
|
||||||
{
|
{
|
||||||
super( settings, family, type );
|
super( settings, family, type );
|
||||||
setDefaultState( getDefaultState()
|
registerDefaultState( defaultBlockState()
|
||||||
.with( FACING, Direction.NORTH )
|
.setValue( FACING, Direction.NORTH )
|
||||||
.with( STATE, ComputerState.OFF )
|
.setValue( STATE, ComputerState.OFF )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void fillStateContainer( StateContainer.Builder<Block, BlockState> builder )
|
protected void createBlockStateDefinition( StateContainer.Builder<Block, BlockState> builder )
|
||||||
{
|
{
|
||||||
builder.add( FACING, STATE );
|
builder.add( FACING, STATE );
|
||||||
}
|
}
|
||||||
@ -47,7 +49,7 @@ public class BlockComputer extends BlockComputerBase<TileComputer>
|
|||||||
@Override
|
@Override
|
||||||
public BlockState getStateForPlacement( BlockItemUseContext placement )
|
public BlockState getStateForPlacement( BlockItemUseContext placement )
|
||||||
{
|
{
|
||||||
return getDefaultState().with( FACING, placement.getPlacementHorizontalFacing().getOpposite() );
|
return defaultBlockState().setValue( FACING, placement.getHorizontalDirection().getOpposite() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -34,6 +34,8 @@ import net.minecraftforge.fml.RegistryObject;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block.Properties;
|
||||||
|
|
||||||
public abstract class BlockComputerBase<T extends TileComputerBase> extends BlockGeneric implements IBundledRedstoneBlock
|
public abstract class BlockComputerBase<T extends TileComputerBase> extends BlockGeneric implements IBundledRedstoneBlock
|
||||||
{
|
{
|
||||||
private static final ResourceLocation DROP = new ResourceLocation( ComputerCraft.MOD_ID, "computer" );
|
private static final ResourceLocation DROP = new ResourceLocation( ComputerCraft.MOD_ID, "computer" );
|
||||||
@ -48,26 +50,26 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void onBlockAdded( @Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState oldState, boolean isMoving )
|
public void onPlace( @Nonnull BlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState oldState, boolean isMoving )
|
||||||
{
|
{
|
||||||
super.onBlockAdded( state, world, pos, oldState, isMoving );
|
super.onPlace( state, world, pos, oldState, isMoving );
|
||||||
|
|
||||||
TileEntity tile = world.getTileEntity( pos );
|
TileEntity tile = world.getBlockEntity( pos );
|
||||||
if( tile instanceof TileComputerBase ) ((TileComputerBase) tile).updateInput();
|
if( tile instanceof TileComputerBase ) ((TileComputerBase) tile).updateInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean canProvidePower( @Nonnull BlockState state )
|
public boolean isSignalSource( @Nonnull BlockState state )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int getStrongPower( @Nonnull BlockState state, IBlockReader world, @Nonnull BlockPos pos, @Nonnull Direction incomingSide )
|
public int getDirectSignal( @Nonnull BlockState state, IBlockReader world, @Nonnull BlockPos pos, @Nonnull Direction incomingSide )
|
||||||
{
|
{
|
||||||
TileEntity entity = world.getTileEntity( pos );
|
TileEntity entity = world.getBlockEntity( pos );
|
||||||
if( !(entity instanceof TileComputerBase) ) return 0;
|
if( !(entity instanceof TileComputerBase) ) return 0;
|
||||||
|
|
||||||
TileComputerBase computerEntity = (TileComputerBase) entity;
|
TileComputerBase computerEntity = (TileComputerBase) entity;
|
||||||
@ -88,9 +90,9 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int getWeakPower( @Nonnull BlockState state, @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull Direction incomingSide )
|
public int getSignal( @Nonnull BlockState state, @Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull Direction incomingSide )
|
||||||
{
|
{
|
||||||
return getStrongPower( state, world, pos, incomingSide );
|
return getDirectSignal( state, world, pos, incomingSide );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -102,7 +104,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
|||||||
@Override
|
@Override
|
||||||
public int getBundledRedstoneOutput( World world, BlockPos pos, Direction side )
|
public int getBundledRedstoneOutput( World world, BlockPos pos, Direction side )
|
||||||
{
|
{
|
||||||
TileEntity entity = world.getTileEntity( pos );
|
TileEntity entity = world.getBlockEntity( pos );
|
||||||
if( !(entity instanceof TileComputerBase) ) return 0;
|
if( !(entity instanceof TileComputerBase) ) return 0;
|
||||||
|
|
||||||
TileComputerBase computerEntity = (TileComputerBase) entity;
|
TileComputerBase computerEntity = (TileComputerBase) entity;
|
||||||
@ -117,7 +119,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getPickBlock( BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player )
|
public ItemStack getPickBlock( BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player )
|
||||||
{
|
{
|
||||||
TileEntity tile = world.getTileEntity( pos );
|
TileEntity tile = world.getBlockEntity( pos );
|
||||||
if( tile instanceof TileComputerBase )
|
if( tile instanceof TileComputerBase )
|
||||||
{
|
{
|
||||||
ItemStack result = getItem( (TileComputerBase) tile );
|
ItemStack result = getItem( (TileComputerBase) tile );
|
||||||
@ -128,48 +130,48 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void harvestBlock( @Nonnull World world, PlayerEntity player, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nullable TileEntity tile, @Nonnull ItemStack tool )
|
public void playerDestroy( @Nonnull World world, PlayerEntity player, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nullable TileEntity tile, @Nonnull ItemStack tool )
|
||||||
{
|
{
|
||||||
// Don't drop blocks here - see onBlockHarvested.
|
// Don't drop blocks here - see onBlockHarvested.
|
||||||
player.addStat( Stats.BLOCK_MINED.get( this ) );
|
player.awardStat( Stats.BLOCK_MINED.get( this ) );
|
||||||
player.addExhaustion( 0.005F );
|
player.causeFoodExhaustion( 0.005F );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockHarvested( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull PlayerEntity player )
|
public void playerWillDestroy( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull PlayerEntity player )
|
||||||
{
|
{
|
||||||
if( !(world instanceof ServerWorld) ) return;
|
if( !(world instanceof ServerWorld) ) return;
|
||||||
|
|
||||||
// We drop the item here instead of doing it in the harvest method, as we should
|
// We drop the item here instead of doing it in the harvest method, as we should
|
||||||
// drop computers for creative players too.
|
// drop computers for creative players too.
|
||||||
|
|
||||||
TileEntity tile = world.getTileEntity( pos );
|
TileEntity tile = world.getBlockEntity( pos );
|
||||||
if( tile instanceof TileComputerBase )
|
if( tile instanceof TileComputerBase )
|
||||||
{
|
{
|
||||||
TileComputerBase computer = (TileComputerBase) tile;
|
TileComputerBase computer = (TileComputerBase) tile;
|
||||||
LootContext.Builder context = new LootContext.Builder( (ServerWorld) world )
|
LootContext.Builder context = new LootContext.Builder( (ServerWorld) world )
|
||||||
.withRandom( world.rand )
|
.withRandom( world.random )
|
||||||
.withParameter( LootParameters.POSITION, pos )
|
.withParameter( LootParameters.BLOCK_POS, pos )
|
||||||
.withParameter( LootParameters.TOOL, player.getHeldItemMainhand() )
|
.withParameter( LootParameters.TOOL, player.getMainHandItem() )
|
||||||
.withParameter( LootParameters.THIS_ENTITY, player )
|
.withParameter( LootParameters.THIS_ENTITY, player )
|
||||||
.withNullableParameter( LootParameters.BLOCK_ENTITY, tile )
|
.withOptionalParameter( LootParameters.BLOCK_ENTITY, tile )
|
||||||
.withDynamicDrop( DROP, ( ctx, out ) -> out.accept( getItem( computer ) ) );
|
.withDynamicDrop( DROP, ( ctx, out ) -> out.accept( getItem( computer ) ) );
|
||||||
for( ItemStack item : state.getDrops( context ) )
|
for( ItemStack item : state.getDrops( context ) )
|
||||||
{
|
{
|
||||||
spawnAsEntity( world, pos, item );
|
popResource( world, pos, item );
|
||||||
}
|
}
|
||||||
|
|
||||||
state.spawnAdditionalDrops( world, pos, player.getHeldItemMainhand() );
|
state.spawnAfterBreak( world, pos, player.getMainHandItem() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, LivingEntity placer, @Nonnull ItemStack stack )
|
public void setPlacedBy( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, LivingEntity placer, @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
super.onBlockPlacedBy( world, pos, state, placer, stack );
|
super.setPlacedBy( world, pos, state, placer, stack );
|
||||||
|
|
||||||
TileEntity tile = world.getTileEntity( pos );
|
TileEntity tile = world.getBlockEntity( pos );
|
||||||
if( !world.isRemote && tile instanceof IComputerTile && stack.getItem() instanceof IComputerItem )
|
if( !world.isClientSide && tile instanceof IComputerTile && stack.getItem() instanceof IComputerItem )
|
||||||
{
|
{
|
||||||
IComputerTile computer = (IComputerTile) tile;
|
IComputerTile computer = (IComputerTile) tile;
|
||||||
IComputerItem item = (IComputerItem) stack.getItem();
|
IComputerItem item = (IComputerItem) stack.getItem();
|
||||||
|
@ -54,21 +54,21 @@ public class TileCommandComputer extends TileComputer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldReceiveFeedback()
|
public boolean acceptsSuccess()
|
||||||
{
|
{
|
||||||
return getWorld().getGameRules().getBoolean( GameRules.SEND_COMMAND_FEEDBACK );
|
return getLevel().getGameRules().getBoolean( GameRules.RULE_SENDCOMMANDFEEDBACK );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldReceiveErrors()
|
public boolean acceptsFailure()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean allowLogging()
|
public boolean shouldInformAdmins()
|
||||||
{
|
{
|
||||||
return getWorld().getGameRules().getBoolean( GameRules.COMMAND_BLOCK_OUTPUT );
|
return getLevel().getGameRules().getBoolean( GameRules.RULE_COMMANDBLOCKOUTPUT );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,10 +96,10 @@ public class TileCommandComputer extends TileComputer
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new CommandSource( receiver,
|
return new CommandSource( receiver,
|
||||||
new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ), Vec2f.ZERO,
|
new Vec3d( worldPosition.getX() + 0.5, worldPosition.getY() + 0.5, worldPosition.getZ() + 0.5 ), Vec2f.ZERO,
|
||||||
(ServerWorld) getWorld(), 2,
|
(ServerWorld) getLevel(), 2,
|
||||||
name, new StringTextComponent( name ),
|
name, new StringTextComponent( name ),
|
||||||
getWorld().getServer(), null
|
getLevel().getServer(), null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,12 +122,12 @@ public class TileCommandComputer extends TileComputer
|
|||||||
MinecraftServer server = player.getServer();
|
MinecraftServer server = player.getServer();
|
||||||
if( server == null || !server.isCommandBlockEnabled() )
|
if( server == null || !server.isCommandBlockEnabled() )
|
||||||
{
|
{
|
||||||
player.sendStatusMessage( new TranslationTextComponent( "advMode.notEnabled" ), true );
|
player.displayClientMessage( new TranslationTextComponent( "advMode.notEnabled" ), true );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if( ComputerCraft.commandRequireCreative ? !player.canUseCommandBlock() : !server.getPlayerList().canSendCommands( player.getGameProfile() ) )
|
else if( ComputerCraft.commandRequireCreative ? !player.canUseGameMasterBlocks() : !server.getPlayerList().isOp( player.getGameProfile() ) )
|
||||||
{
|
{
|
||||||
player.sendStatusMessage( new TranslationTextComponent( "advMode.notAllowed" ), true );
|
player.displayClientMessage( new TranslationTextComponent( "advMode.notAllowed" ), true );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,11 +42,11 @@ public class TileComputer extends TileComputerBase
|
|||||||
{
|
{
|
||||||
ComputerFamily family = getFamily();
|
ComputerFamily family = getFamily();
|
||||||
ServerComputer computer = new ServerComputer(
|
ServerComputer computer = new ServerComputer(
|
||||||
getWorld(), id, label, instanceID, family,
|
getLevel(), id, label, instanceID, family,
|
||||||
ComputerCraft.computerTermWidth,
|
ComputerCraft.computerTermWidth,
|
||||||
ComputerCraft.computerTermHeight
|
ComputerCraft.computerTermHeight
|
||||||
);
|
);
|
||||||
computer.setPosition( getPos() );
|
computer.setPosition( getBlockPos() );
|
||||||
return computer;
|
return computer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,16 +58,16 @@ public class TileComputer extends TileComputerBase
|
|||||||
@Override
|
@Override
|
||||||
public Direction getDirection()
|
public Direction getDirection()
|
||||||
{
|
{
|
||||||
return getBlockState().get( BlockComputer.FACING );
|
return getBlockState().getValue( BlockComputer.FACING );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateBlockState( ComputerState newState )
|
protected void updateBlockState( ComputerState newState )
|
||||||
{
|
{
|
||||||
BlockState existing = getBlockState();
|
BlockState existing = getBlockState();
|
||||||
if( existing.get( BlockComputer.STATE ) != newState )
|
if( existing.getValue( BlockComputer.STATE ) != newState )
|
||||||
{
|
{
|
||||||
getWorld().setBlockState( getPos(), existing.with( BlockComputer.STATE, newState ), 3 );
|
getLevel().setBlock( getBlockPos(), existing.setValue( BlockComputer.STATE, newState ), 3 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
{
|
{
|
||||||
if( m_instanceID >= 0 )
|
if( m_instanceID >= 0 )
|
||||||
{
|
{
|
||||||
if( !getWorld().isRemote ) ComputerCraft.serverComputerRegistry.remove( m_instanceID );
|
if( !getLevel().isClientSide ) ComputerCraft.serverComputerRegistry.remove( m_instanceID );
|
||||||
m_instanceID = -1;
|
m_instanceID = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
unload();
|
unload();
|
||||||
for( Direction dir : DirectionUtil.FACINGS )
|
for( Direction dir : DirectionUtil.FACINGS )
|
||||||
{
|
{
|
||||||
RedstoneUtil.propagateRedstoneOutput( getWorld(), getPos(), dir );
|
RedstoneUtil.propagateRedstoneOutput( getLevel(), getBlockPos(), dir );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,10 +102,10 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove()
|
public void setRemoved()
|
||||||
{
|
{
|
||||||
unload();
|
unload();
|
||||||
super.remove();
|
super.setRemoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canNameWithTag( PlayerEntity player )
|
protected boolean canNameWithTag( PlayerEntity player )
|
||||||
@ -117,13 +117,13 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
@Override
|
@Override
|
||||||
public ActionResultType onActivate( PlayerEntity player, Hand hand, BlockRayTraceResult hit )
|
public ActionResultType onActivate( PlayerEntity player, Hand hand, BlockRayTraceResult hit )
|
||||||
{
|
{
|
||||||
ItemStack currentItem = player.getHeldItem( hand );
|
ItemStack currentItem = player.getItemInHand( hand );
|
||||||
if( !currentItem.isEmpty() && currentItem.getItem() == Items.NAME_TAG && canNameWithTag( player ) && currentItem.hasDisplayName() )
|
if( !currentItem.isEmpty() && currentItem.getItem() == Items.NAME_TAG && canNameWithTag( player ) && currentItem.hasCustomHoverName() )
|
||||||
{
|
{
|
||||||
// Label to rename computer
|
// Label to rename computer
|
||||||
if( !getWorld().isRemote )
|
if( !getLevel().isClientSide )
|
||||||
{
|
{
|
||||||
setLabel( currentItem.getDisplayName().getString() );
|
setLabel( currentItem.getHoverName().getString() );
|
||||||
currentItem.shrink( 1 );
|
currentItem.shrink( 1 );
|
||||||
}
|
}
|
||||||
return ActionResultType.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
@ -131,7 +131,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
else if( !player.isCrouching() )
|
else if( !player.isCrouching() )
|
||||||
{
|
{
|
||||||
// Regular right click to activate computer
|
// Regular right click to activate computer
|
||||||
if( !getWorld().isRemote && isUsable( player, false ) )
|
if( !getLevel().isClientSide && isUsable( player, false ) )
|
||||||
{
|
{
|
||||||
createServerComputer().turnOn();
|
createServerComputer().turnOn();
|
||||||
new ComputerContainerData( createServerComputer() ).open( player, this );
|
new ComputerContainerData( createServerComputer() ).open( player, this );
|
||||||
@ -156,7 +156,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
@Override
|
@Override
|
||||||
public void tick()
|
public void tick()
|
||||||
{
|
{
|
||||||
if( !getWorld().isRemote )
|
if( !getLevel().isClientSide )
|
||||||
{
|
{
|
||||||
ServerComputer computer = createServerComputer();
|
ServerComputer computer = createServerComputer();
|
||||||
if( computer == null ) return;
|
if( computer == null ) return;
|
||||||
@ -189,20 +189,20 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public CompoundNBT write( @Nonnull CompoundNBT nbt )
|
public CompoundNBT save( @Nonnull CompoundNBT nbt )
|
||||||
{
|
{
|
||||||
// Save ID, label and power state
|
// Save ID, label and power state
|
||||||
if( m_computerID >= 0 ) nbt.putInt( NBT_ID, m_computerID );
|
if( m_computerID >= 0 ) nbt.putInt( NBT_ID, m_computerID );
|
||||||
if( label != null ) nbt.putString( NBT_LABEL, label );
|
if( label != null ) nbt.putString( NBT_LABEL, label );
|
||||||
nbt.putBoolean( NBT_ON, m_on );
|
nbt.putBoolean( NBT_ON, m_on );
|
||||||
|
|
||||||
return super.write( nbt );
|
return super.save( nbt );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read( @Nonnull CompoundNBT nbt )
|
public void load( @Nonnull CompoundNBT nbt )
|
||||||
{
|
{
|
||||||
super.read( nbt );
|
super.load( nbt );
|
||||||
|
|
||||||
// Load ID, label and power state
|
// Load ID, label and power state
|
||||||
m_computerID = nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
|
m_computerID = nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
|
||||||
@ -232,11 +232,11 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
Direction offsetSide = dir.getOpposite();
|
Direction offsetSide = dir.getOpposite();
|
||||||
ComputerSide localDir = remapToLocalSide( dir );
|
ComputerSide localDir = remapToLocalSide( dir );
|
||||||
|
|
||||||
computer.setRedstoneInput( localDir, getRedstoneInput( world, offset, dir ) );
|
computer.setRedstoneInput( localDir, getRedstoneInput( level, offset, dir ) );
|
||||||
computer.setBundledRedstoneInput( localDir, BundledRedstone.getOutput( getWorld(), offset, offsetSide ) );
|
computer.setBundledRedstoneInput( localDir, BundledRedstone.getOutput( getLevel(), offset, offsetSide ) );
|
||||||
if( !isPeripheralBlockedOnSide( localDir ) )
|
if( !isPeripheralBlockedOnSide( localDir ) )
|
||||||
{
|
{
|
||||||
IPeripheral peripheral = Peripherals.getPeripheral( getWorld(), offset, offsetSide, invalidate[dir.ordinal()] );
|
IPeripheral peripheral = Peripherals.getPeripheral( getLevel(), offset, offsetSide, invalidate[dir.ordinal()] );
|
||||||
computer.setPeripheral( localDir, peripheral );
|
computer.setPeripheral( localDir, peripheral );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,18 +252,18 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
*/
|
*/
|
||||||
protected static int getRedstoneInput( World world, BlockPos pos, Direction side )
|
protected static int getRedstoneInput( World world, BlockPos pos, Direction side )
|
||||||
{
|
{
|
||||||
int power = world.getRedstonePower( pos, side );
|
int power = world.getSignal( pos, side );
|
||||||
if( power >= 15 ) return power;
|
if( power >= 15 ) return power;
|
||||||
|
|
||||||
BlockState neighbour = world.getBlockState( pos );
|
BlockState neighbour = world.getBlockState( pos );
|
||||||
return neighbour.getBlock() == Blocks.REDSTONE_WIRE
|
return neighbour.getBlock() == Blocks.REDSTONE_WIRE
|
||||||
? Math.max( power, neighbour.get( RedstoneWireBlock.POWER ) )
|
? Math.max( power, neighbour.getValue( RedstoneWireBlock.POWER ) )
|
||||||
: power;
|
: power;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateInput()
|
public void updateInput()
|
||||||
{
|
{
|
||||||
if( getWorld() == null || getWorld().isRemote ) return;
|
if( getLevel() == null || getLevel().isClientSide ) return;
|
||||||
|
|
||||||
// Update all sides
|
// Update all sides
|
||||||
ServerComputer computer = getServerComputer();
|
ServerComputer computer = getServerComputer();
|
||||||
@ -272,20 +272,20 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
BlockPos pos = computer.getPosition();
|
BlockPos pos = computer.getPosition();
|
||||||
for( Direction dir : DirectionUtil.FACINGS )
|
for( Direction dir : DirectionUtil.FACINGS )
|
||||||
{
|
{
|
||||||
updateSideInput( computer, dir, pos.offset( dir ) );
|
updateSideInput( computer, dir, pos.relative( dir ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateInput( BlockPos neighbour )
|
private void updateInput( BlockPos neighbour )
|
||||||
{
|
{
|
||||||
if( getWorld() == null || getWorld().isRemote ) return;
|
if( getLevel() == null || getLevel().isClientSide ) return;
|
||||||
|
|
||||||
ServerComputer computer = getServerComputer();
|
ServerComputer computer = getServerComputer();
|
||||||
if( computer == null ) return;
|
if( computer == null ) return;
|
||||||
|
|
||||||
for( Direction dir : DirectionUtil.FACINGS )
|
for( Direction dir : DirectionUtil.FACINGS )
|
||||||
{
|
{
|
||||||
BlockPos offset = pos.offset( dir );
|
BlockPos offset = worldPosition.relative( dir );
|
||||||
if( offset.equals( neighbour ) )
|
if( offset.equals( neighbour ) )
|
||||||
{
|
{
|
||||||
updateSideInput( computer, dir, offset );
|
updateSideInput( computer, dir, offset );
|
||||||
@ -299,12 +299,12 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
|
|
||||||
private void updateInput( Direction dir )
|
private void updateInput( Direction dir )
|
||||||
{
|
{
|
||||||
if( getWorld() == null || getWorld().isRemote ) return;
|
if( getLevel() == null || getLevel().isClientSide ) return;
|
||||||
|
|
||||||
ServerComputer computer = getServerComputer();
|
ServerComputer computer = getServerComputer();
|
||||||
if( computer == null ) return;
|
if( computer == null ) return;
|
||||||
|
|
||||||
updateSideInput( computer, dir, pos.offset( dir ) );
|
updateSideInput( computer, dir, worldPosition.relative( dir ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateOutput()
|
public void updateOutput()
|
||||||
@ -313,7 +313,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
updateBlock();
|
updateBlock();
|
||||||
for( Direction dir : DirectionUtil.FACINGS )
|
for( Direction dir : DirectionUtil.FACINGS )
|
||||||
{
|
{
|
||||||
RedstoneUtil.propagateRedstoneOutput( getWorld(), getPos(), dir );
|
RedstoneUtil.propagateRedstoneOutput( getLevel(), getBlockPos(), dir );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,23 +334,23 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
@Override
|
@Override
|
||||||
public final void setComputerID( int id )
|
public final void setComputerID( int id )
|
||||||
{
|
{
|
||||||
if( getWorld().isRemote || m_computerID == id ) return;
|
if( getLevel().isClientSide || m_computerID == id ) return;
|
||||||
|
|
||||||
m_computerID = id;
|
m_computerID = id;
|
||||||
ServerComputer computer = getServerComputer();
|
ServerComputer computer = getServerComputer();
|
||||||
if( computer != null ) computer.setID( m_computerID );
|
if( computer != null ) computer.setID( m_computerID );
|
||||||
markDirty();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void setLabel( String label )
|
public final void setLabel( String label )
|
||||||
{
|
{
|
||||||
if( getWorld().isRemote || Objects.equals( this.label, label ) ) return;
|
if( getLevel().isClientSide || Objects.equals( this.label, label ) ) return;
|
||||||
|
|
||||||
this.label = label;
|
this.label = label;
|
||||||
ServerComputer computer = getServerComputer();
|
ServerComputer computer = getServerComputer();
|
||||||
if( computer != null ) computer.setLabel( label );
|
if( computer != null ) computer.setLabel( label );
|
||||||
markDirty();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -361,7 +361,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
|
|
||||||
public ServerComputer createServerComputer()
|
public ServerComputer createServerComputer()
|
||||||
{
|
{
|
||||||
if( getWorld().isRemote ) return null;
|
if( getLevel().isClientSide ) return null;
|
||||||
|
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
if( m_instanceID < 0 )
|
if( m_instanceID < 0 )
|
||||||
@ -386,7 +386,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
|
|
||||||
public ServerComputer getServerComputer()
|
public ServerComputer getServerComputer()
|
||||||
{
|
{
|
||||||
return getWorld().isRemote ? null : ComputerCraft.serverComputerRegistry.get( m_instanceID );
|
return getLevel().isClientSide ? null : ComputerCraft.serverComputerRegistry.get( m_instanceID );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Networking stuff
|
// Networking stuff
|
||||||
@ -428,7 +428,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
{
|
{
|
||||||
return hasCustomName()
|
return hasCustomName()
|
||||||
? new StringTextComponent( label )
|
? new StringTextComponent( label )
|
||||||
: new TranslationTextComponent( getBlockState().getBlock().getTranslationKey() );
|
: new TranslationTextComponent( getBlockState().getBlock().getDescriptionId() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,7 +24,7 @@ public enum ComputerState implements IStringSerializable
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getName()
|
public String getSerializedName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput
|
|||||||
{
|
{
|
||||||
if( player == null ) return null;
|
if( player == null ) return null;
|
||||||
|
|
||||||
Container container = player.openContainer;
|
Container container = player.containerMenu;
|
||||||
if( !(container instanceof IContainerComputer) ) return null;
|
if( !(container instanceof IContainerComputer) ) return null;
|
||||||
|
|
||||||
IContainerComputer computerContainer = (IContainerComputer) container;
|
IContainerComputer computerContainer = (IContainerComputer) container;
|
||||||
|
@ -40,7 +40,7 @@ public class ContainerComputerBase extends Container implements IContainerComput
|
|||||||
protected static IComputer getComputer( PlayerInventory player, ComputerContainerData data )
|
protected static IComputer getComputer( PlayerInventory player, ComputerContainerData data )
|
||||||
{
|
{
|
||||||
int id = data.getInstanceId();
|
int id = data.getInstanceId();
|
||||||
if( !player.player.world.isRemote ) return ComputerCraft.serverComputerRegistry.get( id );
|
if( !player.player.level.isClientSide ) return ComputerCraft.serverComputerRegistry.get( id );
|
||||||
|
|
||||||
ClientComputer computer = ComputerCraft.clientComputerRegistry.get( id );
|
ClientComputer computer = ComputerCraft.clientComputerRegistry.get( id );
|
||||||
if( computer == null ) ComputerCraft.clientComputerRegistry.add( id, computer = new ClientComputer( id ) );
|
if( computer == null ) ComputerCraft.clientComputerRegistry.add( id, computer = new ClientComputer( id ) );
|
||||||
@ -48,7 +48,7 @@ public class ContainerComputerBase extends Container implements IContainerComput
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteractWith( @Nonnull PlayerEntity player )
|
public boolean stillValid( @Nonnull PlayerEntity player )
|
||||||
{
|
{
|
||||||
return canUse.test( player );
|
return canUse.test( player );
|
||||||
}
|
}
|
||||||
@ -74,9 +74,9 @@ public class ContainerComputerBase extends Container implements IContainerComput
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onContainerClosed( @Nonnull PlayerEntity player )
|
public void removed( @Nonnull PlayerEntity player )
|
||||||
{
|
{
|
||||||
super.onContainerClosed( player );
|
super.removed( player );
|
||||||
input.close();
|
input.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ public interface IComputerItem
|
|||||||
|
|
||||||
default String getLabel( @Nonnull ItemStack stack )
|
default String getLabel( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
return stack.hasDisplayName() ? stack.getDisplayName().getString() : null;
|
return stack.hasCustomHoverName() ? stack.getHoverName().getString() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ComputerFamily getFamily();
|
ComputerFamily getFamily();
|
||||||
|
@ -12,6 +12,8 @@ import net.minecraft.util.text.StringTextComponent;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item.Properties;
|
||||||
|
|
||||||
public class ItemComputer extends ItemComputerBase
|
public class ItemComputer extends ItemComputerBase
|
||||||
{
|
{
|
||||||
public ItemComputer( BlockComputer block, Properties settings )
|
public ItemComputer( BlockComputer block, Properties settings )
|
||||||
@ -23,7 +25,7 @@ public class ItemComputer extends ItemComputerBase
|
|||||||
{
|
{
|
||||||
ItemStack result = new ItemStack( this );
|
ItemStack result = new ItemStack( this );
|
||||||
if( id >= 0 ) result.getOrCreateTag().putInt( NBT_ID, id );
|
if( id >= 0 ) result.getOrCreateTag().putInt( NBT_ID, id );
|
||||||
if( label != null ) result.setDisplayName( new StringTextComponent( label ) );
|
if( label != null ) result.setHoverName( new StringTextComponent( label ) );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +33,7 @@ public class ItemComputer extends ItemComputerBase
|
|||||||
public ItemStack withFamily( @Nonnull ItemStack stack, @Nonnull ComputerFamily family )
|
public ItemStack withFamily( @Nonnull ItemStack stack, @Nonnull ComputerFamily family )
|
||||||
{
|
{
|
||||||
ItemStack result = ComputerItemFactory.create( getComputerID( stack ), null, family );
|
ItemStack result = ComputerItemFactory.create( getComputerID( stack ), null, family );
|
||||||
if( stack.hasDisplayName() ) result.setDisplayName( stack.getDisplayName() );
|
if( stack.hasCustomHoverName() ) result.setHoverName( stack.getHoverName() );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,8 @@ import javax.annotation.Nonnull;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item.Properties;
|
||||||
|
|
||||||
public abstract class ItemComputerBase extends BlockItem implements IComputerItem, IMedia
|
public abstract class ItemComputerBase extends BlockItem implements IComputerItem, IMedia
|
||||||
{
|
{
|
||||||
private final ComputerFamily family;
|
private final ComputerFamily family;
|
||||||
@ -35,7 +37,7 @@ public abstract class ItemComputerBase extends BlockItem implements IComputerIte
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List<ITextComponent> list, @Nonnull ITooltipFlag options )
|
public void appendHoverText( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List<ITextComponent> list, @Nonnull ITooltipFlag options )
|
||||||
{
|
{
|
||||||
if( options.isAdvanced() || getLabel( stack ) == null )
|
if( options.isAdvanced() || getLabel( stack ) == null )
|
||||||
{
|
{
|
||||||
@ -43,7 +45,7 @@ public abstract class ItemComputerBase extends BlockItem implements IComputerIte
|
|||||||
if( id >= 0 )
|
if( id >= 0 )
|
||||||
{
|
{
|
||||||
list.add( new TranslationTextComponent( "gui.computercraft.tooltip.computer_id", id )
|
list.add( new TranslationTextComponent( "gui.computercraft.tooltip.computer_id", id )
|
||||||
.applyTextStyle( TextFormatting.GRAY ) );
|
.withStyle( TextFormatting.GRAY ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,11 +69,11 @@ public abstract class ItemComputerBase extends BlockItem implements IComputerIte
|
|||||||
{
|
{
|
||||||
if( label != null )
|
if( label != null )
|
||||||
{
|
{
|
||||||
stack.setDisplayName( new StringTextComponent( label ) );
|
stack.setHoverName( new StringTextComponent( label ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stack.clearCustomName();
|
stack.resetHoverName();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -37,9 +37,9 @@ public abstract class ComputerConvertRecipe extends ShapedRecipe
|
|||||||
{
|
{
|
||||||
if( !super.matches( inventory, world ) ) return false;
|
if( !super.matches( inventory, world ) ) return false;
|
||||||
|
|
||||||
for( int i = 0; i < inventory.getSizeInventory(); i++ )
|
for( int i = 0; i < inventory.getContainerSize(); i++ )
|
||||||
{
|
{
|
||||||
if( inventory.getStackInSlot( i ).getItem() instanceof IComputerItem ) return true;
|
if( inventory.getItem( i ).getItem() instanceof IComputerItem ) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -47,12 +47,12 @@ public abstract class ComputerConvertRecipe extends ShapedRecipe
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getCraftingResult( @Nonnull CraftingInventory inventory )
|
public ItemStack assemble( @Nonnull CraftingInventory inventory )
|
||||||
{
|
{
|
||||||
// Find our computer item and convert it.
|
// Find our computer item and convert it.
|
||||||
for( int i = 0; i < inventory.getSizeInventory(); i++ )
|
for( int i = 0; i < inventory.getContainerSize(); i++ )
|
||||||
{
|
{
|
||||||
ItemStack stack = inventory.getStackInSlot( i );
|
ItemStack stack = inventory.getItem( i );
|
||||||
if( stack.getItem() instanceof IComputerItem ) return convert( (IComputerItem) stack.getItem(), stack );
|
if( stack.getItem() instanceof IComputerItem ) return convert( (IComputerItem) stack.getItem(), stack );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,42 +39,42 @@ public abstract class ComputerFamilyRecipe extends ComputerConvertRecipe
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public T read( @Nonnull ResourceLocation identifier, @Nonnull JsonObject json )
|
public T fromJson( @Nonnull ResourceLocation identifier, @Nonnull JsonObject json )
|
||||||
{
|
{
|
||||||
String group = JSONUtils.getString( json, "group", "" );
|
String group = JSONUtils.getAsString( json, "group", "" );
|
||||||
ComputerFamily family = RecipeUtil.getFamily( json, "family" );
|
ComputerFamily family = RecipeUtil.getFamily( json, "family" );
|
||||||
|
|
||||||
RecipeUtil.ShapedTemplate template = RecipeUtil.getTemplate( json );
|
RecipeUtil.ShapedTemplate template = RecipeUtil.getTemplate( json );
|
||||||
ItemStack result = deserializeItem( JSONUtils.getJsonObject( json, "result" ) );
|
ItemStack result = itemFromJson( JSONUtils.getAsJsonObject( json, "result" ) );
|
||||||
|
|
||||||
return create( identifier, group, template.width, template.height, template.ingredients, result, family );
|
return create( identifier, group, template.width, template.height, template.ingredients, result, family );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public T read( @Nonnull ResourceLocation identifier, @Nonnull PacketBuffer buf )
|
public T fromNetwork( @Nonnull ResourceLocation identifier, @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
int width = buf.readVarInt();
|
int width = buf.readVarInt();
|
||||||
int height = buf.readVarInt();
|
int height = buf.readVarInt();
|
||||||
String group = buf.readString( Short.MAX_VALUE );
|
String group = buf.readUtf( Short.MAX_VALUE );
|
||||||
|
|
||||||
NonNullList<Ingredient> ingredients = NonNullList.withSize( width * height, Ingredient.EMPTY );
|
NonNullList<Ingredient> ingredients = NonNullList.withSize( width * height, Ingredient.EMPTY );
|
||||||
for( int i = 0; i < ingredients.size(); i++ ) ingredients.set( i, Ingredient.read( buf ) );
|
for( int i = 0; i < ingredients.size(); i++ ) ingredients.set( i, Ingredient.fromNetwork( buf ) );
|
||||||
|
|
||||||
ItemStack result = buf.readItemStack();
|
ItemStack result = buf.readItem();
|
||||||
ComputerFamily family = buf.readEnumValue( ComputerFamily.class );
|
ComputerFamily family = buf.readEnum( ComputerFamily.class );
|
||||||
return create( identifier, group, width, height, ingredients, result, family );
|
return create( identifier, group, width, height, ingredients, result, family );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write( @Nonnull PacketBuffer buf, @Nonnull T recipe )
|
public void toNetwork( @Nonnull PacketBuffer buf, @Nonnull T recipe )
|
||||||
{
|
{
|
||||||
buf.writeVarInt( recipe.getWidth() );
|
buf.writeVarInt( recipe.getWidth() );
|
||||||
buf.writeVarInt( recipe.getHeight() );
|
buf.writeVarInt( recipe.getHeight() );
|
||||||
buf.writeString( recipe.getGroup() );
|
buf.writeUtf( recipe.getGroup() );
|
||||||
for( Ingredient ingredient : recipe.getIngredients() ) ingredient.write( buf );
|
for( Ingredient ingredient : recipe.getIngredients() ) ingredient.toNetwork( buf );
|
||||||
buf.writeItemStack( recipe.getRecipeOutput() );
|
buf.writeItem( recipe.getResultItem() );
|
||||||
buf.writeEnumValue( recipe.getFamily() );
|
buf.writeEnum( recipe.getFamily() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ import net.minecraft.util.ResourceLocation;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import dan200.computercraft.shared.computer.recipe.ComputerFamilyRecipe.Serializer;
|
||||||
|
|
||||||
public class ComputerUpgradeRecipe extends ComputerFamilyRecipe
|
public class ComputerUpgradeRecipe extends ComputerFamilyRecipe
|
||||||
{
|
{
|
||||||
public ComputerUpgradeRecipe( ResourceLocation identifier, String group, int width, int height, NonNullList<Ingredient> ingredients, ItemStack result, ComputerFamily family )
|
public ComputerUpgradeRecipe( ResourceLocation identifier, String group, int width, int height, NonNullList<Ingredient> ingredients, ItemStack result, ComputerFamily family )
|
||||||
|
@ -16,6 +16,8 @@ import javax.annotation.Nonnull;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.minecraft.world.storage.loot.conditions.ILootCondition.IBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A loot condition which checks if the tile entity has a name.
|
* A loot condition which checks if the tile entity has a name.
|
||||||
*/
|
*/
|
||||||
@ -30,13 +32,13 @@ public final class BlockNamedEntityLootCondition implements ILootCondition
|
|||||||
@Override
|
@Override
|
||||||
public boolean test( LootContext lootContext )
|
public boolean test( LootContext lootContext )
|
||||||
{
|
{
|
||||||
TileEntity tile = lootContext.get( LootParameters.BLOCK_ENTITY );
|
TileEntity tile = lootContext.getParamOrNull( LootParameters.BLOCK_ENTITY );
|
||||||
return tile instanceof INameable && ((INameable) tile).hasCustomName();
|
return tile instanceof INameable && ((INameable) tile).hasCustomName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Set<LootParameter<?>> getRequiredParameters()
|
public Set<LootParameter<?>> getReferencedContextParams()
|
||||||
{
|
{
|
||||||
return Collections.singleton( LootParameters.BLOCK_ENTITY );
|
return Collections.singleton( LootParameters.BLOCK_ENTITY );
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ import javax.annotation.Nonnull;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.minecraft.world.storage.loot.conditions.ILootCondition.IBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A loot condition which checks if the tile entity has has a non-0 ID.
|
* A loot condition which checks if the tile entity has has a non-0 ID.
|
||||||
*/
|
*/
|
||||||
@ -30,13 +32,13 @@ public final class HasComputerIdLootCondition implements ILootCondition
|
|||||||
@Override
|
@Override
|
||||||
public boolean test( LootContext lootContext )
|
public boolean test( LootContext lootContext )
|
||||||
{
|
{
|
||||||
TileEntity tile = lootContext.get( LootParameters.BLOCK_ENTITY );
|
TileEntity tile = lootContext.getParamOrNull( LootParameters.BLOCK_ENTITY );
|
||||||
return tile instanceof IComputerTile && ((IComputerTile) tile).getComputerID() >= 0;
|
return tile instanceof IComputerTile && ((IComputerTile) tile).getComputerID() >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Set<LootParameter<?>> getRequiredParameters()
|
public Set<LootParameter<?>> getReferencedContextParams()
|
||||||
{
|
{
|
||||||
return Collections.singleton( LootParameters.BLOCK_ENTITY );
|
return Collections.singleton( LootParameters.BLOCK_ENTITY );
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@ import javax.annotation.Nonnull;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.minecraft.world.storage.loot.conditions.ILootCondition.IBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A loot condition which checks if the entity is in creative mode.
|
* A loot condition which checks if the entity is in creative mode.
|
||||||
*/
|
*/
|
||||||
@ -30,13 +32,13 @@ public final class PlayerCreativeLootCondition implements ILootCondition
|
|||||||
@Override
|
@Override
|
||||||
public boolean test( LootContext lootContext )
|
public boolean test( LootContext lootContext )
|
||||||
{
|
{
|
||||||
Entity entity = lootContext.get( LootParameters.THIS_ENTITY );
|
Entity entity = lootContext.getParamOrNull( LootParameters.THIS_ENTITY );
|
||||||
return entity instanceof PlayerEntity && ((PlayerEntity) entity).abilities.isCreativeMode;
|
return entity instanceof PlayerEntity && ((PlayerEntity) entity).abilities.instabuild;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Set<LootParameter<?>> getRequiredParameters()
|
public Set<LootParameter<?>> getReferencedContextParams()
|
||||||
{
|
{
|
||||||
return Collections.singleton( LootParameters.THIS_ENTITY );
|
return Collections.singleton( LootParameters.THIS_ENTITY );
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,8 @@ import net.minecraft.util.ResourceLocation;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static net.minecraft.item.crafting.Ingredient.fromStacks;
|
import static net.minecraft.item.crafting.Ingredient.of;
|
||||||
import static net.minecraft.util.NonNullList.from;
|
import static net.minecraft.util.NonNullList.of;
|
||||||
|
|
||||||
class RecipeResolver implements IRecipeManagerPlugin
|
class RecipeResolver implements IRecipeManagerPlugin
|
||||||
{
|
{
|
||||||
@ -158,18 +158,18 @@ class RecipeResolver implements IRecipeManagerPlugin
|
|||||||
if( left != null && right != null ) return Collections.emptyList();
|
if( left != null && right != null ) return Collections.emptyList();
|
||||||
|
|
||||||
List<Shaped> recipes = new ArrayList<>();
|
List<Shaped> recipes = new ArrayList<>();
|
||||||
Ingredient ingredient = fromStacks( stack );
|
Ingredient ingredient = of( stack );
|
||||||
for( UpgradeInfo upgrade : turtleUpgrades )
|
for( UpgradeInfo upgrade : turtleUpgrades )
|
||||||
{
|
{
|
||||||
// The turtle is facing towards us, so upgrades on the left are actually crafted on the right.
|
// The turtle is facing towards us, so upgrades on the left are actually crafted on the right.
|
||||||
if( left == null )
|
if( left == null )
|
||||||
{
|
{
|
||||||
recipes.add( horizontal( from( Ingredient.EMPTY, ingredient, upgrade.ingredient ), turtleWith( stack, upgrade.turtle, right ) ) );
|
recipes.add( horizontal( of( Ingredient.EMPTY, ingredient, upgrade.ingredient ), turtleWith( stack, upgrade.turtle, right ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( right == null )
|
if( right == null )
|
||||||
{
|
{
|
||||||
recipes.add( horizontal( from( Ingredient.EMPTY, upgrade.ingredient, ingredient ), turtleWith( stack, left, upgrade.turtle ) ) );
|
recipes.add( horizontal( of( Ingredient.EMPTY, upgrade.ingredient, ingredient ), turtleWith( stack, left, upgrade.turtle ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,10 +182,10 @@ class RecipeResolver implements IRecipeManagerPlugin
|
|||||||
if( back != null ) return Collections.emptyList();
|
if( back != null ) return Collections.emptyList();
|
||||||
|
|
||||||
List<Shaped> recipes = new ArrayList<>();
|
List<Shaped> recipes = new ArrayList<>();
|
||||||
Ingredient ingredient = fromStacks( stack );
|
Ingredient ingredient = of( stack );
|
||||||
for( UpgradeInfo upgrade : pocketUpgrades )
|
for( UpgradeInfo upgrade : pocketUpgrades )
|
||||||
{
|
{
|
||||||
recipes.add( vertical( from( Ingredient.EMPTY, ingredient, upgrade.ingredient ), pocketWith( stack, upgrade.pocket ) ) );
|
recipes.add( vertical( of( Ingredient.EMPTY, ingredient, upgrade.ingredient ), pocketWith( stack, upgrade.pocket ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return recipes;
|
return recipes;
|
||||||
@ -240,7 +240,7 @@ class RecipeResolver implements IRecipeManagerPlugin
|
|||||||
if( left != null )
|
if( left != null )
|
||||||
{
|
{
|
||||||
recipes.add( horizontal(
|
recipes.add( horizontal(
|
||||||
from( Ingredient.EMPTY, fromStacks( turtleWith( stack, null, right ) ), fromStacks( left.getCraftingItem() ) ),
|
of( Ingredient.EMPTY, of( turtleWith( stack, null, right ) ), of( left.getCraftingItem() ) ),
|
||||||
stack
|
stack
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
@ -248,7 +248,7 @@ class RecipeResolver implements IRecipeManagerPlugin
|
|||||||
if( right != null )
|
if( right != null )
|
||||||
{
|
{
|
||||||
recipes.add( horizontal(
|
recipes.add( horizontal(
|
||||||
from( Ingredient.EMPTY, fromStacks( right.getCraftingItem() ), fromStacks( turtleWith( stack, left, null ) ) ),
|
of( Ingredient.EMPTY, of( right.getCraftingItem() ), of( turtleWith( stack, left, null ) ) ),
|
||||||
stack
|
stack
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
@ -263,7 +263,7 @@ class RecipeResolver implements IRecipeManagerPlugin
|
|||||||
if( back != null )
|
if( back != null )
|
||||||
{
|
{
|
||||||
recipes.add( vertical(
|
recipes.add( vertical(
|
||||||
from( Ingredient.EMPTY, fromStacks( back.getCraftingItem() ), fromStacks( pocketWith( stack, null ) ) ),
|
of( Ingredient.EMPTY, of( back.getCraftingItem() ), of( pocketWith( stack, null ) ) ),
|
||||||
stack
|
stack
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
@ -346,7 +346,7 @@ class RecipeResolver implements IRecipeManagerPlugin
|
|||||||
UpgradeInfo( ItemStack stack, ITurtleUpgrade turtle )
|
UpgradeInfo( ItemStack stack, ITurtleUpgrade turtle )
|
||||||
{
|
{
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
this.ingredient = fromStacks( stack );
|
this.ingredient = of( stack );
|
||||||
this.upgrade = this.turtle = turtle;
|
this.upgrade = this.turtle = turtle;
|
||||||
this.pocket = null;
|
this.pocket = null;
|
||||||
}
|
}
|
||||||
@ -354,7 +354,7 @@ class RecipeResolver implements IRecipeManagerPlugin
|
|||||||
UpgradeInfo( ItemStack stack, IPocketUpgrade pocket )
|
UpgradeInfo( ItemStack stack, IPocketUpgrade pocket )
|
||||||
{
|
{
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
this.ingredient = fromStacks( stack );
|
this.ingredient = of( stack );
|
||||||
this.turtle = null;
|
this.turtle = null;
|
||||||
this.upgrade = this.pocket = pocket;
|
this.upgrade = this.pocket = pocket;
|
||||||
}
|
}
|
||||||
@ -370,7 +370,7 @@ class RecipeResolver implements IRecipeManagerPlugin
|
|||||||
if( turtle != null && TurtleUpgrades.suitableForFamily( family, turtle ) )
|
if( turtle != null && TurtleUpgrades.suitableForFamily( family, turtle ) )
|
||||||
{
|
{
|
||||||
recipes.add( horizontal(
|
recipes.add( horizontal(
|
||||||
from( Ingredient.EMPTY, ingredient, fromStacks( TurtleItemFactory.create( -1, null, -1, family, null, null, 0, null ) ) ),
|
of( Ingredient.EMPTY, ingredient, of( TurtleItemFactory.create( -1, null, -1, family, null, null, 0, null ) ) ),
|
||||||
TurtleItemFactory.create( -1, null, -1, family, null, turtle, 0, null )
|
TurtleItemFactory.create( -1, null, -1, family, null, turtle, 0, null )
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
@ -378,7 +378,7 @@ class RecipeResolver implements IRecipeManagerPlugin
|
|||||||
if( pocket != null )
|
if( pocket != null )
|
||||||
{
|
{
|
||||||
recipes.add( vertical(
|
recipes.add( vertical(
|
||||||
from( Ingredient.EMPTY, ingredient, fromStacks( PocketComputerItemFactory.create( -1, null, -1, family, null ) ) ),
|
of( Ingredient.EMPTY, ingredient, of( PocketComputerItemFactory.create( -1, null, -1, family, null ) ) ),
|
||||||
PocketComputerItemFactory.create( -1, null, -1, family, pocket )
|
PocketComputerItemFactory.create( -1, null, -1, family, pocket )
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,8 @@ import javax.annotation.Nonnull;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item.Properties;
|
||||||
|
|
||||||
public class ItemDisk extends Item implements IMedia, IColouredItem
|
public class ItemDisk extends Item implements IMedia, IColouredItem
|
||||||
{
|
{
|
||||||
private static final String NBT_ID = "DiskId";
|
private static final String NBT_ID = "DiskId";
|
||||||
@ -51,9 +53,9 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fillItemGroup( @Nonnull ItemGroup tabs, @Nonnull NonNullList<ItemStack> list )
|
public void fillItemCategory( @Nonnull ItemGroup tabs, @Nonnull NonNullList<ItemStack> list )
|
||||||
{
|
{
|
||||||
if( !isInGroup( tabs ) ) return;
|
if( !allowdedIn( tabs ) ) return;
|
||||||
for( int colour = 0; colour < 16; colour++ )
|
for( int colour = 0; colour < 16; colour++ )
|
||||||
{
|
{
|
||||||
list.add( createFromIDAndColour( -1, null, Colour.VALUES[colour].getHex() ) );
|
list.add( createFromIDAndColour( -1, null, Colour.VALUES[colour].getHex() ) );
|
||||||
@ -61,7 +63,7 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List<ITextComponent> list, ITooltipFlag options )
|
public void appendHoverText( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List<ITextComponent> list, ITooltipFlag options )
|
||||||
{
|
{
|
||||||
if( options.isAdvanced() )
|
if( options.isAdvanced() )
|
||||||
{
|
{
|
||||||
@ -69,7 +71,7 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
|
|||||||
if( id >= 0 )
|
if( id >= 0 )
|
||||||
{
|
{
|
||||||
list.add( new TranslationTextComponent( "gui.computercraft.tooltip.disk_id", id )
|
list.add( new TranslationTextComponent( "gui.computercraft.tooltip.disk_id", id )
|
||||||
.applyTextStyle( TextFormatting.GRAY ) );
|
.withStyle( TextFormatting.GRAY ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,7 +85,7 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
|
|||||||
@Override
|
@Override
|
||||||
public String getLabel( @Nonnull ItemStack stack )
|
public String getLabel( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
return stack.hasDisplayName() ? stack.getDisplayName().getString() : null;
|
return stack.hasCustomHoverName() ? stack.getHoverName().getString() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -91,11 +93,11 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
|
|||||||
{
|
{
|
||||||
if( label != null )
|
if( label != null )
|
||||||
{
|
{
|
||||||
stack.setDisplayName( new StringTextComponent( label ) );
|
stack.setHoverName( new StringTextComponent( label ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stack.clearCustomName();
|
stack.resetHoverName();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@ import net.minecraft.world.World;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item.Properties;
|
||||||
|
|
||||||
public class ItemPrintout extends Item
|
public class ItemPrintout extends Item
|
||||||
{
|
{
|
||||||
private static final String NBT_TITLE = "Title";
|
private static final String NBT_TITLE = "Title";
|
||||||
@ -50,7 +52,7 @@ public class ItemPrintout extends Item
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation( @Nonnull ItemStack stack, World world, @Nonnull List<ITextComponent> list, @Nonnull ITooltipFlag options )
|
public void appendHoverText( @Nonnull ItemStack stack, World world, @Nonnull List<ITextComponent> list, @Nonnull ITooltipFlag options )
|
||||||
{
|
{
|
||||||
String title = getTitle( stack );
|
String title = getTitle( stack );
|
||||||
if( title != null && !title.isEmpty() ) list.add( new StringTextComponent( title ) );
|
if( title != null && !title.isEmpty() ) list.add( new StringTextComponent( title ) );
|
||||||
@ -58,14 +60,14 @@ public class ItemPrintout extends Item
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick( World world, @Nonnull PlayerEntity player, @Nonnull Hand hand )
|
public ActionResult<ItemStack> use( World world, @Nonnull PlayerEntity player, @Nonnull Hand hand )
|
||||||
{
|
{
|
||||||
if( !world.isRemote )
|
if( !world.isClientSide )
|
||||||
{
|
{
|
||||||
new HeldItemContainerData( hand )
|
new HeldItemContainerData( hand )
|
||||||
.open( player, new ContainerHeldItem.Factory( Registry.ModContainers.PRINTOUT.get(), player.getHeldItem( hand ), hand ) );
|
.open( player, new ContainerHeldItem.Factory( Registry.ModContainers.PRINTOUT.get(), player.getItemInHand( hand ), hand ) );
|
||||||
}
|
}
|
||||||
return new ActionResult<>( ActionResultType.SUCCESS, player.getHeldItem( hand ) );
|
return new ActionResult<>( ActionResultType.SUCCESS, player.getItemInHand( hand ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -29,6 +29,8 @@ import javax.annotation.Nullable;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item.Properties;
|
||||||
|
|
||||||
public class ItemTreasureDisk extends Item implements IMedia
|
public class ItemTreasureDisk extends Item implements IMedia
|
||||||
{
|
{
|
||||||
private static final String NBT_TITLE = "Title";
|
private static final String NBT_TITLE = "Title";
|
||||||
@ -41,12 +43,12 @@ public class ItemTreasureDisk extends Item implements IMedia
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fillItemGroup( @Nonnull ItemGroup group, @Nonnull NonNullList<ItemStack> stacks )
|
public void fillItemCategory( @Nonnull ItemGroup group, @Nonnull NonNullList<ItemStack> stacks )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List<ITextComponent> list, @Nonnull ITooltipFlag tooltipOptions )
|
public void appendHoverText( @Nonnull ItemStack stack, @Nullable World world, @Nonnull List<ITextComponent> list, @Nonnull ITooltipFlag tooltipOptions )
|
||||||
{
|
{
|
||||||
String label = getTitle( stack );
|
String label = getTitle( stack );
|
||||||
if( !label.isEmpty() ) list.add( new StringTextComponent( label ) );
|
if( !label.isEmpty() ) list.add( new StringTextComponent( label ) );
|
||||||
|
@ -41,7 +41,7 @@ public final class RecordMedia implements IMedia
|
|||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
if( !(item instanceof MusicDiscItem) ) return null;
|
if( !(item instanceof MusicDiscItem) ) return null;
|
||||||
|
|
||||||
return new TranslationTextComponent( item.getTranslationKey() + ".desc" ).getString();
|
return new TranslationTextComponent( item.getDescriptionId() + ".desc" ).getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -52,7 +52,7 @@ public final class RecordMedia implements IMedia
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return ObfuscationReflectionHelper.getPrivateValue( MusicDiscItem.class, (MusicDiscItem) item, "field_185076_b" );
|
return ObfuscationReflectionHelper.getPrivateValue( MusicDiscItem.class, (MusicDiscItem) item, "sound" );
|
||||||
}
|
}
|
||||||
catch( UnableToAccessFieldException | UnableToFindFieldException e )
|
catch( UnableToAccessFieldException | UnableToFindFieldException e )
|
||||||
{
|
{
|
||||||
|
@ -25,8 +25,8 @@ import javax.annotation.Nonnull;
|
|||||||
|
|
||||||
public class DiskRecipe extends SpecialRecipe
|
public class DiskRecipe extends SpecialRecipe
|
||||||
{
|
{
|
||||||
private final Ingredient paper = Ingredient.fromItems( Items.PAPER );
|
private final Ingredient paper = Ingredient.of( Items.PAPER );
|
||||||
private final Ingredient redstone = Ingredient.fromTag( Tags.Items.DUSTS_REDSTONE );
|
private final Ingredient redstone = Ingredient.of( Tags.Items.DUSTS_REDSTONE );
|
||||||
|
|
||||||
public DiskRecipe( ResourceLocation id )
|
public DiskRecipe( ResourceLocation id )
|
||||||
{
|
{
|
||||||
@ -39,9 +39,9 @@ public class DiskRecipe extends SpecialRecipe
|
|||||||
boolean paperFound = false;
|
boolean paperFound = false;
|
||||||
boolean redstoneFound = false;
|
boolean redstoneFound = false;
|
||||||
|
|
||||||
for( int i = 0; i < inv.getSizeInventory(); i++ )
|
for( int i = 0; i < inv.getContainerSize(); i++ )
|
||||||
{
|
{
|
||||||
ItemStack stack = inv.getStackInSlot( i );
|
ItemStack stack = inv.getItem( i );
|
||||||
|
|
||||||
if( !stack.isEmpty() )
|
if( !stack.isEmpty() )
|
||||||
{
|
{
|
||||||
@ -67,13 +67,13 @@ public class DiskRecipe extends SpecialRecipe
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getCraftingResult( @Nonnull CraftingInventory inv )
|
public ItemStack assemble( @Nonnull CraftingInventory inv )
|
||||||
{
|
{
|
||||||
ColourTracker tracker = new ColourTracker();
|
ColourTracker tracker = new ColourTracker();
|
||||||
|
|
||||||
for( int i = 0; i < inv.getSizeInventory(); i++ )
|
for( int i = 0; i < inv.getContainerSize(); i++ )
|
||||||
{
|
{
|
||||||
ItemStack stack = inv.getStackInSlot( i );
|
ItemStack stack = inv.getItem( i );
|
||||||
|
|
||||||
if( stack.isEmpty() ) continue;
|
if( stack.isEmpty() ) continue;
|
||||||
|
|
||||||
@ -88,14 +88,14 @@ public class DiskRecipe extends SpecialRecipe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canFit( int x, int y )
|
public boolean canCraftInDimensions( int x, int y )
|
||||||
{
|
{
|
||||||
return x >= 2 && y >= 2;
|
return x >= 2 && y >= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getRecipeOutput()
|
public ItemStack getResultItem()
|
||||||
{
|
{
|
||||||
return ItemDisk.createFromIDAndColour( -1, null, Colour.BLUE.getHex() );
|
return ItemDisk.createFromIDAndColour( -1, null, Colour.BLUE.getHex() );
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,9 @@ import javax.annotation.Nonnull;
|
|||||||
|
|
||||||
public final class PrintoutRecipe extends SpecialRecipe
|
public final class PrintoutRecipe extends SpecialRecipe
|
||||||
{
|
{
|
||||||
private final Ingredient paper = Ingredient.fromItems( net.minecraft.item.Items.PAPER );
|
private final Ingredient paper = Ingredient.of( net.minecraft.item.Items.PAPER );
|
||||||
private final Ingredient leather = Ingredient.fromItems( net.minecraft.item.Items.LEATHER );
|
private final Ingredient leather = Ingredient.of( net.minecraft.item.Items.LEATHER );
|
||||||
private final Ingredient string = Ingredient.fromItems( Items.STRING );
|
private final Ingredient string = Ingredient.of( Items.STRING );
|
||||||
|
|
||||||
private PrintoutRecipe( ResourceLocation id )
|
private PrintoutRecipe( ResourceLocation id )
|
||||||
{
|
{
|
||||||
@ -30,14 +30,14 @@ public final class PrintoutRecipe extends SpecialRecipe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canFit( int x, int y )
|
public boolean canCraftInDimensions( int x, int y )
|
||||||
{
|
{
|
||||||
return x >= 3 && y >= 3;
|
return x >= 3 && y >= 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getRecipeOutput()
|
public ItemStack getResultItem()
|
||||||
{
|
{
|
||||||
return ItemPrintout.createMultipleFromTitleAndText( null, null, null );
|
return ItemPrintout.createMultipleFromTitleAndText( null, null, null );
|
||||||
}
|
}
|
||||||
@ -45,12 +45,12 @@ public final class PrintoutRecipe extends SpecialRecipe
|
|||||||
@Override
|
@Override
|
||||||
public boolean matches( @Nonnull CraftingInventory inventory, @Nonnull World world )
|
public boolean matches( @Nonnull CraftingInventory inventory, @Nonnull World world )
|
||||||
{
|
{
|
||||||
return !getCraftingResult( inventory ).isEmpty();
|
return !assemble( inventory ).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getCraftingResult( @Nonnull CraftingInventory inventory )
|
public ItemStack assemble( @Nonnull CraftingInventory inventory )
|
||||||
{
|
{
|
||||||
// See if we match the recipe, and extract the input disk ID and dye colour
|
// See if we match the recipe, and extract the input disk ID and dye colour
|
||||||
int numPages = 0;
|
int numPages = 0;
|
||||||
@ -63,7 +63,7 @@ public final class PrintoutRecipe extends SpecialRecipe
|
|||||||
{
|
{
|
||||||
for( int x = 0; x < inventory.getWidth(); x++ )
|
for( int x = 0; x < inventory.getWidth(); x++ )
|
||||||
{
|
{
|
||||||
ItemStack stack = inventory.getStackInSlot( x + y * inventory.getWidth() );
|
ItemStack stack = inventory.getItem( x + y * inventory.getWidth() );
|
||||||
if( !stack.isEmpty() )
|
if( !stack.isEmpty() )
|
||||||
{
|
{
|
||||||
if( stack.getItem() instanceof ItemPrintout && ((ItemPrintout) stack.getItem()).getType() != ItemPrintout.Type.BOOK )
|
if( stack.getItem() instanceof ItemPrintout && ((ItemPrintout) stack.getItem()).getType() != ItemPrintout.Type.BOOK )
|
||||||
|
@ -60,7 +60,7 @@ public final class NetworkHandler
|
|||||||
|
|
||||||
public static void sendToPlayer( PlayerEntity player, NetworkMessage packet )
|
public static void sendToPlayer( PlayerEntity player, NetworkMessage packet )
|
||||||
{
|
{
|
||||||
network.sendTo( packet, ((ServerPlayerEntity) player).connection.netManager, NetworkDirection.PLAY_TO_CLIENT );
|
network.sendTo( packet, ((ServerPlayerEntity) player).connection.connection, NetworkDirection.PLAY_TO_CLIENT );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendToAllPlayers( NetworkMessage packet )
|
public static void sendToAllPlayers( NetworkMessage packet )
|
||||||
|
@ -38,13 +38,13 @@ public class ChatTableClientMessage implements NetworkMessage
|
|||||||
buf.writeBoolean( table.getHeaders() != null );
|
buf.writeBoolean( table.getHeaders() != null );
|
||||||
if( table.getHeaders() != null )
|
if( table.getHeaders() != null )
|
||||||
{
|
{
|
||||||
for( ITextComponent header : table.getHeaders() ) buf.writeTextComponent( header );
|
for( ITextComponent header : table.getHeaders() ) buf.writeComponent( header );
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.writeVarInt( table.getRows().size() );
|
buf.writeVarInt( table.getRows().size() );
|
||||||
for( ITextComponent[] row : table.getRows() )
|
for( ITextComponent[] row : table.getRows() )
|
||||||
{
|
{
|
||||||
for( ITextComponent column : row ) buf.writeTextComponent( column );
|
for( ITextComponent column : row ) buf.writeComponent( column );
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.writeVarInt( table.getAdditional() );
|
buf.writeVarInt( table.getAdditional() );
|
||||||
@ -59,7 +59,7 @@ public class ChatTableClientMessage implements NetworkMessage
|
|||||||
if( buf.readBoolean() )
|
if( buf.readBoolean() )
|
||||||
{
|
{
|
||||||
ITextComponent[] headers = new ITextComponent[columns];
|
ITextComponent[] headers = new ITextComponent[columns];
|
||||||
for( int i = 0; i < columns; i++ ) headers[i] = buf.readTextComponent();
|
for( int i = 0; i < columns; i++ ) headers[i] = buf.readComponent();
|
||||||
table = new TableBuilder( id, headers );
|
table = new TableBuilder( id, headers );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -71,7 +71,7 @@ public class ChatTableClientMessage implements NetworkMessage
|
|||||||
for( int i = 0; i < rows; i++ )
|
for( int i = 0; i < rows; i++ )
|
||||||
{
|
{
|
||||||
ITextComponent[] row = new ITextComponent[columns];
|
ITextComponent[] row = new ITextComponent[columns];
|
||||||
for( int j = 0; j < columns; j++ ) row[j] = buf.readTextComponent();
|
for( int j = 0; j < columns; j++ ) row[j] = buf.readComponent();
|
||||||
table.row( row );
|
table.row( row );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,16 +36,16 @@ public class ComputerDataClientMessage extends ComputerClientMessage
|
|||||||
public void toBytes( @Nonnull PacketBuffer buf )
|
public void toBytes( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
super.toBytes( buf );
|
super.toBytes( buf );
|
||||||
buf.writeEnumValue( state );
|
buf.writeEnum( state );
|
||||||
buf.writeCompoundTag( userData );
|
buf.writeNbt( userData );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromBytes( @Nonnull PacketBuffer buf )
|
public void fromBytes( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
super.fromBytes( buf );
|
super.fromBytes( buf );
|
||||||
state = buf.readEnumValue( ComputerState.class );
|
state = buf.readEnum( ComputerState.class );
|
||||||
userData = buf.readCompoundTag();
|
userData = buf.readNbt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -44,9 +44,9 @@ public class MonitorClientMessage implements NetworkMessage
|
|||||||
public void handle( NetworkEvent.Context context )
|
public void handle( NetworkEvent.Context context )
|
||||||
{
|
{
|
||||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||||
if( player == null || player.world == null ) return;
|
if( player == null || player.level == null ) return;
|
||||||
|
|
||||||
TileEntity te = player.world.getTileEntity( pos );
|
TileEntity te = player.level.getBlockEntity( pos );
|
||||||
if( !(te instanceof TileMonitor) ) return;
|
if( !(te instanceof TileMonitor) ) return;
|
||||||
|
|
||||||
((TileMonitor) te).read( state );
|
((TileMonitor) te).read( state );
|
||||||
|
@ -48,7 +48,7 @@ public class PlayRecordClientMessage implements NetworkMessage
|
|||||||
pos = buf.readBlockPos();
|
pos = buf.readBlockPos();
|
||||||
if( buf.readBoolean() )
|
if( buf.readBoolean() )
|
||||||
{
|
{
|
||||||
name = buf.readString( Short.MAX_VALUE );
|
name = buf.readUtf( Short.MAX_VALUE );
|
||||||
soundEvent = buf.readRegistryIdSafe( SoundEvent.class );
|
soundEvent = buf.readRegistryIdSafe( SoundEvent.class );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -69,7 +69,7 @@ public class PlayRecordClientMessage implements NetworkMessage
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
buf.writeBoolean( true );
|
buf.writeBoolean( true );
|
||||||
buf.writeString( name );
|
buf.writeUtf( name );
|
||||||
buf.writeRegistryId( soundEvent );
|
buf.writeRegistryId( soundEvent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ public class PlayRecordClientMessage implements NetworkMessage
|
|||||||
public void handle( NetworkEvent.Context context )
|
public void handle( NetworkEvent.Context context )
|
||||||
{
|
{
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
mc.worldRenderer.playRecord( soundEvent, pos );
|
mc.levelRenderer.playStreamingMusic( soundEvent, pos );
|
||||||
if( name != null ) mc.ingameGUI.setRecordPlayingMessage( name );
|
if( name != null ) mc.gui.setNowPlaying( name );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,14 @@ public class ComputerContainerData implements ContainerData
|
|||||||
public ComputerContainerData( PacketBuffer buf )
|
public ComputerContainerData( PacketBuffer buf )
|
||||||
{
|
{
|
||||||
this.id = buf.readInt();
|
this.id = buf.readInt();
|
||||||
this.family = buf.readEnumValue( ComputerFamily.class );
|
this.family = buf.readEnum( ComputerFamily.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toBytes( PacketBuffer buf )
|
public void toBytes( PacketBuffer buf )
|
||||||
{
|
{
|
||||||
buf.writeInt( id );
|
buf.writeInt( id );
|
||||||
buf.writeEnumValue( family );
|
buf.writeEnum( family );
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getInstanceId()
|
public int getInstanceId()
|
||||||
|
@ -28,13 +28,13 @@ public class HeldItemContainerData implements ContainerData
|
|||||||
|
|
||||||
public HeldItemContainerData( PacketBuffer buffer )
|
public HeldItemContainerData( PacketBuffer buffer )
|
||||||
{
|
{
|
||||||
hand = buffer.readEnumValue( Hand.class );
|
hand = buffer.readEnum( Hand.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toBytes( PacketBuffer buf )
|
public void toBytes( PacketBuffer buf )
|
||||||
{
|
{
|
||||||
buf.writeEnumValue( hand );
|
buf.writeEnum( hand );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -29,14 +29,14 @@ public class ComputerActionServerMessage extends ComputerServerMessage
|
|||||||
public void toBytes( @Nonnull PacketBuffer buf )
|
public void toBytes( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
super.toBytes( buf );
|
super.toBytes( buf );
|
||||||
buf.writeEnumValue( action );
|
buf.writeEnum( action );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromBytes( @Nonnull PacketBuffer buf )
|
public void fromBytes( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
super.fromBytes( buf );
|
super.fromBytes( buf );
|
||||||
action = buf.readEnumValue( Action.class );
|
action = buf.readEnum( Action.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,17 +40,17 @@ public class QueueEventServerMessage extends ComputerServerMessage
|
|||||||
public void toBytes( @Nonnull PacketBuffer buf )
|
public void toBytes( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
super.toBytes( buf );
|
super.toBytes( buf );
|
||||||
buf.writeString( event );
|
buf.writeUtf( event );
|
||||||
buf.writeCompoundTag( args == null ? null : NBTUtil.encodeObjects( args ) );
|
buf.writeNbt( args == null ? null : NBTUtil.encodeObjects( args ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromBytes( @Nonnull PacketBuffer buf )
|
public void fromBytes( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
super.fromBytes( buf );
|
super.fromBytes( buf );
|
||||||
event = buf.readString( Short.MAX_VALUE );
|
event = buf.readUtf( Short.MAX_VALUE );
|
||||||
|
|
||||||
CompoundNBT args = buf.readCompoundTag();
|
CompoundNBT args = buf.readNbt();
|
||||||
this.args = args == null ? null : NBTUtil.decodeObjects( args );
|
this.args = args == null ? null : NBTUtil.decodeObjects( args );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public class CommandBlockPeripheral implements IPeripheral, ICapabilityProvider
|
|||||||
@LuaFunction( mainThread = true )
|
@LuaFunction( mainThread = true )
|
||||||
public final String getCommand()
|
public final String getCommand()
|
||||||
{
|
{
|
||||||
return commandBlock.getCommandBlockLogic().getCommand();
|
return commandBlock.getCommandBlock().getCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,8 +75,8 @@ public class CommandBlockPeripheral implements IPeripheral, ICapabilityProvider
|
|||||||
@LuaFunction( mainThread = true )
|
@LuaFunction( mainThread = true )
|
||||||
public final void setCommand( String command )
|
public final void setCommand( String command )
|
||||||
{
|
{
|
||||||
commandBlock.getCommandBlockLogic().setCommand( command );
|
commandBlock.getCommandBlock().setCommand( command );
|
||||||
commandBlock.getCommandBlockLogic().updateCommand();
|
commandBlock.getCommandBlock().onUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,8 +89,8 @@ public class CommandBlockPeripheral implements IPeripheral, ICapabilityProvider
|
|||||||
@LuaFunction( mainThread = true )
|
@LuaFunction( mainThread = true )
|
||||||
public final Object[] runCommand()
|
public final Object[] runCommand()
|
||||||
{
|
{
|
||||||
commandBlock.getCommandBlockLogic().trigger( commandBlock.getWorld() );
|
commandBlock.getCommandBlock().performCommand( commandBlock.getLevel() );
|
||||||
int result = commandBlock.getCommandBlockLogic().getSuccessCount();
|
int result = commandBlock.getCommandBlock().getSuccessCount();
|
||||||
return result > 0 ? new Object[] { true } : new Object[] { false, "Command failed" };
|
return result > 0 ? new Object[] { true } : new Object[] { false, "Command failed" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ import net.minecraft.world.World;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block.Properties;
|
||||||
|
|
||||||
public class BlockDiskDrive extends BlockGeneric
|
public class BlockDiskDrive extends BlockGeneric
|
||||||
{
|
{
|
||||||
static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
|
static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
|
||||||
@ -35,14 +37,14 @@ public class BlockDiskDrive extends BlockGeneric
|
|||||||
public BlockDiskDrive( Properties settings )
|
public BlockDiskDrive( Properties settings )
|
||||||
{
|
{
|
||||||
super( settings, Registry.ModTiles.DISK_DRIVE );
|
super( settings, Registry.ModTiles.DISK_DRIVE );
|
||||||
setDefaultState( getStateContainer().getBaseState()
|
registerDefaultState( getStateDefinition().any()
|
||||||
.with( FACING, Direction.NORTH )
|
.setValue( FACING, Direction.NORTH )
|
||||||
.with( STATE, DiskDriveState.EMPTY ) );
|
.setValue( STATE, DiskDriveState.EMPTY ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void fillStateContainer( StateContainer.Builder<Block, BlockState> properties )
|
protected void createBlockStateDefinition( StateContainer.Builder<Block, BlockState> properties )
|
||||||
{
|
{
|
||||||
properties.add( FACING, STATE );
|
properties.add( FACING, STATE );
|
||||||
}
|
}
|
||||||
@ -51,34 +53,34 @@ public class BlockDiskDrive extends BlockGeneric
|
|||||||
@Override
|
@Override
|
||||||
public BlockState getStateForPlacement( BlockItemUseContext placement )
|
public BlockState getStateForPlacement( BlockItemUseContext placement )
|
||||||
{
|
{
|
||||||
return getDefaultState().with( FACING, placement.getPlacementHorizontalFacing().getOpposite() );
|
return defaultBlockState().setValue( FACING, placement.getHorizontalDirection().getOpposite() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void harvestBlock( @Nonnull World world, @Nonnull PlayerEntity player, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nullable TileEntity te, @Nonnull ItemStack stack )
|
public void playerDestroy( @Nonnull World world, @Nonnull PlayerEntity player, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nullable TileEntity te, @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
if( te instanceof INameable && ((INameable) te).hasCustomName() )
|
if( te instanceof INameable && ((INameable) te).hasCustomName() )
|
||||||
{
|
{
|
||||||
player.addStat( Stats.BLOCK_MINED.get( this ) );
|
player.awardStat( Stats.BLOCK_MINED.get( this ) );
|
||||||
player.addExhaustion( 0.005F );
|
player.causeFoodExhaustion( 0.005F );
|
||||||
|
|
||||||
ItemStack result = new ItemStack( this );
|
ItemStack result = new ItemStack( this );
|
||||||
result.setDisplayName( ((INameable) te).getCustomName() );
|
result.setHoverName( ((INameable) te).getCustomName() );
|
||||||
spawnAsEntity( world, pos, result );
|
popResource( world, pos, result );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
super.harvestBlock( world, player, pos, state, te, stack );
|
super.playerDestroy( world, player, pos, state, te, stack );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, LivingEntity placer, ItemStack stack )
|
public void setPlacedBy( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, LivingEntity placer, ItemStack stack )
|
||||||
{
|
{
|
||||||
if( stack.hasDisplayName() )
|
if( stack.hasCustomHoverName() )
|
||||||
{
|
{
|
||||||
TileEntity tileentity = world.getTileEntity( pos );
|
TileEntity tileentity = world.getBlockEntity( pos );
|
||||||
if( tileentity instanceof TileDiskDrive ) ((TileDiskDrive) tileentity).customName = stack.getDisplayName();
|
if( tileentity instanceof TileDiskDrive ) ((TileDiskDrive) tileentity).customName = stack.getHoverName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,38 +48,38 @@ public class ContainerDiskDrive extends Container
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteractWith( @Nonnull PlayerEntity player )
|
public boolean stillValid( @Nonnull PlayerEntity player )
|
||||||
{
|
{
|
||||||
return inventory.isUsableByPlayer( player );
|
return inventory.stillValid( player );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack transferStackInSlot( @Nonnull PlayerEntity player, int slotIndex )
|
public ItemStack quickMoveStack( @Nonnull PlayerEntity player, int slotIndex )
|
||||||
{
|
{
|
||||||
Slot slot = inventorySlots.get( slotIndex );
|
Slot slot = slots.get( slotIndex );
|
||||||
if( slot == null || !slot.getHasStack() ) return ItemStack.EMPTY;
|
if( slot == null || !slot.hasItem() ) return ItemStack.EMPTY;
|
||||||
|
|
||||||
ItemStack existing = slot.getStack().copy();
|
ItemStack existing = slot.getItem().copy();
|
||||||
ItemStack result = existing.copy();
|
ItemStack result = existing.copy();
|
||||||
if( slotIndex == 0 )
|
if( slotIndex == 0 )
|
||||||
{
|
{
|
||||||
// Insert into player inventory
|
// Insert into player inventory
|
||||||
if( !mergeItemStack( existing, 1, 37, true ) ) return ItemStack.EMPTY;
|
if( !moveItemStackTo( existing, 1, 37, true ) ) return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Insert into drive inventory
|
// Insert into drive inventory
|
||||||
if( !mergeItemStack( existing, 0, 1, false ) ) return ItemStack.EMPTY;
|
if( !moveItemStackTo( existing, 0, 1, false ) ) return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( existing.isEmpty() )
|
if( existing.isEmpty() )
|
||||||
{
|
{
|
||||||
slot.putStack( ItemStack.EMPTY );
|
slot.set( ItemStack.EMPTY );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
slot.onSlotChanged();
|
slot.setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( existing.getCount() == result.getCount() ) return ItemStack.EMPTY;
|
if( existing.getCount() == result.getCount() ) return ItemStack.EMPTY;
|
||||||
|
@ -24,7 +24,7 @@ public enum DiskDriveState implements IStringSerializable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public String getName()
|
public String getSerializedName()
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -99,54 +99,54 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
if( player.isCrouching() )
|
if( player.isCrouching() )
|
||||||
{
|
{
|
||||||
// Try to put a disk into the drive
|
// Try to put a disk into the drive
|
||||||
ItemStack disk = player.getHeldItem( hand );
|
ItemStack disk = player.getItemInHand( hand );
|
||||||
if( disk.isEmpty() ) return ActionResultType.PASS;
|
if( disk.isEmpty() ) return ActionResultType.PASS;
|
||||||
if( !getWorld().isRemote && getStackInSlot( 0 ).isEmpty() && MediaProviders.get( disk ) != null )
|
if( !getLevel().isClientSide && getItem( 0 ).isEmpty() && MediaProviders.get( disk ) != null )
|
||||||
{
|
{
|
||||||
setDiskStack( disk );
|
setDiskStack( disk );
|
||||||
player.setHeldItem( hand, ItemStack.EMPTY );
|
player.setItemInHand( hand, ItemStack.EMPTY );
|
||||||
}
|
}
|
||||||
return ActionResultType.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Open the GUI
|
// Open the GUI
|
||||||
if( !getWorld().isRemote ) NetworkHooks.openGui( (ServerPlayerEntity) player, this );
|
if( !getLevel().isClientSide ) NetworkHooks.openGui( (ServerPlayerEntity) player, this );
|
||||||
return ActionResultType.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Direction getDirection()
|
public Direction getDirection()
|
||||||
{
|
{
|
||||||
return getBlockState().get( BlockDiskDrive.FACING );
|
return getBlockState().getValue( BlockDiskDrive.FACING );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read( @Nonnull CompoundNBT nbt )
|
public void load( @Nonnull CompoundNBT nbt )
|
||||||
{
|
{
|
||||||
super.read( nbt );
|
super.load( nbt );
|
||||||
customName = nbt.contains( NBT_NAME ) ? ITextComponent.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null;
|
customName = nbt.contains( NBT_NAME ) ? ITextComponent.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null;
|
||||||
if( nbt.contains( NBT_ITEM ) )
|
if( nbt.contains( NBT_ITEM ) )
|
||||||
{
|
{
|
||||||
CompoundNBT item = nbt.getCompound( NBT_ITEM );
|
CompoundNBT item = nbt.getCompound( NBT_ITEM );
|
||||||
m_diskStack = ItemStack.read( item );
|
m_diskStack = ItemStack.of( item );
|
||||||
m_diskMount = null;
|
m_diskMount = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public CompoundNBT write( @Nonnull CompoundNBT nbt )
|
public CompoundNBT save( @Nonnull CompoundNBT nbt )
|
||||||
{
|
{
|
||||||
if( customName != null ) nbt.putString( NBT_NAME, ITextComponent.Serializer.toJson( customName ) );
|
if( customName != null ) nbt.putString( NBT_NAME, ITextComponent.Serializer.toJson( customName ) );
|
||||||
|
|
||||||
if( !m_diskStack.isEmpty() )
|
if( !m_diskStack.isEmpty() )
|
||||||
{
|
{
|
||||||
CompoundNBT item = new CompoundNBT();
|
CompoundNBT item = new CompoundNBT();
|
||||||
m_diskStack.write( item );
|
m_diskStack.save( item );
|
||||||
nbt.put( NBT_ITEM, item );
|
nbt.put( NBT_ITEM, item );
|
||||||
}
|
}
|
||||||
return super.write( nbt );
|
return super.save( nbt );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -162,7 +162,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
// Music
|
// Music
|
||||||
synchronized( this )
|
synchronized( this )
|
||||||
{
|
{
|
||||||
if( !world.isRemote && m_recordPlaying != m_recordQueued || m_restartRecord )
|
if( !level.isClientSide && m_recordPlaying != m_recordQueued || m_restartRecord )
|
||||||
{
|
{
|
||||||
m_restartRecord = false;
|
m_restartRecord = false;
|
||||||
if( m_recordQueued )
|
if( m_recordQueued )
|
||||||
@ -191,7 +191,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
// IInventory implementation
|
// IInventory implementation
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSizeInventory()
|
public int getContainerSize()
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -204,14 +204,14 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlot( int slot )
|
public ItemStack getItem( int slot )
|
||||||
{
|
{
|
||||||
return m_diskStack;
|
return m_diskStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack removeStackFromSlot( int slot )
|
public ItemStack removeItemNoUpdate( int slot )
|
||||||
{
|
{
|
||||||
ItemStack result = m_diskStack;
|
ItemStack result = m_diskStack;
|
||||||
m_diskStack = ItemStack.EMPTY;
|
m_diskStack = ItemStack.EMPTY;
|
||||||
@ -222,30 +222,30 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack decrStackSize( int slot, int count )
|
public ItemStack removeItem( int slot, int count )
|
||||||
{
|
{
|
||||||
if( m_diskStack.isEmpty() ) return ItemStack.EMPTY;
|
if( m_diskStack.isEmpty() ) return ItemStack.EMPTY;
|
||||||
|
|
||||||
if( m_diskStack.getCount() <= count )
|
if( m_diskStack.getCount() <= count )
|
||||||
{
|
{
|
||||||
ItemStack disk = m_diskStack;
|
ItemStack disk = m_diskStack;
|
||||||
setInventorySlotContents( slot, ItemStack.EMPTY );
|
setItem( slot, ItemStack.EMPTY );
|
||||||
return disk;
|
return disk;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack part = m_diskStack.split( count );
|
ItemStack part = m_diskStack.split( count );
|
||||||
setInventorySlotContents( slot, m_diskStack.isEmpty() ? ItemStack.EMPTY : m_diskStack );
|
setItem( slot, m_diskStack.isEmpty() ? ItemStack.EMPTY : m_diskStack );
|
||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInventorySlotContents( int slot, @Nonnull ItemStack stack )
|
public void setItem( int slot, @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
if( getWorld().isRemote )
|
if( getLevel().isClientSide )
|
||||||
{
|
{
|
||||||
m_diskStack = stack;
|
m_diskStack = stack;
|
||||||
m_diskMount = null;
|
m_diskMount = null;
|
||||||
markDirty();
|
setChanged();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
// Swap disk over
|
// Swap disk over
|
||||||
m_diskStack = stack;
|
m_diskStack = stack;
|
||||||
m_diskMount = null;
|
m_diskMount = null;
|
||||||
markDirty();
|
setChanged();
|
||||||
|
|
||||||
// Mount new disk
|
// Mount new disk
|
||||||
if( !m_diskStack.isEmpty() )
|
if( !m_diskStack.isEmpty() )
|
||||||
@ -288,33 +288,33 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void markDirty()
|
public void setChanged()
|
||||||
{
|
{
|
||||||
if( !world.isRemote ) updateBlockState();
|
if( !level.isClientSide ) updateBlockState();
|
||||||
super.markDirty();
|
super.setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isUsableByPlayer( @Nonnull PlayerEntity player )
|
public boolean stillValid( @Nonnull PlayerEntity player )
|
||||||
{
|
{
|
||||||
return isUsable( player, false );
|
return isUsable( player, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear()
|
public void clearContent()
|
||||||
{
|
{
|
||||||
setInventorySlotContents( 0, ItemStack.EMPTY );
|
setItem( 0, ItemStack.EMPTY );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
ItemStack getDiskStack()
|
ItemStack getDiskStack()
|
||||||
{
|
{
|
||||||
return getStackInSlot( 0 );
|
return getItem( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDiskStack( @Nonnull ItemStack stack )
|
void setDiskStack( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
setInventorySlotContents( 0, stack );
|
setItem( 0, stack );
|
||||||
}
|
}
|
||||||
|
|
||||||
private IMedia getDiskMedia()
|
private IMedia getDiskMedia()
|
||||||
@ -391,7 +391,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
{
|
{
|
||||||
if( m_diskMount == null )
|
if( m_diskMount == null )
|
||||||
{
|
{
|
||||||
m_diskMount = contents.createDataMount( m_diskStack, getWorld() );
|
m_diskMount = contents.createDataMount( m_diskStack, getLevel() );
|
||||||
}
|
}
|
||||||
if( m_diskMount != null )
|
if( m_diskMount != null )
|
||||||
{
|
{
|
||||||
@ -442,7 +442,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
|
|
||||||
private void updateBlockState()
|
private void updateBlockState()
|
||||||
{
|
{
|
||||||
if( removed ) return;
|
if( remove ) return;
|
||||||
|
|
||||||
if( !m_diskStack.isEmpty() )
|
if( !m_diskStack.isEmpty() )
|
||||||
{
|
{
|
||||||
@ -458,14 +458,14 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
private void updateBlockState( DiskDriveState state )
|
private void updateBlockState( DiskDriveState state )
|
||||||
{
|
{
|
||||||
BlockState blockState = getBlockState();
|
BlockState blockState = getBlockState();
|
||||||
if( blockState.get( BlockDiskDrive.STATE ) == state ) return;
|
if( blockState.getValue( BlockDiskDrive.STATE ) == state ) return;
|
||||||
|
|
||||||
getWorld().setBlockState( getPos(), blockState.with( BlockDiskDrive.STATE, state ) );
|
getLevel().setBlockAndUpdate( getBlockPos(), blockState.setValue( BlockDiskDrive.STATE, state ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void ejectContents( boolean destroyed )
|
private synchronized void ejectContents( boolean destroyed )
|
||||||
{
|
{
|
||||||
if( getWorld().isRemote || m_diskStack.isEmpty() ) return;
|
if( getLevel().isClientSide || m_diskStack.isEmpty() ) return;
|
||||||
|
|
||||||
// Remove the disks from the inventory
|
// Remove the disks from the inventory
|
||||||
ItemStack disks = m_diskStack;
|
ItemStack disks = m_diskStack;
|
||||||
@ -477,19 +477,19 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
if( !destroyed )
|
if( !destroyed )
|
||||||
{
|
{
|
||||||
Direction dir = getDirection();
|
Direction dir = getDirection();
|
||||||
xOff = dir.getXOffset();
|
xOff = dir.getStepX();
|
||||||
zOff = dir.getZOffset();
|
zOff = dir.getStepZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockPos pos = getPos();
|
BlockPos pos = getBlockPos();
|
||||||
double x = pos.getX() + 0.5 + xOff * 0.5;
|
double x = pos.getX() + 0.5 + xOff * 0.5;
|
||||||
double y = pos.getY() + 0.75;
|
double y = pos.getY() + 0.75;
|
||||||
double z = pos.getZ() + 0.5 + zOff * 0.5;
|
double z = pos.getZ() + 0.5 + zOff * 0.5;
|
||||||
ItemEntity entityitem = new ItemEntity( getWorld(), x, y, z, disks );
|
ItemEntity entityitem = new ItemEntity( getLevel(), x, y, z, disks );
|
||||||
entityitem.setMotion( xOff * 0.15, 0, zOff * 0.15 );
|
entityitem.setDeltaMovement( xOff * 0.15, 0, zOff * 0.15 );
|
||||||
|
|
||||||
getWorld().addEntity( entityitem );
|
getLevel().addFreshEntity( entityitem );
|
||||||
if( !destroyed ) getWorld().playBroadcastSound( 1000, getPos(), 0 );
|
if( !destroyed ) getLevel().globalLevelEvent( 1000, getBlockPos(), 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private methods
|
// Private methods
|
||||||
@ -500,17 +500,17 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
SoundEvent record = contents != null ? contents.getAudio( m_diskStack ) : null;
|
SoundEvent record = contents != null ? contents.getAudio( m_diskStack ) : null;
|
||||||
if( record != null )
|
if( record != null )
|
||||||
{
|
{
|
||||||
RecordUtil.playRecord( record, contents.getAudioTitle( m_diskStack ), getWorld(), getPos() );
|
RecordUtil.playRecord( record, contents.getAudioTitle( m_diskStack ), getLevel(), getBlockPos() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RecordUtil.playRecord( null, null, getWorld(), getPos() );
|
RecordUtil.playRecord( null, null, getLevel(), getBlockPos() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopRecord()
|
private void stopRecord()
|
||||||
{
|
{
|
||||||
RecordUtil.playRecord( null, null, getWorld(), getPos() );
|
RecordUtil.playRecord( null, null, getLevel(), getBlockPos() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -549,7 +549,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
|||||||
@Override
|
@Override
|
||||||
public ITextComponent getName()
|
public ITextComponent getName()
|
||||||
{
|
{
|
||||||
return customName != null ? customName : new TranslationTextComponent( getBlockState().getBlock().getTranslationKey() );
|
return customName != null ? customName : new TranslationTextComponent( getBlockState().getBlock().getDescriptionId() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -35,7 +35,7 @@ public class GenericPeripheralProvider
|
|||||||
@Nullable
|
@Nullable
|
||||||
public static IPeripheral getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side, NonNullConsumer<LazyOptional<IPeripheral>> invalidate )
|
public static IPeripheral getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side, NonNullConsumer<LazyOptional<IPeripheral>> invalidate )
|
||||||
{
|
{
|
||||||
TileEntity tile = world.getTileEntity( pos );
|
TileEntity tile = world.getBlockEntity( pos );
|
||||||
if( tile == null ) return null;
|
if( tile == null ) return null;
|
||||||
|
|
||||||
ArrayList<SaturatedMethod> saturated = new ArrayList<>( 0 );
|
ArrayList<SaturatedMethod> saturated = new ArrayList<>( 0 );
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
*/
|
*/
|
||||||
package dan200.computercraft.shared.peripheral.generic.data;
|
package dan200.computercraft.shared.peripheral.generic.data;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.state.IProperty;
|
import net.minecraft.state.IProperty;
|
||||||
|
|
||||||
@ -21,7 +20,7 @@ public class BlockData
|
|||||||
data.put( "name", DataHelpers.getId( state.getBlock() ) );
|
data.put( "name", DataHelpers.getId( state.getBlock() ) );
|
||||||
|
|
||||||
Map<Object, Object> stateTable = new HashMap<>();
|
Map<Object, Object> stateTable = new HashMap<>();
|
||||||
for( ImmutableMap.Entry<IProperty<?>, ? extends Comparable<?>> entry : state.getValues().entrySet() )
|
for( Map.Entry<IProperty<?>, ? extends Comparable<?>> entry : state.getValues().entrySet() )
|
||||||
{
|
{
|
||||||
IProperty<?> property = entry.getKey();
|
IProperty<?> property = entry.getKey();
|
||||||
stateTable.put( property.getName(), getPropertyValue( property, entry.getValue() ) );
|
stateTable.put( property.getName(), getPropertyValue( property, entry.getValue() ) );
|
||||||
|
@ -52,12 +52,12 @@ public class ItemData
|
|||||||
|
|
||||||
fillBasic( data, stack );
|
fillBasic( data, stack );
|
||||||
|
|
||||||
data.put( "displayName", stack.getDisplayName().getString() );
|
data.put( "displayName", stack.getHoverName().getString() );
|
||||||
data.put( "maxCount", stack.getMaxStackSize() );
|
data.put( "maxCount", stack.getMaxStackSize() );
|
||||||
|
|
||||||
if( stack.isDamageable() )
|
if( stack.isDamageableItem() )
|
||||||
{
|
{
|
||||||
data.put( "damage", stack.getDamage() );
|
data.put( "damage", stack.getDamageValue() );
|
||||||
data.put( "maxDamage", stack.getMaxDamage() );
|
data.put( "maxDamage", stack.getMaxDamage() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ public class ItemData
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return ITextComponent.Serializer.fromJson( x.getString() );
|
return ITextComponent.Serializer.fromJson( x.getAsString() );
|
||||||
}
|
}
|
||||||
catch( JsonParseException e )
|
catch( JsonParseException e )
|
||||||
{
|
{
|
||||||
@ -138,7 +138,7 @@ public class ItemData
|
|||||||
* I'll do that to have the same data than ones displayed in tooltip.
|
* I'll do that to have the same data than ones displayed in tooltip.
|
||||||
* @see EnchantmentHelper.getEnchantments(ItemStack stack)
|
* @see EnchantmentHelper.getEnchantments(ItemStack stack)
|
||||||
*/
|
*/
|
||||||
addEnchantments( stack.getEnchantmentTagList(), enchants );
|
addEnchantments( stack.getEnchantmentTags(), enchants );
|
||||||
}
|
}
|
||||||
|
|
||||||
return enchants;
|
return enchants;
|
||||||
@ -157,14 +157,14 @@ public class ItemData
|
|||||||
|
|
||||||
enchants.ensureCapacity( enchants.size() + rawEnchants.size() );
|
enchants.ensureCapacity( enchants.size() + rawEnchants.size() );
|
||||||
|
|
||||||
for( Map.Entry<Enchantment, Integer> entry : EnchantmentHelper.func_226652_a_( rawEnchants ).entrySet() )
|
for( Map.Entry<Enchantment, Integer> entry : EnchantmentHelper.deserializeEnchantments( rawEnchants ).entrySet() )
|
||||||
{
|
{
|
||||||
Enchantment enchantment = entry.getKey();
|
Enchantment enchantment = entry.getKey();
|
||||||
Integer level = entry.getValue();
|
Integer level = entry.getValue();
|
||||||
HashMap<String, Object> enchant = new HashMap<>( 3 );
|
HashMap<String, Object> enchant = new HashMap<>( 3 );
|
||||||
enchant.put( "name", DataHelpers.getId( enchantment ) );
|
enchant.put( "name", DataHelpers.getId( enchantment ) );
|
||||||
enchant.put( "level", level );
|
enchant.put( "level", level );
|
||||||
enchant.put( "displayName", enchantment.getDisplayName( level ).getString() );
|
enchant.put( "displayName", enchantment.getFullname( level ).getString() );
|
||||||
enchants.add( enchant );
|
enchants.add( enchant );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,18 +14,18 @@ import javax.annotation.Nonnull;
|
|||||||
public final class ModemShapes
|
public final class ModemShapes
|
||||||
{
|
{
|
||||||
private static final VoxelShape[] BOXES = new VoxelShape[] {
|
private static final VoxelShape[] BOXES = new VoxelShape[] {
|
||||||
VoxelShapes.create( 0.125, 0.0, 0.125, 0.875, 0.1875, 0.875 ), // Down
|
VoxelShapes.box( 0.125, 0.0, 0.125, 0.875, 0.1875, 0.875 ), // Down
|
||||||
VoxelShapes.create( 0.125, 0.8125, 0.125, 0.875, 1.0, 0.875 ), // Up
|
VoxelShapes.box( 0.125, 0.8125, 0.125, 0.875, 1.0, 0.875 ), // Up
|
||||||
VoxelShapes.create( 0.125, 0.125, 0.0, 0.875, 0.875, 0.1875 ), // North
|
VoxelShapes.box( 0.125, 0.125, 0.0, 0.875, 0.875, 0.1875 ), // North
|
||||||
VoxelShapes.create( 0.125, 0.125, 0.8125, 0.875, 0.875, 1.0 ), // South
|
VoxelShapes.box( 0.125, 0.125, 0.8125, 0.875, 0.875, 1.0 ), // South
|
||||||
VoxelShapes.create( 0.0, 0.125, 0.125, 0.1875, 0.875, 0.875 ), // West
|
VoxelShapes.box( 0.0, 0.125, 0.125, 0.1875, 0.875, 0.875 ), // West
|
||||||
VoxelShapes.create( 0.8125, 0.125, 0.125, 1.0, 0.875, 0.875 ), // East
|
VoxelShapes.box( 0.8125, 0.125, 0.125, 1.0, 0.875, 0.875 ), // East
|
||||||
};
|
};
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static VoxelShape getBounds( Direction facing )
|
public static VoxelShape getBounds( Direction facing )
|
||||||
{
|
{
|
||||||
int direction = facing.ordinal();
|
int direction = facing.ordinal();
|
||||||
return direction < BOXES.length ? BOXES[direction] : VoxelShapes.fullCube();
|
return direction < BOXES.length ? BOXES[direction] : VoxelShapes.block();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user